tsuki: fix eval

This commit is contained in:
Oystein Kristoffer Tveit 2024-06-25 22:26:09 +02:00
parent 30b8f6449a
commit 7c3e6fcf42
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 15 additions and 10 deletions

View File

@ -2,7 +2,7 @@
let let
inherit (config) machineVars; inherit (config) machineVars;
in { in {
sops.defaultSopsFile = ./.. + "secrets/${config.networking.hostName}.yaml"; sops.defaultSopsFile = ./.. + "/secrets/${config.networking.hostName}.yaml";
sops.secrets = { sops.secrets = {
"ssh/nix-builders/tsuki/key" = { sopsFile = ./../secrets/common.yaml; }; "ssh/nix-builders/tsuki/key" = { sopsFile = ./../secrets/common.yaml; };

View File

@ -50,6 +50,7 @@
networking = { networking = {
hostName = "tsuki"; hostName = "tsuki";
hostId = "8425e349";
networkmanager.enable = true; networkmanager.enable = true;
interfaces.ens18.useDHCP = true; interfaces.ens18.useDHCP = true;
firewall.enable=true; firewall.enable=true;

View File

@ -3,7 +3,7 @@ let
inherit (lib) mkOption types mdDoc; inherit (lib) mkOption types mdDoc;
in in
{ {
options.socketActivation = mkOption { options.local.socketActivation = mkOption {
type = types.attrsOf (types.submodule ({ name, ... }: { type = types.attrsOf (types.submodule ({ name, ... }: {
options = { options = {
enable = lib.mkEnableOption "socket activation for a systemd service"; enable = lib.mkEnableOption "socket activation for a systemd service";
@ -109,7 +109,7 @@ in
}; };
config = let config = let
activeServices = lib.filterAttrs (_: value: value.enable) config.socketActivation; activeServices = lib.filterAttrs (_: value: value.enable) config.local.socketActivation;
foreachService = f: lib.mapAttrsToList f activeServices; foreachService = f: lib.mapAttrsToList f activeServices;
in { in {
assertions = foreachService (name: value: { assertions = foreachService (name: value: {
@ -130,13 +130,17 @@ in
''; '';
}); });
services.nginx.upstreams = let services.nginx.upstreams = lib.pipe activeServices [
servicesWithNginxUpstream = lib.filterAttrs (_: value: value.createNginxUpstream) activeServices; (lib.filterAttrs (_: value: value.createNginxUpstream))
in lib.mapAttrsToList (name: value: let (lib.mapAttrsToList
protocol = if lib.any (p: lib.hasPrefix p value.newSocketAddress) [ "/" "@" ] then "unix" else "http"; (name: value: let
in { protocol = if lib.any (p: lib.hasPrefix p value.newSocketAddress) [ "/" "@" ] then "unix" else "http";
${name}.servers."${protocol}:${value.newSocketAddress}" = { }; in {
}) servicesWithNginxUpstream; ${name}.servers."${protocol}:${value.newSocketAddress}" = { };
})
)
(lib.foldl lib.recursiveUpdate { })
];
systemd = lib.mkMerge (foreachService (name: value: let systemd = lib.mkMerge (foreachService (name: value: let
originalService = config.systemd.services.${value.service}; originalService = config.systemd.services.${value.service};