ctucx.git: nixfiles

ctucx' nixfiles

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
{ inputs, config, pkgs, lib, ... }:

let
  cfg             = config.ctucxConfig.services.syncthing;
  syncthingConfig = import ../../common/syncthing-config.nix { inherit inputs pkgs config lib; };

in {
  options = {
    ctucxConfig.services.syncthing = {
      enable = lib.mkEnableOption "syncthing";
    };
  };

  config = lib.mkIf cfg.enable {
    age.secrets = {
      syncthing-key = {
        file  = ../../../secrets + "/${config.networking.hostName}/syncthing/key.age";
        owner = "katja";
      };
      syncthing-cert = {
        file  = ../../../secrets + "/${config.networking.hostName}/syncthing/cert.age";
        owner = "katja";
      };
    };

    systemd.services.syncthing.onFailure = [ "email-notify@%i.service" ];

    services.syncthing = {
      enable           = true;
      openDefaultPorts = true;

      user             = "katja";
      group            = "users";

      key              = lib.mkDefault config.age.secrets.syncthing-key.path;
      cert             = lib.mkDefault config.age.secrets.syncthing-cert.path;

      dataDir          = lib.mkDefault "/home/katja";
      configDir        = lib.mkDefault "/home/katja/.config/syncthing";

      settings.devices = syncthingConfig.devices;
      settings.folders = syncthingConfig.folders;
    };
  };

}