-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
compressDrv and compressDrvWeb follow up #332752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cbd09ef
zopfli: set meta.mainProgram
SuperSandro2000 d3a139b
zstd: set meta.mainProgram
SuperSandro2000 7ebbf27
compress-drv: sort formats
SuperSandro2000 6449d32
compress-drv: add htm, otf formats to default
SuperSandro2000 9581a2b
compress-drv: misc cleanup
SuperSandro2000 0ca4bfa
compress-drv: add zstd
SuperSandro2000 4cc5dee
compress-drv: allow passing extra arguments to find
SuperSandro2000 0654f81
compress-drv: carry pname, version forward
SuperSandro2000 a1d5c9d
paperless-ngx: change symlink to work with compressDrvWeb
SuperSandro2000 0505523
compress-drv: correct comment
SuperSandro2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; }) | ||
SuperSandro2000 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| '' | ||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks |
||
| (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)} | ||
| '' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious, why use lib over builtin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it makes really no difference but some lib functions contain backwards compatibility code like
nixpkgs/lib/deprecated/misc.nix
Lines 211 to 213 in c3ede4a