From d3ac0938a7a0ce6455fc580f16eb7476cca87dc6 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 5 Dec 2021 11:33:43 +0000 Subject: [PATCH] nixos/top-level.nix: Make extensible (cherry picked from commit 4ec415cff9bcbaef08e0d900406a5c7181e71881) --- nixos/modules/system/activation/top-level.nix | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index b71ddf95dc50..55536552b2e2 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -93,6 +93,8 @@ let fi ''} + ${config.system.systemBuilderCommands} + echo -n "${toString config.system.extraDependencies}" > $out/extra-dependencies ${config.system.extraSystemBuilderCmds} @@ -103,7 +105,7 @@ let # kernel, systemd units, init scripts, etc.) as well as a script # `switch-to-configuration' that activates the configuration and # makes it bootable. - baseSystem = pkgs.stdenvNoCC.mkDerivation { + baseSystem = pkgs.stdenvNoCC.mkDerivation ({ name = "nixos-system-${config.system.name}-${config.system.nixos.label}"; preferLocalBuild = true; allowSubstitutes = false; @@ -125,7 +127,7 @@ let # Needed by switch-to-configuration. perl = pkgs.perl.withPackages (p: with p; [ ConfigIniFiles FileSlurp ]); - }; + } // config.system.systemBuilderArgs); # Handle assertions and warnings @@ -276,6 +278,24 @@ in ''; }; + system.systemBuilderCommands = mkOption { + type = types.lines; + internal = true; + default = ""; + description = '' + This code will be added to the builder creating the system store path. + ''; + }; + + system.systemBuilderArgs = mkOption { + type = types.attrsOf types.unspecified; + internal = true; + default = {}; + description = lib.mdDoc '' + `lib.mkDerivation` attributes that will be passed to the top level system builder. + ''; + }; + system.extraSystemBuilderCmds = mkOption { type = types.lines; internal = true;