diff --git a/README.md b/README.md index ff38427..157c982 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,22 @@ The goal of this project is to provide Shadow on NixOS with a dynamic derivation ### Install +Note that the ref value (`drv-v*.*.*`) should point to the lastest release. Checkout the tags to know it. + +If you want the latest package derivation, use `ref = "master"` instead. + #### As a home-manager package In your `home.nix` : -``` +```nix imports = [ - (fetchGit { url = "https://github.com/Elyhaka/shadow-nix"; ref = "drv-v0.12.0"; } + "/home-manager.nix") + (fetchGit { url = "https://github.com/Elyhaka/shadow-nix"; ref = "drv-v0.14.0"; } + "/home-manager.nix") ]; programs.shadow-client = { enable = true; - channel = "preprod"; + channel = "preprod"; }; ``` @@ -27,14 +31,14 @@ programs.shadow-client = { In your `configuration.nix` : -``` +```nix imports = [ - (fetchGit { url = "https://github.com/Elyhaka/shadow-nix"; ref = "drv-v0.12.0"; } + "/system.nix") + (fetchGit { url = "https://github.com/Elyhaka/shadow-nix"; ref = "drv-v0.14.0"; } + "/system.nix") ]; programs.shadow-client = { - enable = true; - channel = "prod"; + enable = true; + channel = "prod"; }; ``` @@ -45,7 +49,8 @@ programs.shadow-client = { - `enableDiagnostics` : `bool` / default `false` : The command used to execute the client will be output in a file in /tmp. The client will output its strace in /tmp. This is mainly used for diagnostics purposes (when an update breaks something). - `provideXSession` : `bool` / default `false` (requires system mode) : Provides a XSession desktop file for Shadow Launcher. Useful if you want to autostart it without any DE/WM. - `preferredScreens` : `bool` / default `[]` : Name of preferred screens, ordered by name. If one screen currently plugged matches the listed screens in this options, it shutdowns all other screens. This feature use xrandr, thus you must use xrandr screen names. This can be useful for laptops with changing multi-heads setups. - - `disableAmdFix` : `bool` / default `false` : When the amdgpu driver is detected, the drirc fix is applied automatically. Enabling this option force disable the fix. + - `forceDriver` : `enum` / default `""` : Force the VA driver used by Shadow using the LIBVA_DRIVER_NAME environment variable. + - `disableGpuFix` : `bool` / default `false` : Disable the GPU fixes for Shadow related to the color bit size. ## A word on vaapi @@ -57,7 +62,7 @@ It is important to have `vaapi` enabled to make Shadow works correctly. You can The following example should work for both AMD and Intel GPU. This is just an example, there is no guarantee that it will work. -``` +```nix # Provides the `vainfo` command environment.systemPackages = with pkgs; [ libva-utils ]; @@ -81,5 +86,5 @@ hardware.opengl = { ## I want to add an option - - Issues and PR are welcome ! I'll do my best to make this works for everyone ! + - Issues and PR are welcome! I'll do my best to make this works for everyone! diff --git a/cfg.nix b/cfg.nix index f6fe64f..f18543a 100644 --- a/cfg.nix +++ b/cfg.nix @@ -40,7 +40,7 @@ with lib; preferredScreens = mkOption { type = types.listOf (types.str); - default = []; + default = [ ]; example = [ "HDMI1" ]; description = '' Name of preferred screens, ordered by name. If one screen currently plugged matches @@ -69,15 +69,22 @@ with lib; ''; }; - disableAmdFix = mkOption { + forceDriver = mkOption { + type = types.enum [ "" "iHD" "i965" "radeon" "radeonsi" ]; + default = ""; + example = "iHD"; + description = '' + Force the VA driver used by Shadow using the LIBVA_DRIVER_NAME environment variable. + ''; + }; + + disableGpuFix = mkOption { type = types.bool; default = false; example = true; description = '' - When the amdgpu driver is detected, the drirc fix is - applied automatically. Enabling this option force disable the - fix. + Disable the GPU fixes for Shadow related to the color bit size. ''; }; }; -} \ No newline at end of file +} diff --git a/system.nix b/system.nix index 2cfdfcd..3ca7acf 100644 --- a/system.nix +++ b/system.nix @@ -5,12 +5,14 @@ with lib; let cfg = config.programs.shadow-client; + # Declare the package with the appropriate configuration shadow-package = pkgs.callPackage ./shadow-package.nix { shadowChannel = cfg.channel; enableDiagnostics = cfg.enableDiagnostics; desktopLauncher = cfg.enableDesktopLauncher; }; + # Declare the wrapper with the appropriate configuration shadow-wrapped = pkgs.callPackage ./wrapper.nix { shadow-package = shadow-package; @@ -19,28 +21,31 @@ let xsessionDesktopFile = cfg.provideXSession; launchArgs = cfg.launchArgs; }; -in -{ + + # Drirc file + drirc = (fetchGit { + url = "https://github.com/NicolasGuilloux/blade-shadow-beta"; + ref = "master"; + } + "/resources/drirc"); +in { + # Import the configuration imports = [ ./cfg.nix ]; config = mkIf cfg.enable { + # Install Shadow wrapper environment.systemPackages = [ shadow-wrapped ]; + # Add Shadow session services.xserver.displayManager.sessionPackages = mkIf cfg.provideXSession [ shadow-wrapped ]; - environment.etc = mkIf (!cfg.disableAmdFix && (any (s: s == "amdgpu") config.services.xserver.videoDrivers)) { - "drirc" = { - text = '' - - - - - - - ''; - }; + # Add GPU fixes + environment.etc."drirc" = mkIf (!cfg.disableGpuFix) { + source = drirc; + }; + + # Force VA Driver + environment.variables = mkIf (cfg.forceDriver != "") { + LIBVA_DRIVER_NAME = [cfg.forceDriver]; }; }; }