summaryrefslogtreecommitdiff
path: root/nixos/services.nix
blob: 1d9d850729f7dcc6b7f16de47ec2ef159d587c9e (plain)
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
{ lib, config, pkgs, ... }:

let
  direnv-reload-service = user: {
    description = "Update virtual environments of user ${user}";

    restartIfChanged = false;
    unitConfig.X-StopOnRemoval = false;
    serviceConfig = {
      Type = "oneshot";
      User = user;
    };

    environment = {
      inherit (config.environment.sessionVariables) NIX_PATH;
      HOME = config.users.users."${user}".home;
    };

    path = with pkgs; [ direnv ];
    script = ''
       find $HOME -type d -name .nix-gc-roots -execdir direnv exec . true \;
    '';

    after = [ "nixos-upgrade.service" ];
    wantedBy = [ "nixos-upgrade.service" ];
  };
in {
  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  systemd.services.direnv-reload = lib.mkIf config.system.autoUpgrade.enable
    (direnv-reload-service "qaristote");
  systemd.services.nix-gc.after = [ "direnv-reload.service" ];

  # virtualisation.docker.enable = true;
}