-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.nix
56 lines (53 loc) · 1.49 KB
/
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
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.dmn;
in
{
options.services.dmn = {
enable = mkEnableOption "dmn";
commands = mkOption {
type = with types; listOf (submodule {
options = {
executable = mkOption {
type = str;
};
arguments = mkOption {
type = listOf str;
};
};
});
};
};
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "targets.darwin.defaults" pkgs platforms.darwin)
];
launchd.agents.dmn = {
enable = true;
config = {
Label = "com.gauck.sam.dmn";
KeepAlive = true;
ProgramArguments =
let
package = pkgs.callPackage ./. {};
in
[
"/bin/sh"
"-c"
"/bin/wait4path /nix/store && exec ${package}/bin/dmn"
];
# Theoretically you can view logs directly with
# `sudo launchctl debug <service> --stdout --stderr`
# As is typical for launchd, this has never worked for me,
# so possibly include an option to enable log files in the future?
# Or just expect people to set
# `launchd.agents.dmn.config.StandardOutPath = "/tmp/out";`
# on their own.
# StandardOutPath = "/tmp/nix-dmn-stdout.log";
# StandardErrorPath = "/tmp/nix-dmn-stderr.log";
};
};
xdg.configFile."dmn/commands.json".text = (builtins.toJSON cfg.commands);
};
}