Skip to content

Commit 3bddd16

Browse files
committed
nixos/glance: add environmentFile option
1 parent 6591213 commit 3bddd16

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

nixos/modules/services/web-apps/glance.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,61 @@ in
103103
attribute set with this format: `{ _secret = "/path/to/secret"; }`.
104104
See the example in `services.glance.settings.pages` at the weather widget
105105
with a location secret to get a better picture of this.
106+
107+
Alternatively, you can use a single file with environment variables,
108+
see `services.glance.environmentFile`.
106109
'';
107110
};
108111

112+
environmentFile = mkOption {
113+
type = types.nullOr types.path;
114+
description =
115+
let
116+
singleQuotes = "''";
117+
in
118+
''
119+
Path to an environment file as defined in {manpage}`systemd.exec(5)`.
120+
121+
See upstream documentation
122+
<https://github.com/glanceapp/glance/blob/main/docs/configuration.md#environment-variables>.
123+
124+
Example content of the file:
125+
```
126+
TIMEZONE=Europe/Paris
127+
```
128+
129+
Example `services.glance.settings.pages` configuration:
130+
```nix
131+
[
132+
{
133+
name = "Home";
134+
columns = [
135+
{
136+
size = "full";
137+
widgets = [
138+
{
139+
type = "clock";
140+
timezone = "\''${TIMEZONE}";
141+
label = "Local Time";
142+
}
143+
];
144+
}
145+
];
146+
}
147+
];
148+
```
149+
150+
Note that when using Glance's `''${ENV_VAR}` syntax in Nix,
151+
you need to escape it as follows: use `\''${ENV_VAR}` in `"` strings
152+
and `${singleQuotes}''${ENV_VAR}` in `${singleQuotes}` strings.
153+
154+
Alternatively, you can put each secret in it's own file,
155+
see `services.glance.settings`.
156+
'';
157+
default = "/dev/null";
158+
example = "/var/lib/secrets/glance";
159+
};
160+
109161
openFirewall = mkOption {
110162
type = types.bool;
111163
default = false;
@@ -157,6 +209,7 @@ in
157209
'';
158210
ExecStart = "${getExe cfg.package} --config ${mergedSettingsFile}";
159211
WorkingDirectory = "/var/lib/glance";
212+
EnvironmentFile = cfg.environmentFile;
160213
StateDirectory = "glance";
161214
RuntimeDirectory = "glance";
162215
RuntimeDirectoryMode = "0755";

0 commit comments

Comments
 (0)