Files
home-manager/tests/modules/programs/alistral/mutable-settings.nix
Austin Horstman 0b5c5f1672 alistral: add opt-in mutable settings
Keep credentials and application configuration writable while applying
declared values. Seed the required token map and use the same Linux XDG
path in both modes, preserving the macOS location and existing home.file
overrides. Restore byte-identical files before linking read-only settings.
2026-10-04 20:17:45 -05:00

47 lines
1.4 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
relativePath =
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/alistral/config.json"
else
"custom-config/alistral/config.json";
in
{
xdg.configHome = "${config.home.homeDirectory}/custom-config";
programs.alistral = {
enable = true;
mutableSettings = true;
package = null;
settings.default_user = "test-user";
};
assertions = [
{
assertion = config.home.activation.alistralMutableSettings.after == [ "linkGeneration" ];
message = "Mutable alistral settings must run after linkGeneration.";
}
{
assertion = !(config.home.activation ? alistralImmutableSettings);
message = "Mutable alistral settings must not create immutable cleanup.";
}
{
assertion = !(lib.any (package: lib.getName package == "alistral") config.home.packages);
message = "A null alistral package must not be installed.";
}
];
nmt.script = ''
assertPathNotExists "home-files/${relativePath}"
assertFileContains activate "${config.home.homeDirectory}/${relativePath}"
assertFileContains activate "dynamic='{\"tokens\":{}}'"
input0="$(grep -o '/nix/store/[^ ]*-alistral-mutable-settings' "$TESTED/activate")" \
|| fail "alistral config.json input is missing from activation"
assertFileContent "$input0" ${./mutable-new-expected.json}
'';
}