From 172ac3d46df733fde8516f477c7b08fd1f56fac0 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 20 Jan 2022 14:53:35 +0100 Subject: [PATCH 1/3] nixos/system/build: Extract Extracting system.build into its own module allows other modules that do not depend on e.g. toplevel to be evaluated, used and tested in isolation. --- nixos/modules/system/activation/top-level.nix | 10 +--------- nixos/modules/system/build.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 nixos/modules/system/build.nix diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 1c588ff969184..e10d668ad2cf6 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -139,21 +139,13 @@ in { imports = [ + ../build.nix (mkRemovedOptionModule [ "nesting" "clone" ] "Use `specialisation.«name» = { inheritParentConfig = true; configuration = { ... }; }` instead.") (mkRemovedOptionModule [ "nesting" "children" ] "Use `specialisation.«name».configuration = { ... }` instead.") ]; options = { - system.build = mkOption { - internal = true; - default = {}; - type = types.lazyAttrsOf types.unspecified; - description = '' - Attribute set of derivations used to setup the system. - ''; - }; - specialisation = mkOption { default = {}; example = lib.literalExpression "{ fewJobsManyCores.configuration = { nix.buildCores = 0; nix.maxJobs = 1; }; }"; diff --git a/nixos/modules/system/build.nix b/nixos/modules/system/build.nix new file mode 100644 index 0000000000000..a8fc5dc78be5f --- /dev/null +++ b/nixos/modules/system/build.nix @@ -0,0 +1,18 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options = { + + system.build = mkOption { + internal = true; + default = {}; + type = types.lazyAttrsOf types.unspecified; + description = '' + Attribute set of derivations used to set up the system. + ''; + }; + + }; +} From 50e48a57c51252c5b1207101889e8fd29cb35f41 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 20 Jan 2022 15:04:08 +0100 Subject: [PATCH 2/3] nixos: Make system.build a submodule with freeformType This allows the values below it to be specified as options, while remaining compatible with existing code. --- nixos/modules/system/build.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/build.nix b/nixos/modules/system/build.nix index a8fc5dc78be5f..f7e2c8dfb1a44 100644 --- a/nixos/modules/system/build.nix +++ b/nixos/modules/system/build.nix @@ -6,12 +6,15 @@ in options = { system.build = mkOption { - internal = true; default = {}; - type = types.lazyAttrsOf types.unspecified; description = '' Attribute set of derivations used to set up the system. ''; + type = types.submoduleWith { + modules = [{ + freeformType = types.lazyAttrsOf types.unspecified; + }]; + }; }; }; From 28e8aeb34dc236db77405fbaeee99b29d6b3ec81 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 20 Jan 2022 15:05:45 +0100 Subject: [PATCH 3/3] nixos: Document system.build.toplevel --- nixos/modules/system/activation/top-level.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index e10d668ad2cf6..eae4b8c4e65ab 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -293,6 +293,16 @@ in ''; }; + system.build.toplevel = mkOption { + type = types.package; + readOnly = true; + description = '' + This option contains the store path that typically represents a NixOS system. + + You can read this path in a custom deployment tool for example. + ''; + }; + };