From fbaacf54ede6db204a89683de604f819c04ffc55 Mon Sep 17 00:00:00 2001 From: kat witch Date: Mon, 9 Aug 2021 02:18:12 +0100 Subject: [PATCH] ...depot, without readtree --- config/hosts/athame/meta.nix | 4 ++-- config/hosts/athame/nixos.nix | 4 ++-- config/hosts/beltane/meta.nix | 4 ++-- config/hosts/beltane/nixos.nix | 4 ++-- config/hosts/ostara/meta.nix | 4 ++-- config/hosts/ostara/nixos.nix | 4 ++-- config/hosts/samhain/meta.nix | 4 ++-- config/hosts/samhain/nixos.nix | 4 ++-- config/hosts/yule/meta.nix | 4 ++-- config/hosts/yule/nixos.nix | 4 ++-- config/modules/meta/network.nix | 4 ++-- config/profiles/base/default.nix | 4 ++-- config/targets/personal/default.nix | 4 ++-- default.nix | 31 +++++++++++------------------ pkgs/lib/domain-merge.nix | 5 ++++- 15 files changed, 42 insertions(+), 46 deletions(-) diff --git a/config/hosts/athame/meta.nix b/config/hosts/athame/meta.nix index 0e9d43a9..23e552bb 100644 --- a/config/hosts/athame/meta.nix +++ b/config/hosts/athame/meta.nix @@ -1,4 +1,4 @@ -{ lib, config, profiles, ... }: with lib; { +{ depot, lib, config, ... }: with lib; { config = { deploy.targets.infra = { tf = { @@ -15,7 +15,7 @@ config = { network.nodes.athame = { imports = lib.hostImport { hostName = "athame"; - inherit profiles; + inherit (depot) profiles; }; networking = { hostName = "athame"; diff --git a/config/hosts/athame/nixos.nix b/config/hosts/athame/nixos.nix index dae0c426..fce6c089 100644 --- a/config/hosts/athame/nixos.nix +++ b/config/hosts/athame/nixos.nix @@ -1,11 +1,11 @@ -{ config, users, lib, pkgs, profiles, services, ... }: +{ depot, config, lib, pkgs, ... }: with lib; { # Imports - imports = [ + imports = with depot; [ profiles.hardware.hcloud-imperative users.kat.server services.fail2ban diff --git a/config/hosts/beltane/meta.nix b/config/hosts/beltane/meta.nix index c3e90919..b4d40dfb 100644 --- a/config/hosts/beltane/meta.nix +++ b/config/hosts/beltane/meta.nix @@ -1,4 +1,4 @@ -{ lib, config, profiles, ... }: with lib; { +{ lib, config, depot, ... }: with lib; { config = { deploy.targets.beltane = { tf = { @@ -15,7 +15,7 @@ network.nodes.beltane = { imports = lib.hostImport { hostName = "beltane"; - inherit profiles; + inherit (depot) profiles; }; networking = { hostName = "beltane"; diff --git a/config/hosts/beltane/nixos.nix b/config/hosts/beltane/nixos.nix index 3832285f..1da1bde4 100644 --- a/config/hosts/beltane/nixos.nix +++ b/config/hosts/beltane/nixos.nix @@ -1,11 +1,11 @@ -{ config, lib, pkgs, profiles, services, users, tf, ... }: +{ depot, tf, config, pkgs, lib, ... }: with lib; { # Imports - imports = [ + imports = with depot; [ profiles.hardware.rm-310 profiles.gui users.kat.guiFull diff --git a/config/hosts/ostara/meta.nix b/config/hosts/ostara/meta.nix index bd2f2da4..6a391f52 100644 --- a/config/hosts/ostara/meta.nix +++ b/config/hosts/ostara/meta.nix @@ -1,4 +1,4 @@ -{ lib, config, profiles, ... }: with lib; { +{ lib, config, depot, ... }: with lib; { config = { deploy.targets.ostara = { tf = { @@ -15,7 +15,7 @@ network.nodes.ostara = { imports = lib.hostImport { hostName = "ostara"; - inherit profiles; + inherit (depot) profiles; }; networking = { hostName = "ostara"; diff --git a/config/hosts/ostara/nixos.nix b/config/hosts/ostara/nixos.nix index 25951c19..27f8c4f5 100644 --- a/config/hosts/ostara/nixos.nix +++ b/config/hosts/ostara/nixos.nix @@ -1,11 +1,11 @@ -{ lib, config, users, pkgs, profiles, services, ... }: +{ depot, config, pkgs, lib, ... }: with lib; { # Imports - imports = [ + imports = with depot; [ profiles.hardware.eeepc-1015pem profiles.laptop services.kattv diff --git a/config/hosts/samhain/meta.nix b/config/hosts/samhain/meta.nix index 22fdf83e..501c7dff 100644 --- a/config/hosts/samhain/meta.nix +++ b/config/hosts/samhain/meta.nix @@ -1,4 +1,4 @@ -{ lib, config, profiles, ... }: with lib; { +{ lib, config, depot, ... }: with lib; { config = { deploy.targets.personal = { tf = { @@ -15,7 +15,7 @@ network.nodes.samhain = { imports = lib.hostImport { hostName = "samhain"; - inherit profiles; + inherit (depot) profiles; }; networking = { hostName = "samhain"; diff --git a/config/hosts/samhain/nixos.nix b/config/hosts/samhain/nixos.nix index 800b7401..9d5a07e3 100644 --- a/config/hosts/samhain/nixos.nix +++ b/config/hosts/samhain/nixos.nix @@ -1,4 +1,4 @@ -{ tf, config, users, pkgs, lib, profiles, sources, services, ... }: +{ depot, tf, config, pkgs, lib, sources, ... }: with lib; @@ -9,7 +9,7 @@ let in { # Imports - imports = [ + imports = with depot; [ profiles.hardware.ms-7b86 profiles.gui profiles.vfio diff --git a/config/hosts/yule/meta.nix b/config/hosts/yule/meta.nix index 6fc2b6d9..98f361f8 100644 --- a/config/hosts/yule/meta.nix +++ b/config/hosts/yule/meta.nix @@ -1,4 +1,4 @@ -{ lib, config, profiles, ... }: with lib; { +{ lib, config, depot, ... }: with lib; { config = { deploy.targets.personal = { tf = { @@ -15,7 +15,7 @@ network.nodes.yule = { imports = lib.hostImport { hostName = "yule"; - inherit profiles; + inherit (depot) profiles; }; networking = { hostName = "yule"; diff --git a/config/hosts/yule/nixos.nix b/config/hosts/yule/nixos.nix index f362a526..be874285 100644 --- a/config/hosts/yule/nixos.nix +++ b/config/hosts/yule/nixos.nix @@ -1,11 +1,11 @@ -{ config, users, pkgs, lib, profiles, services, ... }: +{ depot, config, pkgs, lib, ... }: with lib; { # Imports - imports = [ + imports = with depot; [ profiles.hardware.v330-14arr profiles.gui profiles.laptop diff --git a/config/modules/meta/network.nix b/config/modules/meta/network.nix index 2379196a..7b47abcb 100644 --- a/config/modules/meta/network.nix +++ b/config/modules/meta/network.nix @@ -1,4 +1,4 @@ -{ pkgs, sources, users, profiles, services, lib, config, ... }: +{ pkgs, sources, depot, lib, config, ... }: /* This module: @@ -59,7 +59,7 @@ with lib; ]; specialArgs = { inherit (config.network) nodes; - inherit sources profiles users services; + inherit sources depot; meta = config; }; }; diff --git a/config/profiles/base/default.nix b/config/profiles/base/default.nix index fe4c074c..b4a3a98b 100644 --- a/config/profiles/base/default.nix +++ b/config/profiles/base/default.nix @@ -1,7 +1,7 @@ -{ config, users, lib, pkgs, ... }: +{ config, depot, lib, pkgs, ... }: { - imports = [ + imports = with depot; [ users.kat.base # users.kairi.base TODO users.arc diff --git a/config/targets/personal/default.nix b/config/targets/personal/default.nix index 441c1768..e36c5a11 100644 --- a/config/targets/personal/default.nix +++ b/config/targets/personal/default.nix @@ -6,13 +6,13 @@ tf = { config, ... }: { dns.records.ygg_grimoire = { tld = config.kw.dns.tld; - domain = "grimoire.${config.kw.dns.ygg_prefix}"; + domain = "grimoire.net"; aaaa.address = "200:c87d:7960:916:bf0e:a0e1:3da7:4fc6"; }; dns.records.ygg_boline = { tld = config.kw.dns.tld; - domain = "boline.${config.kw.dns.ygg_prefix}"; + domain = "boline.net"; aaaa.address = "200:474d:14f7:1d21:f171:4e85:a3fa:9393"; }; }; diff --git a/default.nix b/default.nix index dd0ee821..cd2b9f83 100644 --- a/default.nix +++ b/default.nix @@ -10,23 +10,16 @@ let /* This is used to generate specialArgs + the like. It works as such: - * A can exist at config/. - * A can exist at config/trusted/. + * A can exist at config/. + * A can exist at config/trusted/. If only one exists, the path for that one is returned. Otherwise a module is generated which contains both import paths. */ - argGenNames = [ "profiles" "users" "targets" "services" ]; - argGen = lib.mapListToAttrs (folder: lib.nameValuePair folder (lib.domainMerge { inherit folder; })) argGenNames; - - /* - This produces an attrSet of hosts based upon: - * hosts being located within config/hosts/ - * hosts having an entrypoint of meta.nix - */ - hosts = lib.domainMerge { - folder = "hosts"; - defaultFile = "meta.nix"; - }; + filterAttrNamesToList = filter: set: + lib.foldl' (a: b: a ++ b) [ ] + (map (e: if (filter e set.${e}) then [ e ] else [ ]) (lib.attrNames set)); + depotNames = lib.unique ((filterAttrNamesToList (name: type: name != "trusted" && type == "directory") (builtins.readDir ./config)) ++ (filterAttrNamesToList (name: type: name != "trusted" && name != "pkgs" && type == "directory") (builtins.readDir ./config/trusted))); + depot = lib.mapListToAttrs (folder: lib.nameValuePair folder (lib.domainMerge { inherit folder; })) depotNames; /* We use this to make the meta runner use this file and to use `--show-trace` on nix-builds. @@ -39,14 +32,14 @@ let # This is where the meta config is evaluated. eval = lib.evalModules { modules = lib.singleton metaConfig - ++ lib.attrValues (removeAttrs argGen.targets ["common"]) - ++ lib.attrValues hosts + ++ lib.attrValues (removeAttrs depot.targets ["common"]) + ++ lib.attrValues depot.hosts ++ lib.optional (builtins.pathExists ./config/trusted/meta.nix) ./config/trusted/meta.nix ++ lib.singleton ./config/modules/meta/default.nix; specialArgs = { inherit sources; - inherit (argGen) profiles users services; + inherit depot; }; }; @@ -55,7 +48,7 @@ let /* Please note all specialArg generated specifications use the folder common to both import paths. - Those import paths are as mentioned above next to `argGenNames`. + Those import paths are as mentioned above next to `depotNames`. This provides us with a ./. that contains (most relevantly): * deploy.targets -> a mapping of target name to host names @@ -66,4 +59,4 @@ let * do not use common, it is tf-nix specific config ingested at line 66 of config/modules/meta/deploy.nix for every target. * services -> the specialArg generated from services/ */ -in config // { inherit pkgs hosts sourceCache sources; } // argGen +in config // { inherit pkgs lib sourceCache sources; } // depot diff --git a/pkgs/lib/domain-merge.nix b/pkgs/lib/domain-merge.nix index bd1ac9b2..ffcbf24c 100644 --- a/pkgs/lib/domain-merge.nix +++ b/pkgs/lib/domain-merge.nix @@ -1,7 +1,10 @@ { lib }: { folder, defaultFile ? "default.nix" }: with lib; let folderNames = [ (../../config + "/${folder}") (../../config/trusted + "/${folder}") ]; + defaultFileFinal = if (defaultFile == "default.nix" && folder == "hosts") then + "meta.nix" + else defaultFile; folderModLists = map (folderName: modList { modulesDir = folderName; - inherit defaultFile; + defaultFile = defaultFileFinal; }) (filter builtins.pathExists folderNames); in foldl modListMerge { } folderModLists