diff --git a/configs/fedora/home.nix b/configs/fedora/home.nix index 4298e5c..0b7b99a 100644 --- a/configs/fedora/home.nix +++ b/configs/fedora/home.nix @@ -6,9 +6,6 @@ ... }: -let - nixGL = import ./../../home-manager/utils/nixGLWrap.nix { inherit pkgs config; }; -in { imports = [ ./../../home-manager/modules/machine.nix ]; @@ -24,7 +21,5 @@ in nixpkgs.config.allowUnfree = true; - nixGLPrefix = lib.getExe pkgs.nixgl.nixGLIntel; - nix.settings.builders = "@/etc/nix/machines"; } diff --git a/home-manager/modules/machine.nix b/home-manager/modules/machine.nix index 90abc88..22f9e03 100644 --- a/home-manager/modules/machine.nix +++ b/home-manager/modules/machine.nix @@ -2,6 +2,7 @@ lib, pkgs, config, + inputs, ... }: with lib; @@ -81,6 +82,13 @@ with lib; news.display = "silent"; targets.genericLinux.enable = config.machine.isGeneric; + nixGL = { + packages = inputs.nixgl.packages; + defaultWrapper = "mesa"; + installScripts = ["mesa"]; + vulkan.enable = true; + }; + home = { username = "${config.machine.username}"; homeDirectory = "/home/${config.machine.username}"; diff --git a/home-manager/modules/packages.nix b/home-manager/modules/packages.nix index 27c4494..cdb67e9 100644 --- a/home-manager/modules/packages.nix +++ b/home-manager/modules/packages.nix @@ -8,7 +8,7 @@ with lib; let - nixGL = import ./../../home-manager/utils/nixGLWrap.nix { inherit pkgs config; }; + nixGL = config.lib.nixGL.wrap; electronFlags = "--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --disable-gpu-shader-disk-cache -n"; in { diff --git a/home-manager/programs/alacritty.nix b/home-manager/programs/alacritty.nix index 01e5308..97d48ad 100644 --- a/home-manager/programs/alacritty.nix +++ b/home-manager/programs/alacritty.nix @@ -6,7 +6,7 @@ }: let - nixGL = import ./../../home-manager/utils/nixGLWrap.nix { inherit pkgs config; }; + nixGL = config.lib.nixGL.wrap; in { programs.alacritty = { diff --git a/home-manager/programs/kitty.nix b/home-manager/programs/kitty.nix index 1132920..0e9a3b0 100644 --- a/home-manager/programs/kitty.nix +++ b/home-manager/programs/kitty.nix @@ -5,7 +5,7 @@ }: let - nixGL = import ./../../home-manager/utils/nixGLWrap.nix { inherit pkgs config; }; + nixGL = config.lib.nixGL.wrap; in { programs.kitty = { diff --git a/home-manager/utils/nixGLWrap.nix b/home-manager/utils/nixGLWrap.nix deleted file mode 100644 index e068d3d..0000000 --- a/home-manager/utils/nixGLWrap.nix +++ /dev/null @@ -1,36 +0,0 @@ -# Call once on import to load global context -{ pkgs, config }: -# Wrap a single package -pkg: -if config.nixGLPrefix == "" then - pkg -else - # Wrap the package's binaries with nixGL, while preserving the rest of - # the outputs and derivation attributes. - (pkg.overrideAttrs (old: { - name = "nixGL-${pkg.name}"; - buildCommand = '' - set -eo pipefail - - ${ - # Heavily inspired by https://stackoverflow.com/a/68523368/6259505 - pkgs.lib.concatStringsSep "\n" ( - map (outputName: '' - echo "Copying output ${outputName}" - set -x - cp -rs --no-preserve=mode "${pkg.${outputName}}" "''$${outputName}" - set +x - '') (old.outputs or [ "out" ]) - ) - } - - rm -rf $out/bin/* - shopt -s nullglob # Prevent loop from running if no files - for file in ${pkg.out}/bin/*; do - echo "#!${pkgs.bash}/bin/bash" > "$out/bin/$(basename $file)" - echo "exec -a \"\$0\" ${config.nixGLPrefix} $file \"\$@\"" >> "$out/bin/$(basename $file)" - chmod +x "$out/bin/$(basename $file)" - done - shopt -u nullglob # Revert nullglob back to its normal default state - ''; - }))