Skip to content

Commit 7541238

Browse files
committed
nixfmt
1 parent 12160f3 commit 7541238

4 files changed

Lines changed: 74 additions & 64 deletions

File tree

‎default.nix‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
final: prev: {
22
logwatch-unwrapped = final.callPackage ./packages/logwatch-unwrapped/package.nix { };
3-
logwatch = final.callPackage ./packages/logwatch/package.nix { inherit (final) logwatch-unwrapped; };
3+
logwatch = final.callPackage ./packages/logwatch/package.nix {
4+
inherit (final) logwatch-unwrapped;
5+
};
46

57
logwatch-scripts = final.lib.makeScope final.newScope (self: {
68
passthrough = self.callPackage ./packages/logwatch-scripts/passthrough.nix { };

‎modules/logwatch.nix‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let
1919
range
2020
detail
2121
services
22-
;
22+
;
2323
};
2424

2525
defaultPackage = pkgs.callPackage ../packages/logwatch/package.nix {

‎packages/logwatch-unwrapped/package.nix‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,20 @@ stdenvNoCC.mkDerivation {
8484
--prefix PERL5LIB : "${
8585
with perlPackages;
8686
makePerlPath [
87-
DateManip
88-
HTMLParser
89-
SysCPU
90-
SysMemInfo
91-
]
87+
DateManip
88+
HTMLParser
89+
SysCPU
90+
SysMemInfo
91+
]
9292
}" \
9393
--prefix PATH : "${
94-
lib.makeBinPath
95-
[
96-
gnugrep
97-
net-tools
98-
gzip
99-
bzip2
100-
xz
101-
]
94+
lib.makeBinPath [
95+
gnugrep
96+
net-tools
97+
gzip
98+
bzip2
99+
xz
100+
]
102101
}" \
103102
--set pathto_ifconfig "${lib.getExe' net-tools "ifconfig"}"
104103
'';

‎packages/logwatch/package.nix‎

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,34 @@ let
1515
unwrapped = logwatch-unwrapped;
1616

1717
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}
4042
41-
eval ${extraFixup}
42-
'';
43-
in
43+
eval ${extraFixup}
44+
'';
45+
in
4446
symlinkJoin {
4547
name = "logwatch-${name}";
4648
paths = [
@@ -49,40 +51,47 @@ let
4951
];
5052
};
5153

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+
);
6368

6469
customConfig = symlinkJoin {
6570
name = "logwatch-config";
6671
paths = [
6772
(map mkCustomService customServices)
68-
] ++ lib.optionals (extraConfig != null) [
73+
]
74+
++ lib.optionals (extraConfig != null) [
6975
(mkConfFile extraConfig)
7076
];
7177
};
7278

73-
wrapper = runCommandLocal "${unwrapped.name}-wrapped" {
74-
nativeBuildInputs = [ makeWrapper ];
79+
wrapper =
80+
runCommandLocal "${unwrapped.name}-wrapped"
81+
{
82+
nativeBuildInputs = [ makeWrapper ];
7583

76-
passthru = {
77-
inherit unwrapped;
78-
};
84+
passthru = {
85+
inherit unwrapped;
86+
};
7987

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+
'';
8796
in
8897
wrapper

0 commit comments

Comments
 (0)