nix: make deps optional + update docs

This commit is contained in:
ed 2023-04-17 13:17:53 +02:00
parent 397bc92fbc
commit dbbba9625b
4 changed files with 58 additions and 19 deletions

3
.gitignore vendored
View file

@ -21,6 +21,9 @@ copyparty.egg-info/
# winmerge # winmerge
*.bak *.bak
# apple pls
.DS_Store
# derived # derived
copyparty/res/COPYING.txt copyparty/res/COPYING.txt
copyparty/web/deps/ copyparty/web/deps/

View file

@ -69,6 +69,8 @@ turn almost any device into a file server with resumable uploads/downloads using
* [themes](#themes) * [themes](#themes)
* [complete examples](#complete-examples) * [complete examples](#complete-examples)
* [reverse-proxy](#reverse-proxy) - running copyparty next to other websites * [reverse-proxy](#reverse-proxy) - running copyparty next to other websites
* [nix package](#nix-package) - `nix profile install github:9001/copyparty`
* [nixos module](#nixos-module)
* [browser support](#browser-support) - TLDR: yes * [browser support](#browser-support) - TLDR: yes
* [client examples](#client-examples) - interact with copyparty using non-browser clients * [client examples](#client-examples) - interact with copyparty using non-browser clients
* [folder sync](#folder-sync) - sync folders to/from copyparty * [folder sync](#folder-sync) - sync folders to/from copyparty
@ -101,8 +103,7 @@ just run **[copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/
* or install through pypi (python3 only): `python3 -m pip install --user -U copyparty` * or install through pypi (python3 only): `python3 -m pip install --user -U copyparty`
* or if you cannot install python, you can use [copyparty.exe](#copypartyexe) instead * or if you cannot install python, you can use [copyparty.exe](#copypartyexe) instead
* or install through nix: `nix profile install github:9001/copyparty` * or [install through nix](#nix-package), or [on NixOS](#nixos-module)
* requires a [flake-enabled](https://nixos.wiki/wiki/Flakes) installation of nix
* or if you are on android, [install copyparty in termux](#install-on-android) * or if you are on android, [install copyparty in termux](#install-on-android)
* or if you prefer to [use docker](./scripts/docker/) 🐋 you can do that too * or if you prefer to [use docker](./scripts/docker/) 🐋 you can do that too
* docker has all deps built-in, so skip this step: * docker has all deps built-in, so skip this step:
@ -1165,7 +1166,20 @@ example webserver configs:
* [nginx config](contrib/nginx/copyparty.conf) -- entire domain/subdomain * [nginx config](contrib/nginx/copyparty.conf) -- entire domain/subdomain
* [apache2 config](contrib/apache/copyparty.conf) -- location-based * [apache2 config](contrib/apache/copyparty.conf) -- location-based
## nix package
`nix profile install github:9001/copyparty`
requires a [flake-enabled](https://nixos.wiki/wiki/Flakes) installation of nix
some recommended dependencies are enabled by default; [override the package](https://github.com/9001/copyparty/blob/hovudstraum/contrib/package/nix/copyparty/default.nix#L3-L22) if you want to add/remove some features/deps
`ffmpeg-full` was chosen over `ffmpeg-headless` mainly because we need `withWebp` (and `withOpenmpt` is also nice) and being able to use a cached build felt more important than optimizing for size at the time -- PRs welcome if you disagree 👍
## nixos module ## nixos module
for this setup, you will need a [flake-enabled](https://nixos.wiki/wiki/Flakes) installation of NixOS. for this setup, you will need a [flake-enabled](https://nixos.wiki/wiki/Flakes) installation of NixOS.
```nix ```nix
@ -1254,6 +1268,9 @@ services.copyparty = {
}; };
``` ```
the passwordFile at /run/keys/copyparty/ could for example be generated by [agenix](https://github.com/ryantm/agenix), or you could just dump it in the nix store instead if that's acceptable
# browser support # browser support
TLDR: yes TLDR: yes

View file

@ -1,24 +1,41 @@
{ lib, stdenv, makeWrapper, fetchurl, utillinux, python, jinja2, mutagen, pillow { lib, stdenv, makeWrapper, fetchurl, utillinux, python, jinja2, impacket, pyftpdlib, pyopenssl, pillow, pyvips, ffmpeg, mutagen,
, pyvips, pyftpdlib, pyopenssl, impacket, ffmpeg }:
# create thumbnails with Pillow; faster than FFmpeg / MediaProcessing
withThumbnails ? true,
# create thumbnails with PyVIPS; even faster, uses more memory
# -- can be combined with Pillow to support more filetypes
withFastThumbnails ? false,
# enable FFmpeg; thumbnails for most filetypes (also video and audio), extract audio metadata, transcode audio to opus
# -- possibly dangerous if you allow anonymous uploads, since FFmpeg has a huge attack surface
# -- can be combined with Thumbnails and/or FastThumbnails, since FFmpeg is slower than both
withMediaProcessing ? true,
# if MediaProcessing is not enabled, you probably want this instead (less accurate, but much safer and faster)
withBasicAudioMetadata ? false,
# enable FTPS support in the FTP server
withFTPS ? false,
# samba/cifs server; dangerous and buggy, enable if you really need it
withSMB ? false,
}:
let let
pinData = lib.importJSON ./pin.json; pinData = lib.importJSON ./pin.json;
pyEnv = python.withPackages (ps: pyEnv = python.withPackages (ps:
with ps; [ with ps; [
# mandatory
jinja2 jinja2
# thumbnails ]
pyvips ++ lib.optional withSMB impacket
# alternative thumbnails, but not needed in the presence of pyvips and ffmpeg ++ lib.optional withFTPS pyopenssl
# pillow pyheif-pillow-opener pillow-avif-plugin ++ lib.optional withThumbnails pillow
# audio metadata ++ lib.optional withFastThumbnails pyvips
mutagen ++ lib.optional withMediaProcessing ffmpeg
# ftp server ++ lib.optional withBasicAudioMetadata mutagen
pyftpdlib );
pyopenssl
# smb server
impacket
]);
in stdenv.mkDerivation { in stdenv.mkDerivation {
pname = "copyparty"; pname = "copyparty";
version = pinData.version; version = pinData.version;
@ -32,7 +49,7 @@ in stdenv.mkDerivation {
installPhase = '' installPhase = ''
install -Dm755 $src $out/share/copyparty-sfx.py install -Dm755 $src $out/share/copyparty-sfx.py
makeWrapper ${pyEnv.interpreter} $out/bin/copyparty \ makeWrapper ${pyEnv.interpreter} $out/bin/copyparty \
--set PATH '${lib.makeBinPath [ utillinux ffmpeg ]}:$PATH' \ --set PATH '${lib.makeBinPath ([ utillinux ] ++ lib.optional withMediaProcessing ffmpeg)}:$PATH' \
--add-flags "$out/share/copyparty-sfx.py" --add-flags "$out/share/copyparty-sfx.py"
''; '';
} }

View file

@ -16,7 +16,9 @@ cat $f | awk '
h=0 h=0
}; };
}; };
/^#/{s=1;pr()} /^#* *(install on android|dev env setup|just the sfx|complete release|optional gpl stuff)|`$/{s=0} /^#/{s=1;rs=0;pr()}
/^#* *(nix package)/{rs=1}
/^#* *(install on android|dev env setup|just the sfx|complete release|optional gpl stuff|nixos module)|`$/{s=rs}
/^#/{ /^#/{
lv=length($1); lv=length($1);
sub(/[^ ]+ /,""); sub(/[^ ]+ /,"");