mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-10 14:50:40 +02:00
feat: introduce shared global variable aggregator with recursive redistribution
This commit is contained in:
parent
cceae6c63c
commit
cbd22db8c0
4 changed files with 67 additions and 1 deletions
19
flake.nix
19
flake.nix
|
@ -141,6 +141,25 @@
|
|||
# Add a shorthand to easily target toplevel derivations
|
||||
"@" = mapAttrs (_: v: v.config.system.build.toplevel) self.nodes;
|
||||
|
||||
globals = let
|
||||
globalsSystem = nixpkgs.lib.evalModules {
|
||||
prefix = ["globals"];
|
||||
modules = [
|
||||
./modules/globals.nix
|
||||
({lib, ...}: {
|
||||
globals = lib.mkMerge (
|
||||
lib.concatLists (lib.flip lib.mapAttrsToList self.nodes (
|
||||
name: cfg:
|
||||
builtins.addErrorContext "while aggregating globals from nixosConfigurations.${name} into flake-level globals:"
|
||||
cfg.config._globalsDefs
|
||||
))
|
||||
);
|
||||
})
|
||||
];
|
||||
};
|
||||
in
|
||||
globalsSystem.config.globals;
|
||||
|
||||
# For each true NixOS system, we want to expose an installer package that
|
||||
# can be used to do the initial setup on the node from a live environment.
|
||||
# We use the minimal sibling configuration to reduce the amount of stuff
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
./backups.nix
|
||||
./deterministic-ids.nix
|
||||
./distributed-config.nix
|
||||
./globals.nix
|
||||
./kanidm.nix
|
||||
./meta.nix
|
||||
./netbird-client.nix
|
||||
|
|
46
modules/globals.nix
Normal file
46
modules/globals.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
in {
|
||||
options = {
|
||||
globals = mkOption {
|
||||
default = {};
|
||||
type = types.submodule {
|
||||
options = {
|
||||
services = mkOption {
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
domain = mkOption {
|
||||
type = types.str;
|
||||
description = "";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
#telegrafChecks = mkOption {
|
||||
# type = types.attrsOf (types.submodule {
|
||||
# options = {
|
||||
# domain = mkOption {};
|
||||
# };
|
||||
# });
|
||||
#};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_globalsDefs = mkOption {
|
||||
type = types.unspecified;
|
||||
default = options.globals.definitions;
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -19,7 +19,7 @@ inputs: let
|
|||
specialArgs = {
|
||||
# Use the correct instance lib that has our overlays
|
||||
inherit (pkgs) lib;
|
||||
inherit (self) nodes;
|
||||
inherit (self) nodes globals;
|
||||
inherit inputs minimal;
|
||||
};
|
||||
modules = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue