nixos/mpd: use pkgs.writeTextFile, with a checkPhase

This commit is contained in:
Doron Behar
2025-12-05 15:39:08 +02:00
parent 4b9430a629
commit 0d168edb28
+24 -1
View File
@@ -24,7 +24,9 @@ let
lib.concatStringsSep "\n" placeholders
);
mpdConf = pkgs.writeText "mpd.conf" ''
mpdConf = pkgs.writeTextFile {
name = "mpd.conf";
text = ''
# This file was automatically generated by NixOS. Edit mpd's configuration
# via NixOS' configuration.nix, as this file will be rewritten upon mpd's
# restart.
@@ -48,6 +50,27 @@ let
${cfg.extraConfig}
'';
derivationArgs = {
expectScript = ''
spawn ${lib.getExe pkgs.buildPackages.mpd} --no-daemon "$env(out)"
expect {
"exception: Error in \"$env(out)\"" {
puts "Config file invalid\n"
exit 1
}
"exception:" {
exit 0
}
}
'';
passAsFile = [
"expectScript"
];
};
checkPhase = ''
${lib.getExe pkgs.buildPackages.expect} -f "$expectScriptPath"
'';
};
in
{