diff --git a/flake.nix b/flake.nix index e71e96a..675d46f 100644 --- a/flake.nix +++ b/flake.nix @@ -46,8 +46,8 @@ } ) // { - homeManagerModules.play = import ./modules/home-manager.nix; - nixosModules.play = import ./modules/nixos.nix; + homeManagerModules.play = import ./modules/home; + nixosModules.play = import ./modules/nixos; # Default module (home-manager) homeManagerModules.default = self.homeManagerModules.play; diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..4edd041 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,37 @@ +{ lib, ... }: +rec { + # Helper to convert Nix attrs to gamescope command-line arguments + toCliArgs = + attrs: + let + argToString = + name: value: + if builtins.isBool value then + lib.optionalString value "--${name}" + else + "--${name} ${toString value}"; + in + lib.concatStringsSep " " (lib.mapAttrsToList argToString attrs); + + # Helper to convert Nix attrs to fish 'set -x' commands + toEnvCommands = + attrs: + lib.concatStringsSep "\n" ( + lib.mapAttrsToList (name: value: "set -x ${name} '${toString value}'") attrs + ); + + getPrimaryMonitor = monitors: lib.findFirst (m: m.primary) null monitors; + + getMonitorDefaults = + monitors: + let + getPrimary = getPrimaryMonitor monitors; + in + { + WIDTH = if getPrimary != null then getPrimary.width else 1920; + HEIGHT = if getPrimary != null then getPrimary.height else 1080; + REFRESH_RATE = if getPrimary != null then getPrimary.refreshRate else 60; + VRR = if getPrimary != null then getPrimary.vrr else false; + HDR = if getPrimary != null then getPrimary.hdr else false; + }; +} diff --git a/lib/defualt.nix b/lib/defualt.nix deleted file mode 100644 index 97a59ac..0000000 --- a/lib/defualt.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ lib }: - -{ - # Helper to convert Nix attrs to gamescope command-line arguments - toCliArgs = - attrs: - let - argToString = - name: value: - if builtins.isBool value then - lib.optionalString value "--${name}" - else - "--${name} ${toString value}"; - in - lib.concatStringsSep " " (lib.mapAttrsToList argToString attrs); - - # Helper to convert Nix attrs to fish 'set -x' commands - toEnvCommands = - attrs: - lib.concatStringsSep "\n" ( - lib.mapAttrsToList (name: value: "set -x ${name} '${toString value}'") attrs - ); - - getPrimaryMonitor = monitors: lib.findFirst (m: m.primary) null monitors; - - getMonitorDefaults = monitors: { - WIDTH = - let - pm = lib.play.getPrimaryMonitor monitors; - in - if pm != null then pm.width else 1920; - HEIGHT = - let - pm = lib.play.getPrimaryMonitor monitors; - in - if pm != null then pm.height else 1080; - REFRESH_RATE = - let - pm = lib.play.getPrimaryMonitor monitors; - in - if pm != null then pm.refreshRate else 60; - VRR = - let - pm = lib.play.getPrimaryMonitor monitors; - in - if pm != null then pm.vrr else false; - HDR = - let - pm = lib.play.getPrimaryMonitor monitors; - in - if pm != null then pm.hdr else false; - }; -} diff --git a/modules/home/default.nix b/modules/home/default.nix index 2b262bb..f2218ab 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -4,3 +4,4 @@ ./gamescoperun.nix ./wrappers.nix ]; +} diff --git a/modules/home/gamescoperun.nix b/modules/home/gamescoperun.nix index 63bef27..0c5261f 100644 --- a/modules/home/gamescoperun.nix +++ b/modules/home/gamescoperun.nix @@ -7,10 +7,13 @@ }: let + # Extend lib with play utilities + playLib = import ../../lib { inherit lib; }; + cfg = config.play.gamescoperun; # Use shared lib functions - inherit (lib.play) toCliArgs toEnvCommands getMonitorDefaults; + inherit (playLib) toCliArgs toEnvCommands getMonitorDefaults; # Get monitor defaults monitorDefaults = getMonitorDefaults config.play.monitors; diff --git a/modules/home/wrapper.nix b/modules/home/wrappers.nix similarity index 96% rename from modules/home/wrapper.nix rename to modules/home/wrappers.nix index 2352970..1d844ff 100644 --- a/modules/home/wrapper.nix +++ b/modules/home/wrappers.nix @@ -6,10 +6,13 @@ }: let + # Extend lib with play utilities + playLib = import ../../lib { inherit lib; }; + cfg = config.play.wrappers; # Use shared lib function - inherit (lib.play) toCliArgs; + inherit (playLib) toCliArgs; # Function to create a wrapper for an application mkWrapper = diff --git a/pkgs/proton-cachyos/package.nix b/pkgs/proton-cachyos/default.nix similarity index 100% rename from pkgs/proton-cachyos/package.nix rename to pkgs/proton-cachyos/default.nix