-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.nix
More file actions
39 lines (35 loc) · 959 Bytes
/
Copy pathmodule.nix
File metadata and controls
39 lines (35 loc) · 959 Bytes
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
{ config, lib, pkgs, ... }:
let
cfg = config.programs.njalla;
in
{
options.programs.njalla = {
enable = lib.mkEnableOption "njalla-cli domain management tool";
package = lib.mkOption {
type = lib.types.package;
description = "The njalla-cli package to use";
};
secretsFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
example = "/var/lib/secrets/njalla/env";
description = ''
Path to environment file containing NJALLA_API_TOKEN.
File should contain: NJALLA_API_TOKEN=your-token
'';
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [
(if cfg.secretsFile != null then
pkgs.writeShellScriptBin "njalla" ''
set -a
[ -f ${cfg.secretsFile} ] && source ${cfg.secretsFile}
set +a
exec ${cfg.package}/bin/njalla "$@"
''
else
cfg.package)
];
};
}