From eb5b8740a898d67bbdeed6171c090b5075f52ffc Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Sun, 8 Dec 2024 11:52:26 +0100 Subject: [PATCH] feat(meta): Remove default values for nixpkgs version They are considered harmful, and it simplifies the code. --- hive.nix | 18 ++++++++++-------- meta/README.md | 4 ++-- meta/nixpkgs.nix | 30 ++++++++++-------------------- meta/options.nix | 7 +++---- 4 files changed, 25 insertions(+), 34 deletions(-) diff --git a/hive.nix b/hive.nix index 6567a24..ee4f749 100644 --- a/hive.nix +++ b/hive.nix @@ -23,17 +23,19 @@ let nixpkgs' = import ./meta/nixpkgs.nix; # All supported nixpkgs versions × systems, instanciated nixpkgs = nix-lib.mapSingleFuse ( - s: nix-lib.mapSingleFuse (mkSystemNixpkgs s) nixpkgs'.versions.supported - ) nixpkgs'.systems.supported; + s: nix-lib.mapSingleFuse (mkSystemNixpkgs s) nixpkgs'.versions + ) nixpkgs'.systems; # Get the configured nixos version for the node, # defaulting to the one defined in meta/nixpkgs - version = node: nodes'.${node}.nixpkgs.version or nixpkgs'.versions.default; - systemType = + version = node: nodes'.${node}.nixpkgs.version; + system = node: nodes'.${node}.nixpkgs.system or (warn "${node}: Not specifying the `deployment.systemType` is deprecated!" "nixos"); + nodePkgs = node: nixpkgs.${system node}.${version node}; + # Builds a patched version of nixpkgs, only as the source mkNixpkgs' = v: @@ -73,11 +75,11 @@ let # Function to create arguments based on the node # mkArgs = node: rec { - lib = nixpkgs.${systemType node}.${version node}.lib // { + lib = nodePkgs.lib // { extra = nix-lib; }; - sourcePkgs = nixpkgs.${systemType node}.${version node}; + nodePkgs = nodePkgs node; meta = (import ./meta) lib; nodeMeta = meta.nodes.${node}; @@ -86,7 +88,7 @@ in { meta = { - nodeNixpkgs = nix-lib.mapSingleFuse (n: nixpkgs.${systemType n}.${version n}) nodes; + nodeNixpkgs = nix-lib.mapSingleFuse nodePkgs nodes; specialArgs = { inherit nixpkgs sources; @@ -99,7 +101,7 @@ in registry = { nixos = { - evalConfig = args: import "${args.specialArgs.sourcePkgs.path}/nixos/lib/eval-config.nix" args; + evalConfig = args: import "${args.specialArgs.nodePkgs.path}/nixos/lib/eval-config.nix" args; defaults = { name, nodeMeta, ... }: { diff --git a/meta/README.md b/meta/README.md index 5446d5a..19e21d0 100644 --- a/meta/README.md +++ b/meta/README.md @@ -32,7 +32,7 @@ TODO. # Nixpkgs -Machines can use different versions of NixOS, the supported and default ones are specified here. +Machines can use different versions of NixOS, the supported ones are specified here. ## How to add a new version @@ -55,7 +55,7 @@ The nodes are declared statically, several options can be configured: - `deployment`, the colmena deployment option - `stateVersion`, the state version of the node -- `nixpkgs`, the version of NixOS to use +- `nixpkgs`, the version and sytem of NixOS to use - `admins`, the list of administrators specific to this node, they will be given root access - `adminGroups`, a list of groups whose members will be added to `admins` - `site`, the physical location of the node diff --git a/meta/nixpkgs.nix b/meta/nixpkgs.nix index 27728d7..5b4cafe 100644 --- a/meta/nixpkgs.nix +++ b/meta/nixpkgs.nix @@ -1,25 +1,15 @@ { - versions = { - # Default version of nixpkgs to use - default = "24.05"; - + versions = [ # Supported nixpkgs versions - supported = [ - "unstable" - "23.11" - "24.05" - "24.11" - ]; - }; - - systems = { - # Default system for our deployments - default = "nixos"; + "unstable" + "23.11" + "24.05" + "24.11" + ]; + systems = [ # Supported system types - supported = [ - "zyxel-nwa50ax" - "nixos" - ]; - }; + "zyxel-nwa50ax" + "nixos" + ]; } diff --git a/meta/options.nix b/meta/options.nix index d646c24..0926f89 100644 --- a/meta/options.nix +++ b/meta/options.nix @@ -141,16 +141,15 @@ in nixpkgs = { version = mkOption { - type = enum nixpkgs.versions.supported; - inherit (nixpkgs.versions) default; + type = enum nixpkgs.versions; description = '' Version of nixpkgs to use. ''; + example = "unstable"; }; system = mkOption { - type = enum nixpkgs.systems.supported; - inherit (nixpkgs.systems) default; + type = enum nixpkgs.systems; description = '' Type of system for this node, will impact how it is evaluated and deployed. '';