-
Notifications
You must be signed in to change notification settings - Fork 25
/
service.nix
59 lines (50 loc) · 1.22 KB
/
service.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
{ config, lib, pkgs, ... }:
let
dockerRun =
import ./default.nix { pkgs = pkgs; };
cfg =
config.services.dockerRun;
commonEnvironment = {
LC_ALL = "en_US.UTF-8";
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
};
in
{
options = {
services.dockerRun = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable docker-run";
};
environment = lib.mkOption {
type = lib.types.attrs;
default = {};
description = "Environment variables for the service";
};
};
};
config = lib.mkIf cfg.enable {
# Add glot group
users.groups.glot = {};
# Service user
users.extraUsers.glot = {
isSystemUser = true;
group = "glot";
extraGroups = ["docker"];
description = "service user";
};
# Systemd service
systemd.services.docker-run = {
description = "docker-run service";
wantedBy = [ "multi-user.target" ];
serviceConfig =
{
ExecStart = "${dockerRun}/bin/docker-run";
Restart = "always";
User = "glot";
};
environment = commonEnvironment // cfg.environment;
};
};
}