mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
Work in progress refactor.
This commit is contained in:
parent
ad1faf2f24
commit
9ece41ee80
14 changed files with 130 additions and 76 deletions
|
|
@ -1,5 +1,12 @@
|
|||
{ pkgs, hostsDir ? ../config/hosts, privateHostsDir ? ../config/private/hosts
|
||||
, commonImports ? [ ../config/common ../modules ], pkgsPath ? ../pkgs }:
|
||||
{
|
||||
pkgs,
|
||||
hostsDir ? ../config/hosts,
|
||||
privateHostsDir ? ../config/private/hosts,
|
||||
commonImports ? [ ../config/common ../modules/nixos ],
|
||||
pkgsPath ? ../pkgs,
|
||||
sources ? {},
|
||||
witch ? {}
|
||||
}:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
|
|
@ -7,22 +14,37 @@ rec {
|
|||
hostNames = attrNames
|
||||
(filterAttrs (name: type: type == "directory") (builtins.readDir hostsDir));
|
||||
|
||||
hostConfig = hostName:
|
||||
{ config, ... }: {
|
||||
_module.args = { inherit hosts profiles; };
|
||||
imports = [
|
||||
(import (hostsDir + "/${hostName}/configuration.nix"))
|
||||
(import (privateHostsDir + "/${hostName}/configuration.nix"))
|
||||
../modules/deploy
|
||||
] ++ commonImports;
|
||||
networking = { inherit hostName; };
|
||||
nixpkgs.pkgs = import pkgsPath { inherit (config.nixpkgs) config; };
|
||||
hostConfig = hostName: { config, ... }: {
|
||||
_module.args = {
|
||||
inherit hosts profiles;
|
||||
};
|
||||
imports = [
|
||||
(import (hostsDir + "/${hostName}/configuration.nix"))
|
||||
(import (privateHostsDir + "/${hostName}/configuration.nix"))
|
||||
# urgh, yes, we still need to manually import the deploy module for now
|
||||
# at least if i want to keep my thing reusable.
|
||||
../modules/nixos/deploy
|
||||
] ++ commonImports;
|
||||
networking = {
|
||||
inherit hostName;
|
||||
};
|
||||
nixpkgs.pkgs = import pkgsPath { inherit (config.nixpkgs) config; };
|
||||
};
|
||||
|
||||
hosts = listToAttrs (map (hostName:
|
||||
nameValuePair hostName
|
||||
(import (pkgs.path + "/nixos") { configuration = hostConfig hostName; }))
|
||||
hostNames);
|
||||
|
||||
hosts = listToAttrs (
|
||||
map (
|
||||
hostName: nameValuePair hostName (
|
||||
import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||
modules = [
|
||||
(hostConfig hostName)
|
||||
(if sources ? home-manager then sources.home-manager + "/nixos" else {})
|
||||
];
|
||||
specialArgs = { inherit sources witch; };
|
||||
}
|
||||
)
|
||||
) hostNames
|
||||
);
|
||||
|
||||
profileNames = unique (concatLists
|
||||
(mapAttrsToList (name: host: host.config.meta.deploy.profiles) hosts));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue