Skip to content
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

pass "exclude" args to mksquashfs for storage-deficient devices #42795

Closed
wants to merge 1 commit into from

Conversation

telent
Copy link
Contributor

@telent telent commented Jun 29, 2018

Motivation for this change

This is debatable and I do not claim that the current behaviour is wrong. But: when building NixWRT images for storage-starved systems (one of my routers has 4MB flash) it is convenient to be able to say, for example, "exclude lib*.a and man pages" without having to hack every derivation that currently installs them.

  squashfs = pkgs.callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
    storeContents = packagesToInstall ;
    excludeWildcards = [ "... lib*.a" "... man/man[1-9]" ];
  };

Maybe it's generally useful, maybe it's a bit niche. If the latter, would you accept a more general patch to add any options at all to the mksquashfs call?

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I never used this, it seems to be pretty useful. It's also nice how this can be done with just a flag to mksquashfs. Other than my suggested change I'm in favor of adding this.

@@ -20,6 +20,7 @@ stdenv.mkDerivation {

# Generate the squashfs image.
mksquashfs nix-path-registration $(cat $closureInfo/store-paths) $out \
-keep-as-directory -all-root -b 1048576 -comp xz -Xdict-size 100%
-keep-as-directory -all-root -b 1048576 -comp xz -Xdict-size 100% \
-wildcards ${stdenv.lib.concatStringsSep " " (map (f: "-e '${f}' ") excludeWildcards)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's lib.escapeShellArg you can use to handle escaping properly.

@infinisil
Copy link
Member

Ping?

@dezgeg
Copy link
Contributor

dezgeg commented Aug 14, 2018

"exclude lib*.a and man pages" without having to hack every derivation that currently installs them.

All of these cases should be fixed by using multiple outputs. I would imagine most of the packages in the default install already do that, do you have any specific list of packages which need this treatment?

@danbst
Copy link
Contributor

danbst commented Dec 27, 2018

I'm adding another hack to make-squashfs.nix in e9775e5. If it is merged, you can implement your niche request by overriding comp argument:

  squashfs = pkgs.callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
    storeContents = packagesToInstall ;
    comp = "xz -Xdict-size 100% -wildcards ${stdenv.lib.concatStringsSep " " (map (f: "-e '${f}' ") excludeWildcards)}";
  };

@mmahut
Copy link
Member

mmahut commented Aug 13, 2019

Are there any updates on this pull request, please?

@danbst
Copy link
Contributor

danbst commented Aug 13, 2019

I'd say, this is pretty niche usecase. My PR https://github.com/NixOS/nixpkgs/pull/52967/files is merged, so workaround using comp argument can be used instead.

I regret now I've named the argument so narrow-scoped... It should have been called extraSquashfsArgs... But it should work here.

@danbst danbst closed this Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants