summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2025-11-17 00:59:31 +0100
committertv <tv@krebsco.de>2025-11-17 01:32:13 +0100
commit7435b5a59f4231baae07a5778f24f7229f4399fe (patch)
tree539d51fd794cadbfba9d760b4c7774178871ba3c
parent30e1376275bc5be97f36c6298dfe5c9203f31d18 (diff)
kartei tv: evalSubmodule -> foldl' recursiveUpdate {}
-rw-r--r--kartei/tv/default.nix27
1 files changed, 11 insertions, 16 deletions
diff --git a/kartei/tv/default.nix b/kartei/tv/default.nix
index 5953a8b13..84d529786 100644
--- a/kartei/tv/default.nix
+++ b/kartei/tv/default.nix
@@ -1,9 +1,8 @@
-{ config, lib, ... }@attrs: let
+{ config, lib, ... }: let
inherit (builtins)
- getAttr head mapAttrs match pathExists readDir readFile typeOf;
+ getAttr mapAttrs pathExists readDir readFile typeOf;
inherit (lib)
- const hasAttrByPath mapAttrs' mkDefault mkIf optionalAttrs removeSuffix
- toList;
+ const hasAttrByPath mapAttrs' mkDefault optionalAttrs removeSuffix;
slib = import ../../lib/pure.nix { inherit lib; };
in {
dns.providers = {
@@ -11,13 +10,7 @@ in {
};
hosts =
mapAttrs
- (hostName: hostFile: let
- hostSource = import hostFile;
- hostConfig = getAttr (typeOf hostSource) {
- lambda = hostSource attrs;
- set = hostSource;
- };
- in slib.evalSubmodule slib.types.host [
+ (hostName: hostConfig: builtins.foldl' lib.recursiveUpdate {} [
hostConfig
{
name = hostName;
@@ -41,17 +34,19 @@ in {
wireguard.pubkey = readFile pubkey-path;
};
})
- (host: mkIf (host.config.ssh.pubkey != null) {
- ssh.privkey = mapAttrs (const mkDefault) {
- path = "${config.krebs.secret.directory}/ssh.id_${host.config.ssh.privkey.type}";
- type = head (toList (builtins.match "ssh-([^ ]+) .*" host.config.ssh.pubkey));
+ (lib.optionalAttrs (hostConfig.ssh.pubkey or null != null) {
+ ssh.privkey = builtins.mapAttrs (const mkDefault) rec {
+ path = "${config.krebs.secret.directory}/ssh.id_${type}";
+ type = builtins.head (lib.toList (builtins.match "ssh-([^ ]+) .*" hostConfig.ssh.pubkey));
};
})
])
(mapAttrs'
(name: type: {
name = removeSuffix ".nix" name;
- value = ./hosts + "/${name}";
+ value = lib.toFunction (import (./hosts + "/${name}")) {
+ inherit config lib;
+ };
})
(readDir ./hosts));
sitemap = {