diff --git a/.gitignore b/.gitignore index 8314f002..0d646f50 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ up.*.txt .hist/ scripts/docker/*.out scripts/docker/*.err + +# nix build output link +result diff --git a/contrib/package/nix/copyparty/default.nix b/contrib/package/nix/copyparty/default.nix new file mode 100644 index 00000000..8832aea8 --- /dev/null +++ b/contrib/package/nix/copyparty/default.nix @@ -0,0 +1,39 @@ +{ lib, stdenv, makeWrapper, fetchurl, utillinux, python, jinja2, mutagen, pillow +, pyvips, pyftpdlib, pyopenssl, impacket, ffmpeg }: + +let + pyEnv = python.withPackages (ps: + with ps; [ + # mandatory + jinja2 + # thumbnails + pyvips + ffmpeg + # alternative thumbnails, but not needed in the presence of pyvips and ffmpeg + # pillow pyheif-pillow-opener pillow-avif-plugin + # audio metadata + mutagen + # ftp server + pyftpdlib + pyopenssl + # smb server + impacket + ]); +in stdenv.mkDerivation rec { + pname = "copyparty"; + version = "1.6.11"; + src = fetchurl { + url = + "https://github.com/9001/copyparty/releases/download/v${version}/copyparty-sfx.py"; + hash = "sha256-0JbjOrZm70UhOJndOhBzX2K1RBM5y3N0+TsjLQtsjTQ="; + }; + buildInputs = [ makeWrapper ]; + dontUnpack = true; + dontBuild = true; + installPhase = '' + install -Dm755 $src $out/share/copyparty-sfx.py + makeWrapper ${pyEnv.interpreter} $out/bin/copyparty \ + --set PATH '${lib.makeBinPath [ utillinux ffmpeg ]}:$PATH' \ + --add-flags "$out/share/copyparty-sfx.py" + ''; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..2162ad8c --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1680334310, + "narHash": "sha256-ISWz16oGxBhF7wqAxefMPwFag6SlsA9up8muV79V9ck=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "884e3b68be02ff9d61a042bc9bd9dd2a358f95da", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..63c6c3c3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-22.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + { + overlays.default = self: super: { + copyparty = + self.python3.pkgs.callPackage ./contrib/package/nix/copyparty { + ffmpeg = self.ffmpeg-full; + }; + }; + } // flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; + in { + packages = { + inherit (pkgs) copyparty; + default = self.packages.${system}.copyparty; + }; + }); +}