all repos — nixfiles @ 3d5de0f50d620b3e9d2b71d9601313886d045997

System and user configuration, managed by nix and home-manager

system/roles/server.nix (view raw)

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
  config,
  pkgs,
  lib,
  ...
}:
let
  mkRoleDefault = lib.mkOverride 500;
in
{
  imports = [
    ../settings/configuration/nix-linux.nix
    ../settings/configuration/auto-upgrade.nix
    ../settings/configuration/date-time.nix
    ../settings/configuration/locale.nix

    ../settings/services/tailscale.nix
    ../settings/services/ssh.nix

    ./remote-admin.nix
    ./base.nix
  ];

  environment.systemPackages = with pkgs; [
    lsof
  ];

  srvos.server.docs.enable = true;

  nix.settings = {
    max-jobs = mkRoleDefault 2;
    cores = mkRoleDefault 2;
  };

  services.sshguard = {
    enable = true;
  };

  services.journald.extraConfig = ''
    MaxRetentionSec=1 month
  '';

  systemd.services.update-home-manager =
    let
      nixfiles = lib.removePrefix "-" config.systemd.services.update-nixfiles.serviceConfig.WorkingDirectory;
    in
    {
      startAt = "weekly";
      path = with pkgs; [
        openssh
        nix
        config.programs.git.package
      ];
      serviceConfig = rec {
        Type = "oneshot";
        User = "alin";
        ExecStart = "${lib.getExe pkgs.nh} home switch --file ${nixfiles} homeConfigurations.${User}@%H --no-nom";
      };
    };

  services.syncthing = {
    dataDir = "/srv/syncthing";
    configDir = "/var/lib/syncthing";
    guiAddress = "[::]:8384";
  };
}