From bd6cbd373f79712f14d1186d218ec8f860ce9868 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 26 Sep 2022 20:45:00 +0100 Subject: [PATCH] add config environment.etc which gets converted to pseudofiles --- make-image.nix | 19 +++++++++++-------- modules/base.nix | 13 +++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/make-image.nix b/make-image.nix index c39ded1..ba4343a 100644 --- 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 { # 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 index 7ac3a77..34eae73 100644 --- 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 + ''); + + }; + }; + }; }