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