2023-05-16 23:50:06 +02:00
|
|
|
let
|
|
|
|
sources = import ./npins;
|
2023-05-22 15:08:33 +02:00
|
|
|
metadata = import ./meta;
|
|
|
|
|
2023-07-23 22:16:59 +02:00
|
|
|
lib = import (sources.nix-lib + "/trivial.nix");
|
2023-05-22 15:08:33 +02:00
|
|
|
|
|
|
|
mkNode = node: { name, nodes, ... }: {
|
|
|
|
# Import the base configuration for each node
|
|
|
|
imports = builtins.map (lib.mkRel ./machines/${node}) [
|
|
|
|
"_configuration.nix"
|
|
|
|
"_hardware-configuration.nix"
|
|
|
|
];
|
|
|
|
|
2023-06-30 18:38:53 +02:00
|
|
|
# Include default secrets
|
|
|
|
dgn-secrets.sources = [ ./machines/${node}/secrets ];
|
|
|
|
|
2023-05-22 15:08:33 +02:00
|
|
|
# Deployment config is specified in meta.nodes.${node}.deployment
|
|
|
|
inherit (metadata.nodes.${node}) deployment;
|
2023-07-20 12:32:31 +02:00
|
|
|
|
|
|
|
# Set NIX_PATH to the patched version of nixpkgs
|
|
|
|
nix.nixPath = [ "nixpkgs=${mkNixpkgs node}" ];
|
2023-07-23 21:46:20 +02:00
|
|
|
|
|
|
|
# Use the stateVersion declared in the metadata
|
|
|
|
system = { inherit (metadata.nodes.${node}) stateVersion; };
|
2023-05-22 15:08:33 +02:00
|
|
|
};
|
|
|
|
|
2023-07-02 17:16:17 +02:00
|
|
|
mkNixpkgs = node:
|
|
|
|
let version = "nixos-${metadata.nodes.${node}.nixpkgs}"; in
|
|
|
|
(import sources.${version} { }).applyPatches {
|
|
|
|
name = "${version}-patched";
|
|
|
|
src = sources.${version};
|
|
|
|
patches = (import ./nix-patches).${version} or [ ];
|
|
|
|
};
|
|
|
|
|
|
|
|
mkNixpkgs' = node: import (mkNixpkgs node) { };
|
2023-05-22 15:08:33 +02:00
|
|
|
|
|
|
|
mkArgs = node: {
|
2023-07-24 09:50:17 +02:00
|
|
|
dgn-lib = import sources.nix-lib { inherit ((mkNixpkgs' node)) lib; keysRoot = ./keys; metaRoot = ./meta; };
|
2023-05-22 15:08:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nodes = builtins.attrNames metadata.nodes;
|
2023-05-16 23:50:06 +02:00
|
|
|
in
|
2023-05-22 15:08:33 +02:00
|
|
|
|
2023-05-16 23:50:06 +02:00
|
|
|
{
|
|
|
|
meta = {
|
2023-07-02 17:16:17 +02:00
|
|
|
nodeNixpkgs = lib.mapSingleFuse mkNixpkgs' nodes;
|
2023-05-22 15:08:33 +02:00
|
|
|
|
2023-06-30 18:38:53 +02:00
|
|
|
specialArgs = { inherit sources; meta = metadata; };
|
2023-05-16 23:50:06 +02:00
|
|
|
|
2023-05-22 15:08:33 +02:00
|
|
|
nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes;
|
2023-05-16 23:50:06 +02:00
|
|
|
};
|
|
|
|
|
2023-05-22 15:08:33 +02:00
|
|
|
defaults = { ... }: {
|
|
|
|
# Import the default modules
|
|
|
|
imports = [ ./modules ];
|
2023-05-16 23:50:06 +02:00
|
|
|
};
|
2023-05-22 15:08:33 +02:00
|
|
|
} // (lib.mapSingleFuse mkNode nodes)
|