From 8b9eb54806f5621cdddf7c602e5d94f4251b5e1e Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Mon, 26 Jul 2021 20:43:52 +0200 Subject: [PATCH] games: Conditionally add emulators This uses a crude arbitrary number to only install them onto machines that can actually run them. --- machines/nunotaba/configuration.nix | 5 ++++- machines/sayuri/configuration.nix | 5 ++++- modules/default.nix | 17 ++++++++++++++++- modules/unfree.nix | 2 ++ users/simon/modules/games.nix | 14 +++++++++++--- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/machines/nunotaba/configuration.nix b/machines/nunotaba/configuration.nix index f027576..6df941f 100644 --- a/machines/nunotaba/configuration.nix +++ b/machines/nunotaba/configuration.nix @@ -8,7 +8,10 @@ ]; sbruder = { - games.enable = true; + games = { + enable = true; + performanceIndex = 2; + }; gui.enable = true; media-proxy.enable = true; mullvad.enable = true; diff --git a/machines/sayuri/configuration.nix b/machines/sayuri/configuration.nix index 47f69b4..293d680 100644 --- a/machines/sayuri/configuration.nix +++ b/machines/sayuri/configuration.nix @@ -8,7 +8,10 @@ ]; sbruder = { - games.enable = true; + games = { + enable = true; + performanceIndex = 8; + }; gui.enable = true; media-proxy.enable = true; mullvad.enable = true; diff --git a/modules/default.nix b/modules/default.nix index abaa67c..9353dac 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -12,7 +12,22 @@ default = true; }; gui.enable = lib.mkEnableOption "gui"; - games.enable = lib.mkEnableOption "games"; + games = { + enable = lib.mkEnableOption "games"; + performanceIndex = lib.mkOption { + type = lib.types.int; + description = '' + Arbitrary number specifying how powerful the machine is. To be + replaced by taking into account single- and multi-core CPU and GPU + metrics separately should this system not map to my machines in + practice. + + * 2: ~ 2014 ultrabook + * 8: ~ 2016 quad-core workstation with mid-range GPU + ''; + default = 1; + }; + }; }; # All modules are imported but non-essential modules are activated by diff --git a/modules/unfree.nix b/modules/unfree.nix index 1d822b3..040cd33 100644 --- a/modules/unfree.nix +++ b/modules/unfree.nix @@ -25,6 +25,8 @@ in "corefonts" "vista-fonts" "wallpaper-unfree" # defined in users/simon/modules/sway.nix + "yuzu-ea" + "yuzu-mainline" # derivation of icons is not allowed ] ++ lib.optionals cfg.allowSoftware [ "cups-kyocera-ecosys-m552x-p502x" # exception: the file header says MIT license, but explicitly forbids modifications WTF? "drone-runner-exec" # exception: same as drone.io diff --git a/users/simon/modules/games.nix b/users/simon/modules/games.nix index e119cb7..babe6cb 100644 --- a/users/simon/modules/games.nix +++ b/users/simon/modules/games.nix @@ -1,5 +1,13 @@ { lib, nixosConfig, pkgs, ... }: -lib.mkIf nixosConfig.sbruder.games.enable { - home.packages = [ ] - ++ lib.optional nixosConfig.sbruder.unfree.allowSoftware pkgs.unstable.osu-lazer-sandbox; +let + cfg = nixosConfig.sbruder.games; + inherit (nixosConfig.sbruder) unfree; +in +lib.mkIf cfg.enable { + home.packages = with pkgs; [ ] + ++ lib.optionals (cfg.performanceIndex >= 4) [ + desmume + dolphinEmuMaster + ] ++ lib.optional (unfree.allowAssets && cfg.performanceIndex >= 8) unstable.yuzu-ea + ++ lib.optional unfree.allowSoftware unstable.osu-lazer-sandbox; }