-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
127 lines (116 loc) · 3.34 KB
/
Copy pathflake.nix
File metadata and controls
127 lines (116 loc) · 3.34 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
description = "tangle";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs =
{ self, nixpkgs }:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
packages = forAllSystems (system: {
default = nixpkgs.legacyPackages.${system}.callPackage ./package.nix { };
});
devShells = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.mkShell {
packages = with pkgs; [
go
gcc
];
};
}
);
nixosModules.default =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.tangle;
yamlConfig = pkgs.writers.writeYAML "config.yaml" {
actions = cfg.actions;
};
in
{
options.services.tangle = {
enable = lib.mkEnableOption "Tangle daemon";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
description = "The tangle package to use.";
};
actions = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
default = [ ];
description = "List of action hooks.";
};
};
config = lib.mkIf cfg.enable {
environment.etc."tangle/config.yaml".source = yamlConfig;
systemd.services.tangle = {
description = "tangle daemon";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/tangle";
Restart = "on-failure";
RestrictAddressFamilies = [ "AF_UNIX" ];
};
};
};
};
hmModules.default =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.tangle;
in
{
options.services.tangle = {
enable = lib.mkEnableOption "Tangle daemon";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
description = "The tangle package to use.";
};
actions = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
default = [ ];
description = "List of action hooks.";
};
};
config = lib.mkIf cfg.enable {
xdg.configFile."tangle/config.yaml".text = lib.generators.toYAML { } {
actions = cfg.actions;
};
systemd.user.services.tangle = {
Unit = {
Description = "tangle daemon (user service)";
After = [ "graphical-session.target" ];
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${cfg.package}/bin/tangle";
Restart = "on-failure";
};
};
};
};
};
}