From 696bbe6521c129855d5223c7b598607485f6a683 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 27 Sep 2022 16:17:55 +0100 Subject: [PATCH] rename systemPackages as defaultProfile.packages it doesn't work the same way as in nixos, so don't name it the same way --- default.nix | 6 +----- modules/base.nix | 14 ++++++++++---- pkgs/liminix-tools/builders/squashfs.nix | 16 ++++++++-------- tests/pppoe/configuration.nix | 2 +- tests/smoke/configuration.nix | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/default.nix b/default.nix index 541ed5d..71c243f 100644 --- a/default.nix +++ b/default.nix @@ -11,11 +11,7 @@ let ./modules/s6 ] nixpkgs.pkgs; - finalConfig = config // { - packages = config.systemPackages ++ - (builtins.attrValues config.services); - }; - squashfs = liminix.builders.squashfs finalConfig; + squashfs = liminix.builders.squashfs config; kernel = callPackage ./kernel { inherit (config.kernel) config; }; diff --git a/modules/base.nix b/modules/base.nix index 68e90da..807ff91 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, ...}: +{ lib, pkgs, config, ...}: let inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; inherit (pkgs.pseudofile) dir symlink; @@ -12,8 +12,12 @@ let in { options = { - systemPackages = mkOption { - type = types.listOf types.package; + # analogous to nixos systemPackages, but we don't symlink into + # /run/current-system, we just add the paths in /etc/profile + defaultProfile = { + packages = mkOption { + type = types.listOf types.package; + }; }; services = mkOption { type = types.attrsOf type_service; @@ -31,6 +35,8 @@ in { }; }; config = { + defaultProfile.packages = with pkgs; + [ s6-init-bin busybox execline s6-linux-init s6-rc ]; environment = dir { bin = dir { sh = symlink "${busybox}/bin/sh"; @@ -48,7 +54,7 @@ in { etc = dir { profile = symlink (pkgs.writeScript ".profile" '' - PATH=${lib.makeBinPath (with pkgs; [ s6-init-bin busybox execline s6-linux-init s6-rc])} + PATH=${lib.makeBinPath config.defaultProfile.packages} export PATH ''); passwd = { file = "root::0:0:root:/:/bin/sh\n"; }; diff --git a/pkgs/liminix-tools/builders/squashfs.nix b/pkgs/liminix-tools/builders/squashfs.nix index 5ac51f7..b88fd52 100644 --- a/pkgs/liminix-tools/builders/squashfs.nix +++ b/pkgs/liminix-tools/builders/squashfs.nix @@ -8,15 +8,15 @@ , writeText } : config : let - config-pseudofiles = pseudofile.write "config.etc" - (config.environment.contents); + pseudofiles = + pseudofile.write "config.etc" (config.environment.contents); storefs = callPackage { - # add pseudofiles as packages to store so that the packages they - # depend on are also added - storeContents = [ - config-pseudofiles - ] ++ config.packages ; + # 1) Every required package is referenced from somewhere + # outside /nix/store. 2) Every file outside the store is + # specified by config.environment. 3) Therefore, closing over + # the pseudofile will give us all the needed packages + storeContents = [ pseudofiles ]; }; in runCommand "frob-squashfs" { nativeBuildInputs = with buildPackages; [ squashfsTools qprint ]; @@ -24,6 +24,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 -p "/ d 0755 0 0" -pf ${config-pseudofiles} + mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${pseudofiles} cp store.img $out '' diff --git a/tests/pppoe/configuration.nix b/tests/pppoe/configuration.nix index f08f05c..6067270 100644 --- a/tests/pppoe/configuration.nix +++ b/tests/pppoe/configuration.nix @@ -68,5 +68,5 @@ in rec { ]; }; - systemPackages = [ pkgs.hello ] ; + defaultProfile.packages = [ pkgs.hello ] ; } diff --git a/tests/smoke/configuration.nix b/tests/smoke/configuration.nix index c92967f..c59410a 100644 --- a/tests/smoke/configuration.nix +++ b/tests/smoke/configuration.nix @@ -63,5 +63,5 @@ in rec { contents = with services; [ loopback ntp defaultroute4 ]; }; - systemPackages = [ pkgs.hello ] ; + defaultProfile.packages = [ pkgs.hello ] ; }