-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathxmllint.nix
More file actions
48 lines (46 loc) · 915 Bytes
/
xmllint.nix
File metadata and controls
48 lines (46 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
config,
lib,
mkFormatterModule,
pkgs,
...
}:
let
cfg = config.programs.xmllint;
in
{
meta.maintainers = [ "andrea11" ];
imports = [
(mkFormatterModule {
name = "xmllint";
package = "libxml2";
includes = [
"*.xml"
"*.svg"
"*.xhtml"
"*.xsl"
"*.xslt"
"*.dtd"
"*.xsd"
];
})
];
config = lib.mkIf cfg.enable {
settings.formatter.xmllint = {
# xmllint doesn't format in place by default
command = pkgs.writeShellApplication {
name = "xmllint-wrapper";
text = ''
temp=$(mktemp)
trap 'rm "$temp"' EXIT
for file in "$@"; do
${lib.getExe' cfg.package "xmllint"} --format "$file" --output "$temp"
if ! cmp -s "$file" "$temp"; then
cp "$temp" "$file"
fi
done
'';
};
};
};
}