1 { config, pkgs, lib, ... }:
3 cfg = config.myServices.vpn;
7 vpn.enable = lib.mkEnableOption "Enable vpn service";
10 config = lib.mkIf cfg.enable {
13 dest = "tinc/key.priv";
17 text = config.myEnv.vpn.eldiron.privateKey;
20 dest = "tinc/key.pub";
24 text = config.myEnv.vpn.eldiron.publicKey;
27 networking.firewall.allowedTCPPorts = [ 655 1194 ];
28 system.activationScripts.tinc = let
29 configFiles = pkgs.runCommand "tinc-files" {
30 mainInterface = "eth0";
33 keyFile = config.secrets.fullPaths."tinc/key.priv";
36 for i in ${./tinc}/*; do
37 substituteAll $i $out/$(basename $i)
41 install -m750 -o root -g root -d /var/lib/tinc/ /var/lib/tinc/Immae
42 install -m700 -o root -g root -t /var/lib/tinc/Immae ${configFiles}/{host-*,tinc-*}
43 install -m400 -o root -g root -t /var/lib/tinc/Immae ${configFiles}/tinc.conf
44 if [ ! -d /var/lib/tinc/Immae/hosts ]; then
45 ${pkgs.git}/bin/git clone -b master https://git.immae.eu/perso/Immae/Config/tinc/hosts /var/lib/tinc/Immae/hosts
49 systemd.slices.tinc = {
50 description = "Tinc slice";
53 systemd.services.tinc-Immae = {
54 description = "Tinc Daemon - Immae";
55 wantedBy = [ "multi-user.target" ];
56 after = [ "network.target" ];
57 path = [ pkgs.tinc pkgs.bashInteractive pkgs.iproute pkgs.gnused pkgs.gawk pkgs.git pkgs.glibc ];
63 ExecStart = "${pkgs.tinc}/bin/tincd -d1 -D -c /var/lib/tinc/Immae --pidfile /run/tinc.Immae.pid";