···
cfg = config.services.glance;
settingsFormat = pkgs.formats.yaml { };
30
+
settingsFile = settingsFormat.generate "glance.yaml" cfg.settings;
31
+
mergedSettingsFile = "/run/glance/glance.yaml";
options.services.glance = {
···
72
-
location = "Nivelles, Belgium";
85
+
_secret = "/var/lib/secrets/glance/location";
···
Configuration written to a yaml file that is read by glance. See
<https://github.com/glanceapp/glance/blob/main/docs/configuration.md>
102
+
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
107
+
with a location secret to get a better picture of this.
···
description = "Glance feed dashboard server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
126
+
path = [ pkgs.replace-secret ];
109
-
glance-yaml = settingsFormat.generate "glance.yaml" cfg.settings;
133
+
if isAttrs data then
134
+
if data ? _secret then
137
+
concatLists (map (attr: findSecrets (getAttr attr data)) (attrNames data))
138
+
else if isList data then
139
+
concatLists (map findSecrets data)
142
+
secretPaths = catAttrs "_secret" (findSecrets cfg.settings);
143
+
mkSecretReplacement = secretPath: ''
145
+
lib.escapeShellArgs [
146
+
"_secret: ${secretPath}"
152
+
secretReplacements = concatMapStrings mkSecretReplacement secretPaths;
111
-
"${getExe cfg.package} --config ${glance-yaml}";
154
+
# Use "+" to run as root because the secrets may not be accessible to glance
156
+
+ pkgs.writeShellScript "glance-start-pre" ''
157
+
install -m 600 -o $USER ${settingsFile} ${mergedSettingsFile}
158
+
${secretReplacements}
160
+
ExecStart = "${getExe cfg.package} --config ${mergedSettingsFile}";
WorkingDirectory = "/var/lib/glance";
StateDirectory = "glance";
RuntimeDirectory = "glance";