squashfs.nix (949B)
1 { 2 stdenv 3 , busybox 4 , buildPackages 5 , callPackage 6 , pseudofile 7 , runCommand 8 , writeText 9 } : filesystem : 10 let 11 pseudofiles = pseudofile.write "files.pf" filesystem; 12 13 storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> { 14 # 1) Every required package is referenced from somewhere 15 # outside /nix/store. 2) Every file outside the store is 16 # specified by config.filesystem. 3) Therefore, closing over 17 # the pseudofile will give us all the needed packages 18 storeContents = [ pseudofiles ]; 19 }; 20 in runCommand "frob-squashfs" { 21 nativeBuildInputs = with buildPackages; [ squashfsTools qprint ]; 22 } '' 23 cp ${storefs} ./store.img 24 chmod +w store.img 25 mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0" 26 mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${pseudofiles} 27 cp store.img $out 28 ''