summaryrefslogtreecommitdiffstats
path: root/nixos/modules/virtualisation/incus-agent.nix
blob: 34c08e8ee0146a4259f6dc8b291da7774566db11 (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
39
40
41
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.virtualisation.incus.agent;
in
{
  meta = {
    teams = [ lib.teams.lxc ];
  };

  options = {
    virtualisation.incus.agent.enable = lib.mkEnableOption "Incus agent";
  };

  config = lib.mkIf cfg.enable {
    services.udev.packages = [ config.virtualisation.incus.package.agent_loader ];
    systemd.packages = [ config.virtualisation.incus.package.agent_loader ];

    systemd.services.incus-agent = {
      enable = true;
      wantedBy = [ "multi-user.target" ];

      path = [
        pkgs.kmod
        pkgs.util-linux

        # allow `incus exec` to find system binaries
        "/run/current-system/sw"
      ];

      # avoid killing nixos-rebuild switch when executed through incus exec
      restartIfChanged = false;
      stopIfChanged = false;
    };
  };
}