forked from srid/neuron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
home-manager-module.nix
92 lines (80 loc) · 2.12 KB
/
home-manager-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
80
81
82
83
84
85
86
87
88
89
90
91
92
{ config, lib, pkgs, ... }:
let
inherit (lib)
mkEnableOption
mkIf
mkOption
types
;
cfg = config.services.neuron;
in
{
options = {
services.neuron = {
enable = mkEnableOption ''
Future-proof note-taking and publishing based on Zettelkasten
'';
package = mkOption {
type = types.package;
default = pkgs.neuron-notes;
defaultText = "pkgs.neuron-notes";
description = "neuron derivation to use";
};
notesDirectory = mkOption {
type = types.nullOr types.path;
default = null;
example = "/home/\${name}/zettelkasten";
description = "Directory that holds the neuron notes";
};
host = mkOption {
type = types.str;
default = "127.0.0.1";
description = "The hostname or IP address the HTTP server should listen to";
};
port = mkOption {
type = types.port;
default = 8080;
description = "Port the HTTP server should listen to";
};
prettyUrls = mkOption {
type = types.bool;
default = false;
description = "If set, drops the .html at the end of Zettel URLs.";
};
systemdTarget = mkOption {
type = types.str;
default = "graphical-session.target";
description = "Systemd target to bind to";
};
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.notesDirectory != null;
message = "`services.neuron.notesDirectory' must be set.";
}
];
systemd.user.services.neuron = {
Unit = {
Description = "Neuron zettelkasten service";
PartOf = [ cfg.systemdTarget ];
After = [ cfg.systemdTarget ];
};
Service = {
Type = "exec";
ExecStart = ''
${cfg.package}/bin/neuron \
-d ${cfg.notesDirectory} \
gen \
--watch \
--serve ${cfg.host}:${toString cfg.port} \
${lib.optionalString cfg.prettyUrls "--pretty-urls"}
'';
};
Install = {
WantedBy = [ cfg.systemdTarget ];
};
};
};
}