2022-09-26 17:19:14 +02:00
|
|
|
{
|
|
|
|
stdenv
|
|
|
|
, busybox
|
|
|
|
, buildPackages
|
|
|
|
, callPackage
|
|
|
|
, execline
|
|
|
|
, lib
|
2022-09-26 21:45:00 +02:00
|
|
|
, pseudofile
|
2022-09-26 17:19:14 +02:00
|
|
|
, runCommand
|
|
|
|
, s6-init-bin
|
|
|
|
, s6-init-files
|
|
|
|
, s6-linux-init
|
|
|
|
, s6-rc
|
|
|
|
, s6-rc-database
|
|
|
|
, stdenvNoCC
|
|
|
|
, writeScript
|
|
|
|
, writeText
|
|
|
|
} : config :
|
2022-09-20 00:51:38 +02:00
|
|
|
let
|
2022-09-21 00:04:08 +02:00
|
|
|
pseudofiles = writeText "pseudofiles" ''
|
|
|
|
/ d 0755 0 0
|
|
|
|
/bin d 0755 0 0
|
|
|
|
/etc d 0755 0 0
|
|
|
|
/run d 0755 0 0
|
|
|
|
/dev d 0755 0 0
|
|
|
|
/dev/null c 0666 root root 1 3
|
2022-09-22 00:01:21 +02:00
|
|
|
/dev/zero c 0666 root root 1 5
|
2022-09-21 00:04:08 +02:00
|
|
|
/dev/tty1 c 0777 root root 4 1
|
|
|
|
/dev/tty2 c 0777 root root 4 2
|
|
|
|
/dev/tty3 c 0777 root root 4 3
|
|
|
|
/dev/tty4 c 0777 root root 4 4
|
2022-09-22 00:01:21 +02:00
|
|
|
/dev/tty c 0777 root root 5 0
|
|
|
|
/dev/console c 0600 root root 5 1
|
2022-09-21 00:04:08 +02:00
|
|
|
/proc d 0555 root root
|
2022-09-22 01:10:00 +02:00
|
|
|
/sys d 0555 root root
|
2022-09-21 00:04:08 +02:00
|
|
|
/dev/pts d 0755 0 0
|
|
|
|
/etc/init.d d 0755 0 0
|
2022-09-26 17:19:14 +02:00
|
|
|
/bin/init s 0755 0 0 ${s6-init-bin}/bin/init
|
|
|
|
/bin/sh s 0755 0 0 ${busybox}/bin/sh
|
|
|
|
/bin/busybox s 0755 0 0 ${busybox}/bin/busybox
|
2022-09-21 00:04:08 +02:00
|
|
|
'';
|
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 16:59:21 +02:00
|
|
|
# add pseudofiles to store so that the packages they
|
|
|
|
# depend on are also added
|
2022-09-26 21:45:00 +02:00
|
|
|
storeContents = [
|
|
|
|
pseudofiles
|
|
|
|
s6-init-files
|
|
|
|
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-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-26 21:45:00 +02:00
|
|
|
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -pf ${pseudofiles} -pf ${s6-init-files} -pf ${config-pseudofiles}
|
2022-09-22 00:01:21 +02:00
|
|
|
cp store.img $out
|
|
|
|
''
|