Tom Hubrecht
62d4ae298e
All checks were successful
build configuration / build_vault01 (pull_request) Successful in 1m2s
build configuration / build_web02 (pull_request) Successful in 1m3s
build configuration / build_storage01 (pull_request) Successful in 1m6s
build configuration / build_compute01 (pull_request) Successful in 1m9s
build configuration / build_rescue01 (pull_request) Successful in 50s
build configuration / build_web01 (pull_request) Successful in 1m27s
build configuration / build_vault01 (push) Successful in 1m1s
build configuration / build_storage01 (push) Successful in 1m5s
build configuration / build_web02 (push) Successful in 1m5s
build configuration / build_compute01 (push) Successful in 1m11s
lint / check (push) Successful in 21s
build configuration / build_web01 (push) Successful in 1m26s
build configuration / build_rescue01 (push) Successful in 46s
78 lines
1.8 KiB
Nix
78 lines
1.8 KiB
Nix
let
|
|
sources = import ./npins;
|
|
|
|
lib = import (sources.nix-lib + "/src/trivial.nix");
|
|
|
|
patch = import sources.nix-patches { patchFile = ./patches; };
|
|
|
|
nodes' = import ./meta/nodes.nix;
|
|
nodes = builtins.attrNames nodes';
|
|
|
|
mkNode = node: {
|
|
# Import the base configuration for each node
|
|
imports = builtins.map (lib.mkRel (./machines/${node})) [
|
|
"_configuration.nix"
|
|
"_hardware-configuration.nix"
|
|
];
|
|
};
|
|
|
|
mkNixpkgs =
|
|
node:
|
|
patch.mkNixpkgsSrc rec {
|
|
src = sources.${version};
|
|
version = "nixos-${nodes'.${node}.nixpkgs or (import ./meta/nixpkgs.nix)}";
|
|
};
|
|
|
|
mkNixpkgs' = node: import (mkNixpkgs node) { };
|
|
|
|
###
|
|
# Function to create arguments based on the node
|
|
#
|
|
mkArgs = node: rec {
|
|
lib = import sources.nix-lib {
|
|
inherit (mkNixpkgs' node) lib;
|
|
|
|
keysRoot = ./keys;
|
|
};
|
|
|
|
meta = (import ./meta) lib;
|
|
};
|
|
in
|
|
# nodes = builtins.attrNames metadata.nodes;
|
|
{
|
|
meta = {
|
|
nodeNixpkgs = lib.mapSingleFuse mkNixpkgs' nodes;
|
|
|
|
specialArgs = {
|
|
inherit sources;
|
|
};
|
|
|
|
nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes;
|
|
};
|
|
|
|
defaults =
|
|
{ meta, name, ... }:
|
|
{
|
|
# Import the default modules
|
|
imports = [ ./modules ];
|
|
|
|
# Include default secrets
|
|
age-secrets.sources = [ (./machines + "/${name}/secrets") ];
|
|
|
|
# Deployment config is specified in meta.nodes.${node}.deployment
|
|
inherit (meta.nodes.${name}) deployment;
|
|
|
|
# Set NIX_PATH to the patched version of nixpkgs
|
|
nix.nixPath = [ "nixpkgs=${mkNixpkgs name}" ];
|
|
nix.optimise.automatic = true;
|
|
|
|
# Allow unfree packages
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
# Use the stateVersion declared in the metadata
|
|
system = {
|
|
inherit (meta.nodes.${name}) stateVersion;
|
|
};
|
|
};
|
|
}
|
|
// (lib.mapSingleFuse mkNode nodes)
|