|
15 | 15 | unwrapped = logwatch-unwrapped; |
16 | 16 |
|
17 | 17 | mkCustomService = |
18 | | - { |
19 | | - name, |
20 | | - title ? null, |
21 | | - output ? "cat", |
22 | | - unit ? null, |
23 | | - script ? null, |
24 | | - preIgnore ? null, |
25 | | - extraConfig ? "", |
26 | | - extraFixup ? "", |
27 | | - }: |
28 | | - let |
29 | | - serviceConf = writeTextDir "conf/services/${name}.conf" '' |
30 | | - ${lib.optionalString (title != null) ''Title = "${title}"''} |
31 | | - LogFile = |
32 | | - LogFile = none |
33 | | - *JournalCtl = "--output=${output} --unit=${if unit != null then unit else "${name}.service"}" |
34 | | - ${lib.optionalString (preIgnore != null) ''Pre_Ignore = "${preIgnore}"''} |
35 | | - ${extraConfig} |
36 | | - ''; |
37 | | - serviceScript = runCommandLocal "logwatch-${name}-script" { } '' |
38 | | - mkdir -p $out/scripts/services |
39 | | - cp ${if (script != null) then script else "${unwrapped}/usr/share/logwatch/scripts/services/${name}"} $out/scripts/services/${name} |
| 18 | + { |
| 19 | + name, |
| 20 | + title ? null, |
| 21 | + output ? "cat", |
| 22 | + unit ? null, |
| 23 | + script ? null, |
| 24 | + preIgnore ? null, |
| 25 | + extraConfig ? "", |
| 26 | + extraFixup ? "", |
| 27 | + }: |
| 28 | + let |
| 29 | + serviceConf = writeTextDir "conf/services/${name}.conf" '' |
| 30 | + ${lib.optionalString (title != null) ''Title = "${title}"''} |
| 31 | + LogFile = |
| 32 | + LogFile = none |
| 33 | + *JournalCtl = "--output=${output} --unit=${if unit != null then unit else "${name}.service"}" |
| 34 | + ${lib.optionalString (preIgnore != null) ''Pre_Ignore = "${preIgnore}"''} |
| 35 | + ${extraConfig} |
| 36 | + ''; |
| 37 | + serviceScript = runCommandLocal "logwatch-${name}-script" { } '' |
| 38 | + mkdir -p $out/scripts/services |
| 39 | + cp ${ |
| 40 | + if (script != null) then script else "${unwrapped}/usr/share/logwatch/scripts/services/${name}" |
| 41 | + } $out/scripts/services/${name} |
40 | 42 |
|
41 | | - eval ${extraFixup} |
42 | | - ''; |
43 | | - in |
| 43 | + eval ${extraFixup} |
| 44 | + ''; |
| 45 | + in |
44 | 46 | symlinkJoin { |
45 | 47 | name = "logwatch-${name}"; |
46 | 48 | paths = [ |
|
49 | 51 | ]; |
50 | 52 | }; |
51 | 53 |
|
52 | | - mkConfFile = config: |
53 | | - writeTextDir "conf/logwatch.conf" ('' |
54 | | - TmpDir = /tmp |
55 | | - mailer = ${config.mailer} |
56 | | - Archives = ${if config.archives then "Yes" else "No"} |
57 | | - MailTo = ${config.mailto} |
58 | | - MailFrom = ${config.mailfrom} |
59 | | - Range = ${config.range} |
60 | | - Detail = ${config.detail} |
61 | | - '' |
62 | | - + lib.concatMapStrings (s: "Service = ${s}\n") config.services); |
| 54 | + mkConfFile = |
| 55 | + config: |
| 56 | + writeTextDir "conf/logwatch.conf" ( |
| 57 | + '' |
| 58 | + TmpDir = /tmp |
| 59 | + mailer = ${config.mailer} |
| 60 | + Archives = ${if config.archives then "Yes" else "No"} |
| 61 | + MailTo = ${config.mailto} |
| 62 | + MailFrom = ${config.mailfrom} |
| 63 | + Range = ${config.range} |
| 64 | + Detail = ${config.detail} |
| 65 | + '' |
| 66 | + + lib.concatMapStrings (s: "Service = ${s}\n") config.services |
| 67 | + ); |
63 | 68 |
|
64 | 69 | customConfig = symlinkJoin { |
65 | 70 | name = "logwatch-config"; |
66 | 71 | paths = [ |
67 | 72 | (map mkCustomService customServices) |
68 | | - ] ++ lib.optionals (extraConfig != null) [ |
| 73 | + ] |
| 74 | + ++ lib.optionals (extraConfig != null) [ |
69 | 75 | (mkConfFile extraConfig) |
70 | 76 | ]; |
71 | 77 | }; |
72 | 78 |
|
73 | | - wrapper = runCommandLocal "${unwrapped.name}-wrapped" { |
74 | | - nativeBuildInputs = [ makeWrapper ]; |
| 79 | + wrapper = |
| 80 | + runCommandLocal "${unwrapped.name}-wrapped" |
| 81 | + { |
| 82 | + nativeBuildInputs = [ makeWrapper ]; |
75 | 83 |
|
76 | | - passthru = { |
77 | | - inherit unwrapped; |
78 | | - }; |
| 84 | + passthru = { |
| 85 | + inherit unwrapped; |
| 86 | + }; |
79 | 87 |
|
80 | | - meta.mainProgram = "logwatch"; |
81 | | - } '' |
82 | | - makeWrapper ${unwrapped}/bin/logwatch $out/bin/logwatch \ |
83 | | - --prefix PERL5LIB : "${perlPackages.makePerlPath extraPerl5Lib}" \ |
84 | | - --prefix PATH : "${lib.makeBinPath extraPath}" \ |
85 | | - --set NIX_LOGWATCH_CONF_PATH ${customConfig} |
86 | | - ''; |
| 88 | + meta.mainProgram = "logwatch"; |
| 89 | + } |
| 90 | + '' |
| 91 | + makeWrapper ${unwrapped}/bin/logwatch $out/bin/logwatch \ |
| 92 | + --prefix PERL5LIB : "${perlPackages.makePerlPath extraPerl5Lib}" \ |
| 93 | + --prefix PATH : "${lib.makeBinPath extraPath}" \ |
| 94 | + --set NIX_LOGWATCH_CONF_PATH ${customConfig} |
| 95 | + ''; |
87 | 96 | in |
88 | 97 | wrapper |
0 commit comments