Symlinking from custom NVIDIA driver to Home

I’m trying to copy the nvngx.dll and _nvngx.dll files from the NVIDIA proprietary driver to my home. These files are defined in the nvidia-x11 package at nixpkgs/pkgs/os-specific/linux/nvidia-x11/builder.sh at 4a92571f9207810b559c9eac203d1f4d79830073 · NixOS/nixpkgs · GitHub.

I would like a symlink to these files to be created at .xlcore/wineprefix/drive_c/windows/system32/. I am attempting this using Home Manager with the following:

home = {
  file.".xlcore/wineprefix/drive_c/windows/system32/nvngx.dll" = {
    source = "${pkgs.linuxKernel.packages.linux_6_10.nvidia_x11}/lib/nvidia/wine/nvngx.dll";
  };

  file.".xlcore/wineprefix/drive_c/windows/system32/_nvngx.dll" = {
    source = "${pkgs.linuxKernel.packages.linux_6_10.nvidia_x11}/lib/nvidia/wine/_nvngx.dll";
  };
};

However, this creates a new NVIDIA driver derivation which fails to compile. The problem is that I have a custom NVIDIA driver defined as:

hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
  version = "555.58.02";
  sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
  sha256_aarch64 = lib.fakeSha256;
  openSha256 = lib.fakeSha256;
  settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
  persistencedSha256 = lib.fakeSha256;
};

How can I reference this custom package within my Home Manager config?

You can use the NixOS config with home-manager like this:

# configuration.nix or any other **NixOS** module
{ config, ... }:
{
  home-manager.users.<username> = {
    home = {
      file.".xlcore/wineprefix/drive_c/windows/system32/nvngx.dll" = {
        source = "${config.hardware.nvidia.package}/lib/nvidia/wine/nvngx.dll";
      };

      file.".xlcore/wineprefix/drive_c/windows/system32/_nvngx.dll" = {
        source = "${config.hardware.nvidia.package}/lib/nvidia/wine/_nvngx.dll";
      };
    };
  };
}

If I put that in home.nix, I get

 error: attribute 'hardware' missing
       at /nix/store/prr19n0mlpqhcjygrs7gc8xax4ck7kbg-source/home.nix:11:45:
           10|   file.".xlcore/ffxiv/game/nvngx.dll" = "${config.hardware.nvidia.package}/lib/nvidia/wine/nvngx.dll";
           11|   file.".xlcore/ffxiv/game/_nvngx.dll" = "${config.hardware.nvidia.package}/lib/nvidia/wine/_nvngx.dll";
             |                                             ^
           12|

In configuration.nix I get:

error: The option `home-manager.users.<username>.file' does not exist. Definition values:
       - In `/nix/store/79yrhaxq3iirbgq5p0wabdv35ka0r60z-source/configuration.nix':
           {
             ".xlcore/ffxiv/game/_nvngx.dll" = "/nix/store/h1z8llqf8ar745ncf0hwdx0fcrildrag-nvidia-x11-555.58.02-6.10.4/lib/nvidia/wine/_nvngx.dll";
             ".xlcore/ffxiv/game/nvngx.dll" = "/nix/store/h1z8llqf8ar745ncf0hwdx0fcrildrag-nvidia-x11-555.58.02-6.10.4/lib/nvidia/wine/nvngx.dll";
           }

config for home-manager is not the same as the NixOS config.

hardware.nvidia is a NixOS module, so we must use the NixOS config to reference it. That’s why you shouldn’t put this in home.nix.

Well, yeah, you should replace <username> with your actual username for home-manager.

I replaced my actual username with <username> for the purpose of the post (I apologise, I should’ve made that clearer), it’s correct in the config but that’s the error I get.

It’s alright. How did you install home-manager? Is it not a NixOS module?

Using the Flake setup, which I’d link if GitHub wasn’t down

Is it like this Home Manager Manual ?

Yes, that, pointing to a home.nix file in the same directory.

Wait, this needs to be home-manager.users.<username>.home.file. You have a home missing before file.

That’s true, but JFYI NixOS config is accessible in home manager modules as osConfig argument (moar details in this issue).

2 Likes

Oh, I didn’t know that. That’s pretty useful, thanks!

Ah, sorry, forgot to update this thread.

This is the home.nix config that ended up working for me:

{ pkgs, osConfig, ... }:

let
  dxvk-nvapi = pkgs.fetchzip {
    url = "https://github.com/jp7677/dxvk-nvapi/releases/download/v0.7.1/dxvk-nvapi-v0.7.1.tar.gz";
    sha256 = "076sjchv308zc7fv6mrdph2kd8w5nvgrqjc4acmgpwj3s7v85yjv";
    stripRoot = false;
  };

  dlsstweaks = pkgs.fetchzip {
    url = "https://github.com/emoose/DLSSTweaks/files/15013420/DLSSTweaks-0.200.9.0-beta1.zip";
    sha256 = "19w5kjgy5zayp02mz5rv5g91r31ix5rm1m95qwlxfrp9gbag9dh2";
    stripRoot = false;
  };
in
{
  home = {
    homeDirectory = "/home/<username>";
    stateVersion = "24.05";
    username = "<username>";

    # DXVK-NVAPI
    file.".xlcore/wineprefix/drive_c/windows/system32/nvapi64.dll".source = "${dxvk-nvapi}/x64/nvapi64.dll";
    file.".xlcore/wineprefix/drive_c/windows/syswow64/nvapi.dll".source = "${dxvk-nvapi}/x32/nvapi.dll";
    file.".xlcore/ffxiv/game/nvngx.dll".source = "${osConfig.hardware.nvidia.package}/lib/nvidia/wine/nvngx.dll";
    file.".xlcore/ffxiv/game/_nvngx.dll".source = "${osConfig.hardware.nvidia.package}/lib/nvidia/wine/_nvngx.dll";

    # DLSSTweaks
    file.".xlcore/ffxiv/game/winmm.dll".source = "${dlsstweaks}/nvngx.dll";
  };

  programs.home-manager.enable = true;
}

So this pulls in the DLL’s from the custom NVIDIA driver and also pulls in some DLL’s from GitHub.

Thanks all!

1 Like