-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrrr-demo.module.nix
52 lines (48 loc) · 1.62 KB
/
brrr-demo.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
# Copyright © 2024 Brrr Authors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# A NixOS module for a brrr demo binary. N.B.: It does not contain any
# dependencies; this is just the demo script.
#
# Inspired by
# https://blakesmith.me/2024/03/02/running-nixos-tests-with-flakes.html
{ lib, config, pkgs, ... }: {
options.services.brrr-demo = let
native = import ./brrr-demo.options.nix { inherit lib pkgs; };
mod1 = { options = native; };
mod2 = {
options.enable = lib.mkEnableOption "brrr-demo";
};
in lib.mkOption {
description = "Brrr demo service configuration";
type = lib.types.submoduleWith {
modules = [ mod1 mod2 ];
};
default = {};
};
config = let
cfg = config.services.brrr-demo;
in lib.mkIf cfg.enable {
systemd.services.brrr-demo = {
inherit (cfg) environment;
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
script = ''
exec ${lib.getExe cfg.package} ${lib.escapeShellArgs cfg.args}
'';
serviceConfig = {
Type = "simple";
};
};
};
}