1 { config, pkgs, lib, ... }:
3 cfg = config.myServices.vpn;
7 vpn.enable = lib.mkEnableOption "Enable vpn service";
10 config = lib.mkIf cfg.enable {
16 text = config.myEnv.vpn.eldiron.privateKey;
22 text = config.myEnv.vpn.eldiron.publicKey;
25 networking.firewall.allowedTCPPorts = [ 655 1194 ];
26 system.activationScripts.tinc = let
27 configFiles = pkgs.runCommand "tinc-files" {
28 mainInterface = "eth0";
31 keyFile = config.secrets.fullPaths."tinc/key.priv";
34 for i in ${./tinc}/*; do
35 substituteAll $i $out/$(basename $i)
39 install -m750 -o root -g root -d /var/lib/tinc/ /var/lib/tinc/Immae
40 install -m700 -o root -g root -t /var/lib/tinc/Immae ${configFiles}/{host-*,tinc-*}
41 install -m400 -o root -g root -t /var/lib/tinc/Immae ${configFiles}/tinc.conf
42 if [ ! -d /var/lib/tinc/Immae/hosts ]; then
43 ${pkgs.git}/bin/git clone -b master https://git.immae.eu/perso/Immae/Config/tinc/hosts /var/lib/tinc/Immae/hosts
47 systemd.slices.tinc = {
48 description = "Tinc slice";
51 systemd.services.tinc-Immae = {
52 description = "Tinc Daemon - Immae";
53 wantedBy = [ "multi-user.target" ];
54 after = [ "network.target" ];
55 path = [ pkgs.tinc pkgs.bashInteractive pkgs.iproute pkgs.gnused pkgs.gawk pkgs.git pkgs.glibc ];
61 ExecStart = "${pkgs.tinc}/bin/tincd -d1 -D -c /var/lib/tinc/Immae --pidfile /run/tinc.Immae.pid";