squashfs.nix (971B)
1 { 2 buildPackages, 3 callPackage, 4 nixpkgs, 5 pseudofile, 6 runCommand, 7 writeText, 8 }: 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 21 runCommand "frob-squashfs" 22 { 23 nativeBuildInputs = with buildPackages; [ 24 squashfsTools 25 qprint 26 ]; 27 } 28 '' 29 cp ${storefs} ./store.img 30 chmod +w store.img 31 mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0" 32 mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${pseudofiles} 33 cp store.img $out 34 ''