git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/journalwatch: permissionsStartOnly is deprecated

See #53852 for details, related to the efforts in #56265

commite916cdf02de684c963b65cbd07df78031ddc54a0 authorFlorian Jacob <projects+git@florianjacob.de> dateSat 13 Apr 2019, 22:08 (8 years ago) parent68c6f3f
1 file changed+30−12
nixos/modules/services/logging/journalwatch.nix+30−12
nixos/modules/services/logging/journalwatch.nix+30−12
@@ -4,6 +4,8 @@ with lib;
44let
55 cfg = config.services.journalwatch;
66 user = "journalwatch";
7+ # for journal access
8+ group = "systemd-journal";
79 dataDir = "/var/lib/${user}";
810
911 journalwatchConfig = pkgs.writeText "config" (''
@@ -31,6 +33,17 @@ let
3133
3234 '') filterBlocks);
3335
36+ # can't use joinSymlinks directly, because when we point $XDG_CONFIG_HOME
37+ # to the /nix/store path, we still need the subdirectory "journalwatch" inside that
38+ # to match journalwatch's expectations
39+ journalwatchConfigDir = pkgs.runCommand "journalwatch-config"
40+ { preferLocalBuild = true; allowSubstitutes = false; }
41+ ''
42+ mkdir -p $out/journalwatch
43+ ln -sf ${journalwatchConfig} $out/journalwatch/config
44+ ln -sf ${journalwatchPatterns} $out/journalwatch/patterns
45+ '';
46+
3447
3548in {
3649 options = {
@@ -199,33 +212,38 @@ in {
199212
200213 users.users.${user} = {
201214 isSystemUser = true;
202− createHome = true;
203215 home = dataDir;
204− # for journal access
205− group = "systemd-journal";
216+ group = group;
206217 };
207218
219+ systemd.tmpfiles.rules = [
220+ # present since NixOS 19.09: remove old stateful symlink join directory,
221+ # which has been replaced with the journalwatchConfigDir store path
222+ "R ${dataDir}/config"
223+ ];
224+
208225 systemd.services.journalwatch = {
226+
209227 environment = {
228+ # journalwatch stores the last processed timpestamp here
229+ # the share subdirectory is historic now that config home lives in /nix/store,
230+ # but moving this in a backwards-compatible way is much more work than what's justified
231+ # for cleaning that up.
210232 XDG_DATA_HOME = "${dataDir}/share";
211− XDG_CONFIG_HOME = "${dataDir}/config";
233+ XDG_CONFIG_HOME = journalwatchConfigDir;
212234 };
213235 serviceConfig = {
214236 User = user;
237+ Group = group;
215238 Type = "oneshot";
216− PermissionsStartOnly = true;
239+ # requires a relative directory name to create beneath /var/lib
240+ StateDirectory = user;
241+ StateDirectoryMode = 0750;
217242 ExecStart = "${pkgs.python3Packages.journalwatch}/bin/journalwatch mail";
218243 # lowest CPU and IO priority, but both still in best-effort class to prevent starvation
219244 Nice=19;
220245 IOSchedulingPriority=7;
221246 };
222− preStart = ''
223− chown -R ${user}:systemd-journal ${dataDir}
224− chmod -R u+rwX,go-w ${dataDir}
225− mkdir -p ${dataDir}/config/journalwatch
226− ln -sf ${journalwatchConfig} ${dataDir}/config/journalwatch/config
227− ln -sf ${journalwatchPatterns} ${dataDir}/config/journalwatch/patterns
228− '';
229247 };
230248
231249 systemd.timers.journalwatch = {