1
0
Fork 0

Replace lib/hosts.nix with an injected special argument containing the nix flake

This commit is contained in:
clerie 2023-02-06 12:20:59 +01:00
parent 8748015acc
commit 9ee8585716
3 changed files with 10 additions and 28 deletions

View File

@ -19,6 +19,14 @@
generateNixosSystem = name: nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ ... }: {
/*
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._nixfiles = self;
})
./configuration/common
({ ... }: {
nixpkgs.overlays = [

View File

@ -1,9 +1,9 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, _nixfiles, ... }:
with lib;
let
hosts = (import ../../lib/hosts.nix { inherit pkgs; }).hosts;
hosts = _nixfiles.nixosConfigurations;
monitoringHosts = filterAttrs (name: host:
attrByPath ["clerie" "monitoring" "enable"] false host.config)

View File

@ -1,26 +0,0 @@
{ pkgs ? import ../pkgs {} }:
with pkgs.lib;
rec {
hostsDir = ../hosts;
hostNames = attrNames (
filterAttrs (
name: type: type == "directory"
) (
builtins.readDir hostsDir
)
);
hosts = listToAttrs (
map (
hostName: nameValuePair hostName (
import (pkgs.path + "/nixos") {
configuration = import (hostsDir + "/${hostName}/configuration.nix");
system = "x86_64-linux";
}
)
) hostNames
);
}