Refactors for module imports and lib utilities
- Updates import paths in flake to correct locations - Rename lib file correctly
This commit is contained in:
parent
38beb52fe5
commit
5df8547c98
7 changed files with 48 additions and 57 deletions
|
@ -46,8 +46,8 @@
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// {
|
// {
|
||||||
homeManagerModules.play = import ./modules/home-manager.nix;
|
homeManagerModules.play = import ./modules/home;
|
||||||
nixosModules.play = import ./modules/nixos.nix;
|
nixosModules.play = import ./modules/nixos;
|
||||||
|
|
||||||
# Default module (home-manager)
|
# Default module (home-manager)
|
||||||
homeManagerModules.default = self.homeManagerModules.play;
|
homeManagerModules.default = self.homeManagerModules.play;
|
||||||
|
|
37
lib/default.nix
Normal file
37
lib/default.nix
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
|
@ -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;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -4,3 +4,4 @@
|
||||||
./gamescoperun.nix
|
./gamescoperun.nix
|
||||||
./wrappers.nix
|
./wrappers.nix
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
|
@ -7,10 +7,13 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# Extend lib with play utilities
|
||||||
|
playLib = import ../../lib { inherit lib; };
|
||||||
|
|
||||||
cfg = config.play.gamescoperun;
|
cfg = config.play.gamescoperun;
|
||||||
|
|
||||||
# Use shared lib functions
|
# Use shared lib functions
|
||||||
inherit (lib.play) toCliArgs toEnvCommands getMonitorDefaults;
|
inherit (playLib) toCliArgs toEnvCommands getMonitorDefaults;
|
||||||
|
|
||||||
# Get monitor defaults
|
# Get monitor defaults
|
||||||
monitorDefaults = getMonitorDefaults config.play.monitors;
|
monitorDefaults = getMonitorDefaults config.play.monitors;
|
||||||
|
|
|
@ -6,10 +6,13 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# Extend lib with play utilities
|
||||||
|
playLib = import ../../lib { inherit lib; };
|
||||||
|
|
||||||
cfg = config.play.wrappers;
|
cfg = config.play.wrappers;
|
||||||
|
|
||||||
# Use shared lib function
|
# Use shared lib function
|
||||||
inherit (lib.play) toCliArgs;
|
inherit (playLib) toCliArgs;
|
||||||
|
|
||||||
# Function to create a wrapper for an application
|
# Function to create a wrapper for an application
|
||||||
mkWrapper =
|
mkWrapper =
|
Loading…
Add table
Reference in a new issue