summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdam Stephens <adam@valkor.net>2023-10-12 10:51:41 -0400
committerAdam Stephens <adam@valkor.net>2023-10-12 10:51:41 -0400
commita91bd0b468ae5bb51802ddb767ebcaf9954b605b (patch)
treed4672306fd66b5158738f08537f50ca257590e30
parentd4e6bfe2972da4f69b48db2b36be70db8c1503f5 (diff)
downloadnixpkgs-a91bd0b468ae5bb51802ddb767ebcaf9954b605b.tar
nixpkgs-a91bd0b468ae5bb51802ddb767ebcaf9954b605b.tar.gz
nixpkgs-a91bd0b468ae5bb51802ddb767ebcaf9954b605b.tar.bz2
nixpkgs-a91bd0b468ae5bb51802ddb767ebcaf9954b605b.tar.lz
nixpkgs-a91bd0b468ae5bb51802ddb767ebcaf9954b605b.tar.xz
nixpkgs-a91bd0b468ae5bb51802ddb767ebcaf9954b605b.tar.zst
nixpkgs-a91bd0b468ae5bb51802ddb767ebcaf9954b605b.zip
make-squashfs: add support for pseudoFiles, custom name, and disabling strip
-rw-r--r--nixos/lib/make-squashfs.nix13
1 files changed, 10 insertions, 3 deletions
diff --git a/nixos/lib/make-squashfs.nix b/nixos/lib/make-squashfs.nix
index b7c7078b73b..4b6b5673994 100644
--- a/nixos/lib/make-squashfs.nix
+++ b/nixos/lib/make-squashfs.nix
@@ -1,15 +1,22 @@
 { lib, stdenv, squashfsTools, closureInfo
 
+,  fileName ? "squashfs"
 , # The root directory of the squashfs filesystem is filled with the
   # closures of the Nix store paths listed here.
   storeContents ? []
+  # Pseudo files to be added to squashfs image
+, pseudoFiles ? []
+, noStrip ? false
 , # Compression parameters.
   # For zstd compression you can use "zstd -Xcompression-level 6".
   comp ? "xz -Xdict-size 100%"
 }:
 
+let
+  pseudoFilesArgs = lib.concatMapStrings (f: ''-p "${f}" '') pseudoFiles;
+in
 stdenv.mkDerivation {
-  name = "squashfs.img";
+  name = "${fileName}.img";
   __structuredAttrs = true;
 
   nativeBuildInputs = [ squashfsTools ];
@@ -31,8 +38,8 @@ stdenv.mkDerivation {
     '' + ''
 
       # Generate the squashfs image.
-      mksquashfs nix-path-registration $(cat $closureInfo/store-paths) $out \
-        -no-hardlinks -keep-as-directory -all-root -b 1048576 -comp ${comp} \
+      mksquashfs nix-path-registration $(cat $closureInfo/store-paths) $out ${pseudoFilesArgs} \
+        -no-hardlinks ${lib.optionalString noStrip "-no-strip"} -keep-as-directory -all-root -b 1048576 -comp ${comp} \
         -processors $NIX_BUILD_CORES
     '';
 }