-
Notifications
You must be signed in to change notification settings - Fork 10
/
disnix-module.nix
79 lines (65 loc) · 2.44 KB
/
disnix-module.nix
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
67
68
69
70
71
72
73
74
75
76
77
78
79
{pkgs, lib, config, ...}:
with lib;
let
cfg = config.services.disnixTest;
in
{
options = {
services = {
disnixTest = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable Disnix";
};
enableMultiUser = mkOption {
type = types.bool;
default = true;
description = "Whether to support multi-user mode by enabling the Disnix D-Bus service";
};
package = mkOption {
type = types.path;
description = "The Disnix package";
};
dysnomia = mkOption {
type = types.path;
description = "The Dysnomia package";
};
enableProfilePath = mkOption {
type = types.bool;
default = false;
description = "Whether to expose Disnix profiles in the system's PATH";
};
profiles = mkOption {
type = types.listOf types.string;
default = [ "default" ];
example = [ "default" ];
description = "Names of the Disnix profiles to expose in the system's PATH";
};
};
};
};
config = mkIf cfg.enable {
ids.gids = { disnix = 200; };
users.extraGroups.disnix.gid = 200;
services.dbus.enable = true;
services.dbus.packages = [ cfg.package ];
services.openssh.enable = true;
services.disnixTest.package = mkDefault (import ./release.nix {}).build."${pkgs.stdenv.system}";
systemd.services.disnix = mkIf cfg.enableMultiUser
{ description = "Disnix server";
wantedBy = [ "multi-user.target" ];
after = [ "dbus.service" ];
path = [ config.nix.package cfg.package cfg.dysnomia ];
environment = {
HOME = "/root";
}
// (if config.environment.variables ? DYSNOMIA_CONTAINERS_PATH then { inherit (config.environment.variables) DYSNOMIA_CONTAINERS_PATH; } else {})
// (if config.environment.variables ? DYSNOMIA_MODULES_PATH then { inherit (config.environment.variables) DYSNOMIA_MODULES_PATH; } else {});
serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service";
};
environment.systemPackages = [ cfg.package ];
environment.variables.PATH = lib.optionals cfg.enableProfilePath (map (profileName: "/nix/var/nix/profiles/disnix/${profileName}/bin" ) cfg.profiles);
environment.variables.DISNIX_REMOTE_CLIENT = lib.optionalString (cfg.enableMultiUser) "disnix-client";
};
}