feat(meta): Remove default values for nixpkgs version

They are considered harmful, and it simplifies the code.
This commit is contained in:
Tom Hubrecht 2024-12-08 11:52:26 +01:00
parent 1821104e8e
commit eb5b8740a8
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc
4 changed files with 25 additions and 34 deletions

View file

@ -23,17 +23,19 @@ let
nixpkgs' = import ./meta/nixpkgs.nix; nixpkgs' = import ./meta/nixpkgs.nix;
# All supported nixpkgs versions × systems, instanciated # All supported nixpkgs versions × systems, instanciated
nixpkgs = nix-lib.mapSingleFuse ( nixpkgs = nix-lib.mapSingleFuse (
s: nix-lib.mapSingleFuse (mkSystemNixpkgs s) nixpkgs'.versions.supported s: nix-lib.mapSingleFuse (mkSystemNixpkgs s) nixpkgs'.versions
) nixpkgs'.systems.supported; ) nixpkgs'.systems;
# Get the configured nixos version for the node, # Get the configured nixos version for the node,
# defaulting to the one defined in meta/nixpkgs # defaulting to the one defined in meta/nixpkgs
version = node: nodes'.${node}.nixpkgs.version or nixpkgs'.versions.default; version = node: nodes'.${node}.nixpkgs.version;
systemType = system =
node: node:
nodes'.${node}.nixpkgs.system nodes'.${node}.nixpkgs.system
or (warn "${node}: Not specifying the `deployment.systemType` is deprecated!" "nixos"); 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 # Builds a patched version of nixpkgs, only as the source
mkNixpkgs' = mkNixpkgs' =
v: v:
@ -73,11 +75,11 @@ let
# Function to create arguments based on the node # Function to create arguments based on the node
# #
mkArgs = node: rec { mkArgs = node: rec {
lib = nixpkgs.${systemType node}.${version node}.lib // { lib = nodePkgs.lib // {
extra = nix-lib; extra = nix-lib;
}; };
sourcePkgs = nixpkgs.${systemType node}.${version node}; nodePkgs = nodePkgs node;
meta = (import ./meta) lib; meta = (import ./meta) lib;
nodeMeta = meta.nodes.${node}; nodeMeta = meta.nodes.${node};
@ -86,7 +88,7 @@ in
{ {
meta = { meta = {
nodeNixpkgs = nix-lib.mapSingleFuse (n: nixpkgs.${systemType n}.${version n}) nodes; nodeNixpkgs = nix-lib.mapSingleFuse nodePkgs nodes;
specialArgs = { specialArgs = {
inherit nixpkgs sources; inherit nixpkgs sources;
@ -99,7 +101,7 @@ in
registry = { registry = {
nixos = { 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 = defaults =
{ name, nodeMeta, ... }: { name, nodeMeta, ... }:
{ {

View file

@ -32,7 +32,7 @@ TODO.
# Nixpkgs # 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 ## 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 - `deployment`, the colmena deployment option
- `stateVersion`, the state version of the node - `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 - `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` - `adminGroups`, a list of groups whose members will be added to `admins`
- `site`, the physical location of the node - `site`, the physical location of the node

View file

@ -1,25 +1,15 @@
{ {
versions = { versions = [
# Default version of nixpkgs to use
default = "24.05";
# Supported nixpkgs versions # Supported nixpkgs versions
supported = [
"unstable" "unstable"
"23.11" "23.11"
"24.05" "24.05"
"24.11" "24.11"
]; ];
};
systems = {
# Default system for our deployments
default = "nixos";
systems = [
# Supported system types # Supported system types
supported = [
"zyxel-nwa50ax" "zyxel-nwa50ax"
"nixos" "nixos"
]; ];
};
} }

View file

@ -141,16 +141,15 @@ in
nixpkgs = { nixpkgs = {
version = mkOption { version = mkOption {
type = enum nixpkgs.versions.supported; type = enum nixpkgs.versions;
inherit (nixpkgs.versions) default;
description = '' description = ''
Version of nixpkgs to use. Version of nixpkgs to use.
''; '';
example = "unstable";
}; };
system = mkOption { system = mkOption {
type = enum nixpkgs.systems.supported; type = enum nixpkgs.systems;
inherit (nixpkgs.systems) default;
description = '' description = ''
Type of system for this node, will impact how it is evaluated and deployed. Type of system for this node, will impact how it is evaluated and deployed.
''; '';