home(minecraft): run minecraft under dedicated user

This commit is contained in:
514fpv 2024-05-31 11:09:20 +08:00
parent 44ca762deb
commit debe03c516
Signed by: koishi
SSH key fingerprint: SHA256:axz0uIzzY+5W19i7QOUuiw5LSqhKfCBKPf3L4xFRxLw
2 changed files with 11 additions and 5 deletions

View file

@ -3,11 +3,10 @@
, config
, ... }: with lib; let
cfg = config.home.minecraft;
persist = [ ".local/share/PrismLauncher" ];
gui = with config.global.gpu; enable && session;
in {
options.home.minecraft = {
enable = mkEnableOption "minecraft game launcher and jvm";
allUsers = mkEnableOption "set up for all users";
};
config = {
@ -16,7 +15,14 @@ in {
{ passthrough.minecraft = cfg; }
];
users.home.persist.directories = with cfg; mkIf (enable && allUsers) persist;
users.home.persistApp.directories = with cfg; mkIf (enable && !allUsers) persist;
users.profiles.minecraft = mkIf cfg.enable {
uid = 5801;
description = "Minecraft";
picture = ../picture/aux.png;
};
environment.persistence."/nix/persist".users.minecraft.directories = mkIf (cfg.enable && gui) [
".local/share/PrismLauncher"
];
};
}