nixos-config/machines/cherry/network-wireguard-wg1.nix

28 lines
803 B
Nix
Raw Normal View History

2024-08-07 09:14:26 +02:00
{ pkgs, config, ... }:
2024-08-07 08:14:09 +02:00
{
clan.core.facts.services.wg1 = {
secret."wg1.conf" = { };
generator = {
# I download the config from my fritz.box
# cat wg_config.conf | pass insert -m machiens/<name>/wg1.conf
prompt = "please enter the wg1.conf";
path = with pkgs; [ coreutils ];
script = ''
echo "$prompt_value" > "$secrets"/wg1.conf
'';
};
};
2024-08-07 09:14:26 +02:00
home-manager.users.root.home.packages = [
(pkgs.writers.writeBashBin "wg1-up" ''
2024-08-29 03:26:04 +02:00
${pkgs.wireguard-tools}/bin/wg-quick up ${
config.clan.core.facts.services.wg1.secret."wg1.conf".path
}
2024-08-07 08:14:09 +02:00
'')
2024-08-07 09:14:26 +02:00
(pkgs.writers.writeBashBin "wg1-down" ''
2024-08-29 03:26:04 +02:00
${pkgs.wireguard-tools}/bin/wg-quick down ${
config.clan.core.facts.services.wg1.secret."wg1.conf".path
}
2024-08-07 09:14:26 +02:00
'')
2024-08-07 08:14:09 +02:00
];
}