diff --git a/flake.nix b/flake.nix index a541e15..fb4aba8 100644 --- a/flake.nix +++ b/flake.nix @@ -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; diff --git a/home/home.nix b/home/home.nix index e83cce9..0c676a5 100644 --- a/home/home.nix +++ b/home/home.nix @@ -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 diff --git a/home/modules/programs/prism-launcher/default.nix b/home/modules/programs/prism-launcher/default.nix new file mode 100644 index 0000000..7039d02 --- /dev/null +++ b/home/modules/programs/prism-launcher/default.nix @@ -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; + }; + }; + }; +} diff --git a/home/packages.nix b/home/packages.nix index a2cee09..632b327 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -161,9 +161,6 @@ ] ++ lib.optionals (machineVars.gaming) [ desmume osu-lazer - (prismlauncher.override { - jdk17 = jdk21; - }) retroarchFull steam steam-tui diff --git a/home/programs/prism-launcher.nix b/home/programs/prism-launcher.nix new file mode 100644 index 0000000..1c54f9d --- /dev/null +++ b/home/programs/prism-launcher.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: +{ + programs.prism-launcher = { + enable = true; + + package = pkgs.prismlauncher.override { + jdk17 = pkgs.jdk21; + }; + + screenshotMover.enable = true; + }; +}