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-26 21:45:00 +02:00
|
|
|
config-pseudofiles = pseudofile.write "config.etc"
|
|
|
|
(config.environment.contents);
|
|
|
|
|
2022-09-22 00:01:21 +02:00
|
|
|
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
|
2022-09-26 22:11:07 +02:00
|
|
|
# add pseudofiles as packages to store so that the packages they
|
2022-09-26 16:59:21 +02:00
|
|
|
# depend on are also added
|
2022-09-26 21:45:00 +02:00
|
|
|
storeContents = [
|
|
|
|
config-pseudofiles
|
|
|
|
] ++ config.packages ;
|
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 15:06:07 +02:00
|
|
|
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${config-pseudofiles}
|
2022-09-22 00:01:21 +02:00
|
|
|
cp store.img $out
|
2022-09-27 15:06:07 +02:00
|
|
|
''
|