1
0

lib/flake-helper.nix,flake/nixosConfigurations.nix: Move functions to flake directory

This commit is contained in:
2024-05-13 17:39:54 +02:00
parent 2a3281a7c4
commit d55dc35882
3 changed files with 9 additions and 8 deletions

View File

@@ -7,10 +7,6 @@ let
} // inputs);
lib = {
flake-helper = callLibs ./flake-helper.nix;
inherit ("flake-helper")
generateNixosSystem
mapToNixosConfigurations;
clerie-monitoring-ids = callLibs ./clerie-monitoring-ids.nix;
};

View File

@@ -1,60 +0,0 @@
{ self, nixpkgs, fernglas, fieldpoc, nixos-exporter, solid-xmpp-alarm, sops-nix, ... }@inputs:
rec {
generateNixosSystem = {
name,
system ? "x86_64-linux",
group ? null,
modules ? [],
}: let
localNixpkgs = nixpkgs.lib.attrByPath [ "nixpkgs-${name}" ] nixpkgs inputs;
in localNixpkgs.lib.nixosSystem {
system = system;
modules = modules ++ [
self.nixosModules.nixfilesInputs
self.nixosModules.clerie
({ config, lib, ... }: {
# Apply overlays
nixpkgs.overlays = [
self.overlays.nixfilesInputs
self.overlays.clerie
];
/*
Make the contents of the flake availiable to modules.
Useful for having the monitoring server scraping the
target config from all other servers automatically.
*/
_module.args = {
inputs = inputs;
_nixfiles = self;
};
# Expose host group to monitoring
clerie.monitoring = nixpkgs.lib.attrsets.optionalAttrs (group != null) { serviceLevel = group; };
# Automatically load secrets from sops file for host
sops.defaultSopsFile = ../hosts + "/${name}/secrets.json";
sops.secrets = let
secretFile = config.sops.defaultSopsFile;
secretNames = builtins.filter (name: name != "sops") (builtins.attrNames (builtins.fromJSON (builtins.readFile secretFile)));
secrets = if builtins.pathExists secretFile then
lib.listToAttrs (builtins.map (name: lib.nameValuePair name {}) secretNames)
else
{};
in
secrets;
})
# Config to be applied to every host
../configuration/common
../users/clerie
# Host specific config
(../hosts + "/${name}/configuration.nix")
];
};
mapToNixosConfigurations = hosts: builtins.mapAttrs (name: host: generateNixosSystem host) hosts;
}