liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

squashfs.nix (957B)


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