Skip to content

Commit 13cd7af

Browse files
authored
nixos/glance: add environmentFile option (#413373)
2 parents 2949933 + 3bddd16 commit 13cd7af

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

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

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,64 @@ in
100100
for more.
101101
102102
Settings containing secret data should be set to an
103-
attribute set containing the attribute
104-
<literal>_secret</literal> - a string pointing to a file
105-
containing the value the option should be set to. See the
106-
example in `services.glance.settings.pages` at the weather widget
103+
attribute set with this format: `{ _secret = "/path/to/secret"; }`.
104+
See the example in `services.glance.settings.pages` at the weather widget
107105
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`.
108109
'';
109110
};
110111

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+
111161
openFirewall = mkOption {
112162
type = types.bool;
113163
default = false;
@@ -159,6 +209,7 @@ in
159209
'';
160210
ExecStart = "${getExe cfg.package} --config ${mergedSettingsFile}";
161211
WorkingDirectory = "/var/lib/glance";
212+
EnvironmentFile = cfg.environmentFile;
162213
StateDirectory = "glance";
163214
RuntimeDirectory = "glance";
164215
RuntimeDirectoryMode = "0755";

0 commit comments

Comments
 (0)