Skip to content

Commit d683e55

Browse files
committed
validate config in home-manager
1 parent 2a76ff4 commit d683e55

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

nix/hm-modules.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ self: {
1212
${lib.optionalString cfg.systemd.enable systemdActivation}
1313
${cfg.autostart_sh}
1414
'';
15+
validatedConfig = pkgs.runCommand "mango-config.conf" { } ''
16+
cat > "$out" <<'EOF'
17+
${cfg.settings}
18+
EOF
19+
20+
output=$(${cfg.package}/bin/mango -c "$out" -p 2>&1 || true)
21+
22+
if echo "$output" | grep -Fq '[ERROR]:'; then
23+
echo "$output"
24+
exit 1
25+
fi
26+
'';
1527
in {
1628
options = {
1729
wayland.windowManager.mango = with lib; {
@@ -99,7 +111,7 @@ in {
99111
home.packages = [cfg.package];
100112
xdg.configFile = {
101113
"mango/config.conf" = lib.mkIf (cfg.settings != "") {
102-
text = cfg.settings;
114+
source = validatedConfig;
103115
};
104116
"mango/autostart.sh" = lib.mkIf (cfg.autostart_sh != "") {
105117
source = autostart_sh;

0 commit comments

Comments
 (0)