diff --git a/pkgs/applications/office/paperless-ngx/default.nix b/pkgs/applications/office/paperless-ngx/default.nix index 391569825b183..be9b11f5da015 100644 --- a/pkgs/applications/office/paperless-ngx/default.nix +++ b/pkgs/applications/office/paperless-ngx/default.nix @@ -21,6 +21,7 @@ , pango , pkg-config , nltk-data +, xorg }: let @@ -121,6 +122,7 @@ python.pkgs.buildPythonApplication rec { nativeBuildInputs = [ gettext + xorg.lndir ]; propagatedBuildInputs = with python.pkgs; [ @@ -194,9 +196,9 @@ python.pkgs.buildPythonApplication rec { in '' runHook preInstall - mkdir -p $out/lib/paperless-ngx + mkdir -p $out/lib/paperless-ngx/static/frontend cp -r {src,static,LICENSE,gunicorn.conf.py} $out/lib/paperless-ngx - ln -s ${frontend}/lib/paperless-ui/frontend $out/lib/paperless-ngx/static/ + lndir -silent ${frontend}/lib/paperless-ui/frontend $out/lib/paperless-ngx/static/frontend chmod +x $out/lib/paperless-ngx/src/manage.py makeWrapper $out/lib/paperless-ngx/src/manage.py $out/bin/paperless-ngx \ --prefix PYTHONPATH : "${pythonPath}" \ diff --git a/pkgs/build-support/compress-drv/default.nix b/pkgs/build-support/compress-drv/default.nix index 0773ab9e0554e..f1ace8c7a7aa2 100644 --- a/pkgs/build-support/compress-drv/default.nix +++ b/pkgs/build-support/compress-drv/default.nix @@ -9,6 +9,12 @@ : List of file extensions to compress. Example: `["txt" "svg" "xml"]`. + `extraFindOperands` (String) + + : Extra command line parameters to pass to the find command. + This can be used to exclude certain files. + For example: `-not -iregex ".*(\/apps\/.*\/l10n\/).*"` + `compressors` ( { ${fileExtension} :: String }) : Map a desired extension (e.g. `gz`) to a compress program. @@ -47,7 +53,11 @@ ::: */ drv: -{ formats, compressors }: +{ + formats, + compressors, + extraFindOperands ? "", +}: let validProg = ext: prog: @@ -61,18 +71,22 @@ let ext: prog: assert validProg ext prog; '' - find -L $out -type f -regextype posix-extended -iregex '.*\.(${formatsPipe})' -print0 \ + find -L $out -type f -regextype posix-extended -iregex '.*\.(${formatsPipe})' ${extraFindOperands} -print0 \ | xargs -0 -P$NIX_BUILD_CORES -I{} ${prog} ''; - formatsPipe = builtins.concatStringsSep "|" formats; + formatsPipe = lib.concatStringsSep "|" formats; in -runCommand "${drv.name}-compressed" { } '' - mkdir $out +runCommand "${drv.name}-compressed" + ( + (lib.optionalAttrs (drv ? pname) { inherit (drv) pname; }) + // (lib.optionalAttrs (drv ? version) { inherit (drv) version; }) + ) + '' + mkdir $out - # cannot use lndir here, because it also symlinks directories, - # which we do not need; we only need to symlink files. - (cd ${drv}; find -L -type d -exec mkdir -p $out/{} ';') - (cd ${drv}; find -L -type f -exec ln -s ${drv}/{} $out/{} ';') + # cannot use lndir here, because it stop recursing at symlinks that point to directories + (cd ${drv}; find -L -type d -exec mkdir -p $out/{} ';') + (cd ${drv}; find -L -type f -exec ln -s ${drv}/{} $out/{} ';') - ${lib.concatStringsSep "\n\n" (lib.mapAttrsToList mkCmd compressors)} -'' + ${lib.concatStringsSep "\n\n" (lib.mapAttrsToList mkCmd compressors)} + '' diff --git a/pkgs/build-support/compress-drv/web.nix b/pkgs/build-support/compress-drv/web.nix index 86ed99e26fa7f..17deb1c0e3bd0 100644 --- a/pkgs/build-support/compress-drv/web.nix +++ b/pkgs/build-support/compress-drv/web.nix @@ -1,7 +1,9 @@ { - zopfli, brotli, compressDrv, + lib, + zopfli, + zstd, }: /** compressDrvWeb compresses a derivation for common web server use. @@ -17,6 +19,10 @@ Defaults to common formats that compress well. + `extraFindOperands` (String) + + : See compressDrv for details. + `extraFormats` ([ String ]) : Extra extensions to compress in addition to `formats`. @@ -108,24 +114,32 @@ drv: { formats ? [ "css" + "eot" + "htm" + "html" "js" + "json" + "map" + "otf" "svg" "ttf" - "eot" "txt" - "xml" - "map" - "html" - "json" "webmanifest" + "xml" ], extraFormats ? [ ], compressors ? { - "gz" = "${zopfli}/bin/zopfli --keep {}"; - "br" = "${brotli}/bin/brotli --keep --no-copy-stat {}"; + br = "${lib.getExe brotli} --keep --no-copy-stat {}"; + gz = "${lib.getExe zopfli} --keep {}"; + # --force is required to not fail on symlinks + # for details on the compression level see + # https://github.com/NixOS/nixpkgs/pull/332752#issuecomment-2275110390 + zstd = "${lib.getExe zstd} --force --keep --quiet -19 {}"; }, + extraFindOperands ? "", }: compressDrv drv { formats = formats ++ extraFormats; compressors = compressors; + inherit extraFindOperands; } diff --git a/pkgs/tools/compression/zopfli/default.nix b/pkgs/tools/compression/zopfli/default.nix index 2c844cffc21b6..8d8813e2eda4f 100644 --- a/pkgs/tools/compression/zopfli/default.nix +++ b/pkgs/tools/compression/zopfli/default.nix @@ -34,6 +34,7 @@ stdenv.mkDerivation rec { ''; platforms = platforms.unix; license = licenses.asl20; + mainProgram = "zopfli"; maintainers = with maintainers; [ bobvanderlinden edef ]; }; } diff --git a/pkgs/tools/compression/zstd/default.nix b/pkgs/tools/compression/zstd/default.nix index d42866cdda9f9..ba5fb90c1360e 100644 --- a/pkgs/tools/compression/zstd/default.nix +++ b/pkgs/tools/compression/zstd/default.nix @@ -122,7 +122,7 @@ stdenv.mkDerivation rec { homepage = "https://facebook.github.io/zstd/"; changelog = "https://github.com/facebook/zstd/blob/v${version}/CHANGELOG"; license = with licenses; [ bsd3 ]; # Or, at your opinion, GPL-2.0-only. - + mainProgram = "zstd"; platforms = platforms.all; maintainers = with maintainers; [ orivej ]; };