commit bd6cbd373f79712f14d1186d218ec8f860ce9868
parent 09a9dba96347a9c6a326d393b33b515eb6f55ecb
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 26 Sep 2022 20:45:00 +0100
add config environment.etc which gets converted to pseudofiles
Diffstat:
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/make-image.nix b/make-image.nix
@@ -5,6 +5,7 @@
, callPackage
, execline
, lib
+, pseudofile
, runCommand
, s6-init-bin
, s6-init-files
@@ -20,11 +21,6 @@ let
services = builtins.attrValues config.services;
};
- profile = writeScript ".profile" ''
- PATH=${lib.makeBinPath ([ s6-init-bin busybox execline s6-linux-init s6-rc])}
- export PATH
- '';
-
pseudofiles = writeText "pseudofiles" ''
/ d 0755 0 0
/bin d 0755 0 0
@@ -49,12 +45,19 @@ let
/etc/s6-rc d 0755 0 0
/etc/s6-rc/compiled s 0755 0 0 ${s6-rc-db}/compiled
/etc/passwd f 0644 0 0 echo "root::0:0:root:/:/bin/sh"
- /.profile s 0644 0 0 ${profile}
'';
+
+ config-pseudofiles = pseudofile.write "config.etc"
+ (config.environment.contents);
+
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
# add pseudofiles to store so that the packages they
# depend on are also added
- storeContents = [ pseudofiles s6-init-files ] ++ config.packages ;
+ storeContents = [
+ pseudofiles
+ s6-init-files
+ config-pseudofiles
+ ] ++ config.packages ;
};
in runCommand "frob-squashfs" {
nativeBuildInputs = with buildPackages; [ squashfsTools qprint ];
@@ -62,6 +65,6 @@ in runCommand "frob-squashfs" {
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 ${s6-init-files}
+ mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -pf ${pseudofiles} -pf ${s6-init-files} -pf ${config-pseudofiles}
cp store.img $out
''
diff --git a/modules/base.nix b/modules/base.nix
@@ -17,6 +17,7 @@ in {
services = mkOption {
type = types.attrsOf type_service;
};
+ environment = mkOption { type = types.anything; };
kernel = {
config = mkOption {
# mostly the values are y n or m, but sometimes
@@ -28,4 +29,16 @@ in {
};
};
};
+ config = {
+ environment = dir {
+ etc = dir {
+ profile = symlink
+ (pkgs.writeScript ".profile" ''
+ PATH=${lib.makeBinPath (with pkgs; [ s6-init-bin busybox execline s6-linux-init s6-rc])}
+ export PATH
+ '');
+
+ };
+ };
+ };
}