commit e40a91fca06d4a7dcac251aee6b7d30050ce0def
parent 797aa30c475b7317e774c783ee58cbe854060fb2
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 27 Sep 2022 14:06:07 +0100
move all remaining pseudofiles to base module
Diffstat:
3 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/make-image.nix b/make-image.nix
@@ -8,28 +8,6 @@
, writeText
} : config :
let
- 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
- /dev/zero c 0666 root root 1 5
- /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
- /dev/tty c 0777 root root 5 0
- /dev/console c 0600 root root 5 1
- /proc d 0555 root root
- /sys d 0555 root root
- /dev/pts d 0755 0 0
- /etc/init.d d 0755 0 0
- /bin/sh s 0755 0 0 ${busybox}/bin/sh
- /bin/busybox s 0755 0 0 ${busybox}/bin/busybox
- '';
-
config-pseudofiles = pseudofile.write "config.etc"
(config.environment.contents);
@@ -37,16 +15,15 @@ let
# add pseudofiles as packages to store so that the packages they
# depend on are also added
storeContents = [
- pseudofiles
config-pseudofiles
] ++ config.packages ;
};
in runCommand "frob-squashfs" {
nativeBuildInputs = with buildPackages; [ squashfsTools qprint ];
- } ''
+} ''
cp ${storefs} ./store.img
chmod +w store.img
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
- mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -pf ${pseudofiles} -pf ${config-pseudofiles}
+ mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${config-pseudofiles}
cp store.img $out
- ''
+''
diff --git a/modules/base.nix b/modules/base.nix
@@ -2,6 +2,7 @@
let
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
inherit (pkgs.pseudofile) dir symlink;
+ inherit (pkgs) busybox;
type_service = types.package // {
name = "service";
@@ -31,6 +32,19 @@ in {
};
config = {
environment = dir {
+ bin = dir {
+ sh = symlink "${busybox}/bin/sh";
+ busybox = symlink "${busybox}/bin/busybox";
+ };
+ dev =
+ let node = type: major: minor: mode : { inherit type major minor mode; };
+ in dir {
+ null = node "c" "1" "3" "0666";
+ zero = node "c" "1" "5" "0666";
+ tty = node "c" "5" "0" "0666";
+ console = node "c" "5" "1" "0600";
+ pts = dir {};
+ };
etc = dir {
profile = symlink
(pkgs.writeScript ".profile" ''
@@ -40,6 +54,9 @@ in {
passwd = { file = "root::0:0:root:/:/bin/sh\n"; };
group = { file = "root::0:\n"; };
};
+ proc = dir {};
+ run = dir {};
+ sys = dir {};
};
};
}
diff --git a/pkgs/pseudofile/default.nix b/pkgs/pseudofile/default.nix
@@ -21,6 +21,10 @@ let
else if attrs'.type == "d" then
(visit "${prefix}/${filename}" attrs.contents) +
"\n" + line
+ else if attrs'.type == "c" then
+ with attrs'; "${line} ${major} ${minor}"
+ else if attrs'.type == "b" then
+ with attrs'; "${line} ${major} ${minor}"
else if attrs'.type == "s" then
"${line} ${attrs'.target}"
else if attrs'.type == "l" then