mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-16 01:55:13 -05:00
feat: added wireguard
This commit is contained in:
parent
a635237125
commit
a7ed1629e8
6 changed files with 105 additions and 5 deletions
18
modules/config/instances/config/wireGuard.nix
Normal file
18
modules/config/instances/config/wireGuard.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ instancesFunctions }:
|
||||
let
|
||||
inherit (instancesFunctions)
|
||||
sopsPath
|
||||
;
|
||||
|
||||
wireGuardLabel = "WireGuard";
|
||||
wireGuardName = "wireguard";
|
||||
in
|
||||
{
|
||||
label = wireGuardLabel;
|
||||
name = wireGuardName;
|
||||
sops = {
|
||||
path0 = "${sopsPath}/${wireGuardName}";
|
||||
};
|
||||
ports = {
|
||||
};
|
||||
}
|
|
@ -62,6 +62,7 @@ in
|
|||
theming
|
||||
polychromatic
|
||||
dolphin
|
||||
espanso
|
||||
;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,6 +17,7 @@ in
|
|||
flatpak
|
||||
plasma
|
||||
sddm
|
||||
wireGuard
|
||||
;
|
||||
};
|
||||
};
|
||||
|
|
67
modules/nixos/services/wireGuard/default.nix
Normal file
67
modules/nixos/services/wireGuard/default.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{ config, flake, ... }:
|
||||
let
|
||||
inherit (flake.config.services.instances) wireGuard;
|
||||
service = wireGuard;
|
||||
|
||||
wireGuardInterface =
|
||||
{
|
||||
secret,
|
||||
publicKey,
|
||||
endpoint,
|
||||
}:
|
||||
{
|
||||
name = "Proton-${secret}";
|
||||
value = {
|
||||
autostart = false;
|
||||
address = [ "10.2.0.2/32" ];
|
||||
dns = [ "10.2.0.1" ];
|
||||
privateKeyFile = config.sops.secrets."${service.name}-${secret}".path;
|
||||
peers = [
|
||||
{
|
||||
inherit publicKey endpoint;
|
||||
allowedIPs = [ "0.0.0.0/0,::/0" ];
|
||||
persistentKeepalive = 25;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
interfaces = [
|
||||
{
|
||||
secret = "CA363";
|
||||
publicKey = "9mTDh5Tku0gxDdzqxnpnzItHQBm2h2B2hXnUHvhGCFw=";
|
||||
endpoint = "149.88.97.110:51820";
|
||||
}
|
||||
{
|
||||
secret = "CA220";
|
||||
publicKey = "UR8vjVYrrWYadCwLKiAabKTIdxM4yikmCXnvKWm89D8=";
|
||||
endpoint = "139.28.218.130:51820";
|
||||
}
|
||||
{
|
||||
secret = "CA358";
|
||||
publicKey = "9mTDh5Tku0gxDdzqxnpnzItHQBm2h2B2hXnUHvhGCFw=";
|
||||
endpoint = "149.88.97.110:51820";
|
||||
}
|
||||
{
|
||||
secret = "CA627";
|
||||
publicKey = "xLFgU430Tt7PdHJydVbIKvtjXJodoPpGKW7fhF7XE2k=";
|
||||
endpoint = "139.28.218.130:51820";
|
||||
}
|
||||
];
|
||||
|
||||
sopsPath = secret: {
|
||||
path = "${service.sops.path0}/${service.name}-${secret}";
|
||||
owner = "root";
|
||||
mode = "600";
|
||||
};
|
||||
in
|
||||
{
|
||||
networking.wg-quick.interfaces = builtins.listToAttrs (map wireGuardInterface interfaces);
|
||||
|
||||
sops.secrets = builtins.listToAttrs (
|
||||
map (interface: {
|
||||
name = "${service.name}-${interface.secret}";
|
||||
value = sopsPath interface.secret;
|
||||
}) interfaces
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue