Fixed bug with key providers in static configuration

release
Matthew Salerno 1 year ago
parent e3c89e816f
commit f45752f5d7

@ -13,10 +13,8 @@ let
keyProvidersInit = map (x: x inputs intermediateConfig peerName) keyProviders; keyProvidersInit = map (x: x inputs intermediateConfig peerName) keyProviders;
getPeerPubKey = otherPeerName: findFirst (x: x != null) (throw "Wirenix: Could not find public key for " + otherPeerName) getPeerPubKey = otherPeerName: findFirst (x: x != null) (throw "Wirenix: Could not find public key for " + otherPeerName)
(map (provider: provider.getPeerPubKey otherPeerName) keyProvidersInit); (map (provider: provider.getPeerPubKey otherPeerName) keyProvidersInit);
getPrivKeyFile = getPrivKeyFile (x: x != null) (throw "Wirenix: Could not find private key file for " + peerName) getPrivKeyFile = findFirst (x: x != null) (throw "Wirenix: Could not find private key file for " + peerName)
(map (provider: provider.getPrivKeyFile) keyProvidersInit); (map (provider: provider.getPrivKeyFile) keyProvidersInit);
getPubKey = findFirst (x: x != null) (throw "Wirenix: Could not find public key for " + peerName)
(map (provider: provider.getPubKey) keyProvidersInit);
getSubnetPSKFile = subnetName: findFirst (x: x != null) (null) getSubnetPSKFile = subnetName: findFirst (x: x != null) (null)
(map (provider: provider.getSubnetPSKFile subnetName) keyProvidersInit); (map (provider: provider.getSubnetPSKFile subnetName) keyProvidersInit);
in in

@ -1,10 +1,10 @@
{lib, ...}: intermediateConfig: {lib, ...}: intermediateConfig: peerName:
with import ../lib.nix; with import ../lib.nix;
with lib.attrsets; with lib.attrsets;
with builtins; with builtins;
{ {
config = {}; config = {};
getPeerPubKey = peerName: attrByPath [peerName "publicKey"] null intermediateConfig.peers; getPeerPubKey = otherPeerName: attrByPath [otherPeerName "publicKey"] null intermediateConfig.peers;
getPeerPrivKeyFile = peerName: attrByPath [peerName "privateKeyFile"] null intermediateConfig.peers; getPrivKeyFile = attrByPath [peerName "privateKeyFile"] null intermediateConfig.peers;
getSubnetPSK = subnetName: attrByPath [subnetName "presharedKeyFile"] null intermediateConfig.subnets; getSubnetPSKFile = subnetName: attrByPath [subnetName "presharedKeyFile"] null intermediateConfig.subnets;
} }

@ -28,6 +28,5 @@ let secretsDir = peerName: (nixosConfigForPeer nixosConfigurations peerName).con
}; };
getPeerPubKey = otherPeerName: lib.removeSuffix ".age" ((secretsDir otherPeerName).config.secrets."wirenix-peer-${peerName}".path) + ".pub"; getPeerPubKey = otherPeerName: lib.removeSuffix ".age" ((secretsDir otherPeerName).config.secrets."wirenix-peer-${peerName}".path) + ".pub";
getPrivKeyFile = config.age.secrets."wirenix-peer-${peerName}".path; getPrivKeyFile = config.age.secrets."wirenix-peer-${peerName}".path;
getPubKey = lib.removeSuffix ".age" (config.age.secrets."wirenix-peer-${peerName}".path) + ".pub";
getSubnetPSKFile = subnetName: config.age.secrets."wirenix-subnet-${subnetName}".path; getSubnetPSKFile = subnetName: config.age.secrets."wirenix-subnet-${subnetName}".path;
} }
Loading…
Cancel
Save