prismlauncher: add module

This commit is contained in:
mikaeladev 2026-01-30 22:48:22 +00:00 committed by Austin Horstman
parent 6f64dee491
commit 04e5203db6
4 changed files with 192 additions and 0 deletions

View file

@ -0,0 +1,3 @@
{
prismlauncher-settings = ./settings.nix;
}

View file

@ -0,0 +1,65 @@
{
config,
lib,
pkgs,
...
}:
let
configPath = ".local/share/PrismLauncher/prismlauncher.cfg";
preexistingConfig = pkgs.writeText "preexisting.cfg" ''
[General]
ApplicationTheme=system
MaxMemAlloc=8192
MinMemAlloc=512
'';
expectedConfig = pkgs.writeText "expected.cfg" ''
[General]
ApplicationTheme=dark
MaxMemAlloc=8192
MinMemAlloc=512
ConsoleMaxLines=100000
ShowConsole=true
'';
activationScript = pkgs.writeScript "activation" config.home.activation.prismlauncherConfigActivation.data;
in
{
programs.prismlauncher = {
enable = true;
package = config.lib.test.mkStubPackage { };
settings = {
ApplicationTheme = "dark";
ShowConsole = true;
ConsoleMaxLines = 100000;
};
};
home.homeDirectory = lib.mkForce "/@TMPDIR@/hm-user";
nmt.script = ''
export HOME=$TMPDIR/hm-user
# write preexisting config
mkdir -p $HOME/.local/share/PrismLauncher
cat ${preexistingConfig} > $HOME/${configPath}
# run the activation script
substitute ${activationScript} $TMPDIR/activate --subst-var TMPDIR
chmod +x $TMPDIR/activate
$TMPDIR/activate
# validate the merged config
assertFileExists "$HOME/${configPath}"
assertFileContent "$HOME/${configPath}" "${expectedConfig}"
# test idempotence
$TMPDIR/activate
assertFileExists "$HOME/${configPath}"
assertFileContent "$HOME/${configPath}" "${expectedConfig}"
'';
}