feat(infra): Rework nixpkgs version management #84
7 changed files with 38 additions and 21 deletions
32
hive.nix
32
hive.nix
|
@ -16,23 +16,34 @@ let
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mkPatchedNixpkgs =
|
nixpkgs' = import ./meta/nixpkgs.nix;
|
||||||
version:
|
# All supported nixpkgs versions, instanciated
|
||||||
|
nixpkgs = lib.mapSingleFuse mkNixpkgs nixpkgs'.supported;
|
||||||
|
|
||||||
|
# Get the configured nixos version for the node,
|
||||||
|
# defaulting to the one defined in meta/nixpkgs
|
||||||
|
version = node: nodes'.${node}.nixpkgs or nixpkgs'.default;
|
||||||
|
|
||||||
|
# Builds a patched version of nixpkgs, only as the source
|
||||||
|
mkNixpkgs' =
|
||||||
|
v:
|
||||||
|
let
|
||||||
|
version = "nixos-${v}";
|
||||||
|
in
|
||||||
patch.mkNixpkgsSrc {
|
patch.mkNixpkgsSrc {
|
||||||
src = sources.${version};
|
src = sources.${version};
|
||||||
inherit version;
|
inherit version;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkNixpkgs = version: import (mkPatchedNixpkgs version) { };
|
# Instanciates the required nixpkgs version
|
||||||
|
mkNixpkgs = version: import (mkNixpkgs' version) { };
|
||||||
mkNixpkgsVersion = node: "nixos-${nodes'.${node}.nixpkgs or (import ./meta/nixpkgs.nix)}";
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Function to create arguments based on the node
|
# Function to create arguments based on the node
|
||||||
#
|
#
|
||||||
mkArgs = node: rec {
|
mkArgs = node: rec {
|
||||||
lib = import sources.nix-lib {
|
lib = import sources.nix-lib {
|
||||||
inherit (mkNixpkgs (mkNixpkgsVersion node)) lib;
|
inherit (nixpkgs.${version node}) lib;
|
||||||
|
|
||||||
keysRoot = ./keys;
|
keysRoot = ./keys;
|
||||||
};
|
};
|
||||||
|
@ -40,14 +51,13 @@ let
|
||||||
meta = (import ./meta) lib;
|
meta = (import ./meta) lib;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
# nodes = builtins.attrNames metadata.nodes;
|
|
||||||
{
|
{
|
||||||
meta = {
|
meta = {
|
||||||
nodeNixpkgs = lib.mapSingleFuse (n: mkNixpkgs (mkNixpkgsVersion n)) nodes;
|
nodeNixpkgs = lib.mapSingleFuse (n: nixpkgs.${version n}) nodes;
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit sources;
|
inherit nixpkgs sources;
|
||||||
inherit mkNixpkgs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes;
|
nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes;
|
||||||
|
@ -66,7 +76,7 @@ in
|
||||||
inherit (meta.nodes.${name}) deployment;
|
inherit (meta.nodes.${name}) deployment;
|
||||||
|
|
||||||
# Set NIX_PATH to the patched version of nixpkgs
|
# Set NIX_PATH to the patched version of nixpkgs
|
||||||
nix.nixPath = [ "nixpkgs=${mkPatchedNixpkgs (mkNixpkgsVersion name)}" ];
|
nix.nixPath = [ "nixpkgs=${mkNixpkgs' (version name)}" ];
|
||||||
nix.optimise.automatic = true;
|
nix.optimise.automatic = true;
|
||||||
|
|
||||||
# Allow unfree packages
|
# Allow unfree packages
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, sources, ... }:
|
{ config, nixpkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
domain = "sso.dgnum.eu";
|
domain = "sso.dgnum.eu";
|
||||||
|
@ -18,7 +18,7 @@ in
|
||||||
services.kanidm = {
|
services.kanidm = {
|
||||||
enableServer = true;
|
enableServer = true;
|
||||||
|
|
||||||
package = (import sources.nixos-unstable { }).kanidm;
|
package = nixpkgs.unstable.kanidm;
|
||||||
|
|
||||||
serverSettings = {
|
serverSettings = {
|
||||||
inherit domain;
|
inherit domain;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
sources,
|
nixpkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ in
|
||||||
pkgs.colmena
|
pkgs.colmena
|
||||||
pkgs.npins
|
pkgs.npins
|
||||||
pkgs.tea
|
pkgs.tea
|
||||||
(import sources.nixpkgs { }).nixfmt-rfc-style
|
nixpkgs.unstable.nixfmt-rfc-style
|
||||||
];
|
];
|
||||||
|
|
||||||
containerOptions = [ "--cpus=4" ];
|
containerOptions = [ "--cpus=4" ];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
mkNixpkgs,
|
nixpkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ in
|
||||||
services = {
|
services = {
|
||||||
netbox = {
|
netbox = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = (mkNixpkgs "nixos-unstable").netbox_3_7;
|
package = nixpkgs.unstable.netbox_3_7;
|
||||||
secretKeyFile = "/dev/null";
|
secretKeyFile = "/dev/null";
|
||||||
listenAddress = "127.0.0.1";
|
listenAddress = "127.0.0.1";
|
||||||
plugins = p: [ p.netbox-qrcode ];
|
plugins = p: [ p.netbox-qrcode ];
|
||||||
|
|
|
@ -1,2 +1,10 @@
|
||||||
# Default version of nixpkgs to use
|
{
|
||||||
"23.11"
|
# Default version of nixpkgs to use
|
||||||
|
default = "23.11";
|
||||||
|
|
||||||
|
# Supported nixpkgs versions
|
||||||
|
supported = [
|
||||||
|
"unstable"
|
||||||
|
"23.11"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ in
|
||||||
|
|
||||||
nixpkgs = mkOption {
|
nixpkgs = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = import ./nixpkgs.nix;
|
inherit (import ./nixpkgs.nix) default;
|
||||||
description = ''
|
description = ''
|
||||||
Version of nixpkgs to use.
|
Version of nixpkgs to use.
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (config.deployment) tags;
|
|
||||||
inherit (config.networking) hostName domain;
|
inherit (config.networking) hostName domain;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue