-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathdrip.nix
80 lines (78 loc) · 1.73 KB
/
drip.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
80
{ self, ... }:
{
perSystem =
{
self',
pkgs,
system,
config,
crane,
stdenv,
dbg,
mkCi,
...
}:
let
drip = crane.buildWorkspaceMember {
crateDirFromRoot = "drip";
};
in
{
packages.drip = drip.packages.drip;
};
flake.nixosModules.drip =
{
lib,
pkgs,
config,
...
}:
with lib;
let
cfg = config.services.drip;
in
{
options.services.drip = {
enable = mkEnableOption "drip service";
package = mkOption {
type = types.package;
default = self.packages.${pkgs.system}.drip;
};
config = mkOption {
type = types.attrs;
description = "config file";
};
log-level = mkOption {
type = types.str;
description = "RUST_LOG";
};
};
config = mkIf cfg.enable {
systemd.services.drip =
let
drip-systemd-script = pkgs.writeShellApplication {
name = "drip-systemd";
runtimeInputs = [
pkgs.coreutils
cfg.package
];
text = ''
${pkgs.lib.getExe cfg.package} -c '${builtins.toFile "drip-config.json" (builtins.toJSON cfg.config)}'
'';
};
in
{
wantedBy = [ "multi-user.target" ];
description = "drip";
serviceConfig = {
Type = "simple";
ExecStart = pkgs.lib.getExe drip-systemd-script;
Restart = mkForce "always";
};
environment = {
RUST_LOG = cfg.log-level;
};
};
};
};
}