home/modules/prism-launcher: init

This commit is contained in:
2025-04-03 19:17:46 +02:00
parent 4d21a1325c
commit f929d267ba
5 changed files with 76 additions and 3 deletions

View File

@@ -150,6 +150,7 @@
neovim-auto-clean-swapfiles = ./home/modules/programs/neovim/auto-clean-swapfiles.nix;
newsboat = ./home/modules/programs/newsboat;
nix-index-auto-update-database = ./home/modules/programs/nix-index/auto-update-database.nix;
prism-launcher = ./home/modules/programs/prism-launcher;
shellAliases = ./home/modules/shellAliases.nix;
systemd-tmpfiles = ./home/modules/systemd-tmpfiles.nix;
uidGid = ./home/modules/uidGid.nix;

View File

@@ -57,6 +57,7 @@ in {
./programs/ncmpcpp.nix
./programs/newsboat
./programs/obs-studio.nix
./programs/prism-launcher.nix
./programs/qutebrowser.nix
./programs/rofi
./programs/taskwarrior.nix

View File

@@ -0,0 +1,62 @@
{ config, pkgs, lib, ... }:
let
cfg = config.programs.prism-launcher;
screenshotPathGlob = "${config.xdg.dataHome}/PrismLauncher/instances/*/.minecraft/screenshots";
in
{
options.programs.prism-launcher = {
enable = lib.mkEnableOption "PrismLauncher, an open source minecraft launcher";
package = lib.mkPackageOption pkgs "prismlauncher" { };
screenshotMover = {
enable = lib.mkEnableOption "a systemd unit that automatically moves screenshots from all minecraft instances into a common dir";
screenshotDir = lib.mkOption {
description = "Where to move the minecraft screenshots.";
type = lib.types.path;
# TODO: priority list:
# - userDirs pictures
# - homeDir Pictures
default = "${config.xdg.userDirs.pictures}/prismlauncher-screenshots";
# TODO: Literal expression for default
example = lib.literalExpression ''
"''${config.home.homeDirectory}/minecraftScreenshots"
'';
};
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
systemd.user.paths.prismlauncher-move-minecraft-screenshots = lib.mkIf cfg.screenshotMover.enable {
Install.WantedBy = [ "paths.target" ];
Unit.Description = "Watchdog that moves screenshots from all prismlauncher minecraft instances into a common dir";
Path = {
PathChanged = [ screenshotPathGlob ];
Unit = "prismlauncher-move-minecraft-screenshots.service";
TriggerLimitIntervalSec = "1s";
TriggerLimitBurst = "1";
};
};
systemd.user.services.prismlauncher-move-minecraft-screenshots = lib.mkIf cfg.screenshotMover.enable {
Unit.Description = "Watchdog that moves screenshots from all prismlauncher minecraft instances into a common dir";
Service = {
Type = "oneshot";
# TODO: expand glob inside a shell
ExecStart = "${pkgs.coreutils}/bin/mv ${screenshotPathGlob} '${cfg.screenshotMover.screenshotDir}'";
PrivateUsers = true;
ProtectSystem = true;
NoNewPrivileges = true;
ProtectKernelTunables = true;
ProtectControlGroups = true;
RestrictAddressFamilies = [ ];
RestrictNamespaces = true;
};
};
};
}

View File

@@ -161,9 +161,6 @@
] ++ lib.optionals (machineVars.gaming) [
desmume
osu-lazer
(prismlauncher.override {
jdk17 = jdk21;
})
retroarchFull
steam
steam-tui

View File

@@ -0,0 +1,12 @@
{ pkgs, ... }:
{
programs.prism-launcher = {
enable = true;
package = pkgs.prismlauncher.override {
jdk17 = pkgs.jdk21;
};
screenshotMover.enable = true;
};
}