liminix-fork/pkgs/liminix-tools/builders/squashfs.nix

29 lines
949 B
Nix
Raw Permalink Normal View History

2022-09-26 17:19:14 +02:00
{
stdenv
, busybox
, buildPackages
, callPackage
, pseudofile
2022-09-26 17:19:14 +02:00
, runCommand
, writeText
} : filesystem :
let
pseudofiles = pseudofile.write "files.pf" filesystem;
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
# 1) Every required package is referenced from somewhere
# outside /nix/store. 2) Every file outside the store is
# specified by config.filesystem. 3) Therefore, closing over
# the pseudofile will give us all the needed packages
storeContents = [ pseudofiles ];
};
in runCommand "frob-squashfs" {
2022-09-26 17:19:14 +02:00
nativeBuildInputs = with buildPackages; [ squashfsTools qprint ];
} ''
cp ${storefs} ./store.img
chmod +w store.img
2022-09-27 18:36:25 +02:00
mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${pseudofiles}
cp store.img $out
''