git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #59424 from florianjacob/journalwatch

journalwatch: fix broken package, general maintenance

commit8d64ec7a17a14f16073578c9e56d42b457e17d0d authorAaron Andersen <aaron@fosslib.net> dateSat 27 Apr 2019, 10:58 (8 years ago) parentd15be44e916cdf
2 files changed+38−24
nixos/modules/services/logging/journalwatch.nix+30−12 pkgs/tools/system/journalwatch/default.nix+8−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 = {
pkgs/tools/system/journalwatch/default.nix+8−12
@@ -1,15 +1,15 @@
1−{ stdenv, buildPythonPackage, fetchurl, pythonOlder, systemd, pytest }:
1+{ stdenv, buildPythonPackage, fetchFromGitHub, pythonOlder, systemd, pytest }:
22
33buildPythonPackage rec {
44 pname = "journalwatch";
5− name = "${pname}-${version}";
65 version = "1.1.0";
76 disabled = pythonOlder "3.3";
87
9−
10− src = fetchurl {
11− url = "https://github.com/The-Compiler/${pname}/archive/v${version}.tar.gz";
12− sha512 = "3hvbgx95hjfivz9iv0hbhj720wvm32z86vj4a60lji2zdfpbqgr2b428lvg2cpvf71l2xn6ca5v0hzyz57qylgwqzgfrx7hqhl5g38s";
8+ src = fetchFromGitHub {
9+ owner = "The-Compiler";
10+ repo = pname;
11+ rev = "v${version}";
12+ sha512 = "11g2f1w9lfqw6zxxyg7qrqpb914s6w71j0gnpw7qr7cak2l5jlf2l39dlg30y55rw7jgmf0yg77wwzd0c430mq1n6q1v8w86g1rwkzb";
1313 };
1414
1515 # can be removed post 1.1.0
@@ -20,14 +20,10 @@ buildPythonPackage rec {
2020
2121
2222 doCheck = true;
23−
23+ checkInputs = [ pytest ];
2424 checkPhase = ''
25− pytest test_journalwatch.py
26− '';
27−
28− buildInputs = [
2925 pytest
30− ];
26+ '';
3127
3228 propagatedBuildInputs = [
3329 systemd