Noob NixOs+Hyprland Build error regarding store paths

Hello, I’m new to linux and by extension nix. After getting the latest nixos release, I started following guides on youtube, wiki, reddit, here, and pretty much anywhere I can find to troubleshoot as I set up nixos+hyprland. Over the course of the last three days I’ve worked out every other issue I’ve had except for this one. I cant seem to get hyprland to build with my current configuration file.

Bellow is my current config and the errors I get when running “nixos-rebuild switch”. I know its probably messy, bear with me. I’m still trying to figure this all out. Also I am running the 550 drivers for nvidia.

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:



{
imports =
[ # Include the results of the hardware scan.
  ./hardware-configuration.nix
];

# Enable flake
#nix.settings.experimental-features = [ "nix-command" "flakes" ];

# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;

boot.initrd.luks.devices."luks-c2da8c22-7665-455f-980d-f5ddb37e84ab".device = "/dev/disk/by-uuid/c2da8c22-7665-455f-980d-f5ddb37e84ab";
networking.hostName = "nixos"; # Define your hostname.
# networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

# Enable networking
networking.networkmanager.enable = true;

# Set your time zone.
time.timeZone = "America/New_York";

# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";

i18n.extraLocaleSettings = {
  LC_ADDRESS = "en_US.UTF-8";
  LC_IDENTIFICATION = "en_US.UTF-8";
  LC_MEASUREMENT = "en_US.UTF-8";
  LC_MONETARY = "en_US.UTF-8";
  LC_NAME = "en_US.UTF-8";
  LC_NUMERIC = "en_US.UTF-8";
  LC_PAPER = "en_US.UTF-8";
  LC_TELEPHONE = "en_US.UTF-8";
  LC_TIME = "en_US.UTF-8";
};

# Enable the X11 windowing system.
services.xserver.enable = true;

# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;

# Configure keymap in X11
  services.xserver = {
  layout = "us";
  xkbVariant = "";
};

# Enable CUPS to print documents.
services.printing.enable = true;

# Enable sound with pipewire.
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
jack.enable = true;

# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};

# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.madmanmo = {
  isNormalUser = true;
  description = "MadManMo";
  extraGroups = [ "networkmanager" "wheel" ];
  packages = with pkgs; [
#  thunderbird
  ];
};

# Install firefox.
programs.firefox.enable = true;


# Allow unfree packages
nixpkgs.config.allowUnfree = true;

# Enabling hyprlnd on NixOS
programs.hyprland = {
enable = true;
# nvidiaPatches = true;
xwayland.enable = true;
};

environment.sessionVariables = {
# If your cursor becomes invisible
WLR_NO_HARDWARE_CURSORS = "1";
# Hint electron apps to use wayland
NIXOS_OZONE_WL = "1";
};

# XDG portal
xdg.portal.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];



# Enable OpenGL
hardware.opengl = {
  enable = true;
  driSupport = true;
  driSupport32Bit = true;
};

# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["nvidia"];

hardware.nvidia.modesetting.enable = true;
hardware.nvidia.powerManagement.enable = false;
hardware.nvidia.powerManagement.finegrained = false;
hardware.nvidia.open = false;
hardware.nvidia.nvidiaSettings = true;
# Special config to load the latest (535 or 550) driver for the support of the 4070 SUPER
hardware.nvidia.package = let 
rcu_patch = pkgs.fetchpatch {
url = "https://github.com/gentoo/gentoo/raw/c64caf53/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.223.02-gpl-pfn_valid.patch";
hash = "sha256-eZiQQp2S/asE7MfGvfe6dA/kdCvek9SYa/FFGp24dVg=";
   };
in config.boot.kernelPackages.nvidiaPackages.mkDriver {
#version = "535.154.05";
#sha256_64bit = "sha256-fpUGXKprgt6SYRDxSCemGXLrEsIA6GOinp+0eGbqqJg=";
#sha256_aarch64 = "sha256-G0/GiObf/BZMkzzET8HQjdIcvCSqB1uhsinro2HLK9k=";
#openSha256 = "sha256-wvRdHguGLxS0mR06P5Qi++pDJBCF8pJ8hr4T8O6TJIo=";
#settingsSha256 = "sha256-9wqoDEWY4I7weWW05F4igj1Gj9wjHsREFMztfEmqm10=";
#persistencedSha256 = "sha256-d0Q3Lk80JqkS1B54Mahu2yY/WocOqFFbZVBh+ToGhaE=";

version = "550.40.07";
sha256_64bit = "sha256-KYk2xye37v7ZW7h+uNJM/u8fNf7KyGTZjiaU03dJpK0=";
sha256_aarch64 = "sha256-AV7KgRXYaQGBFl7zuRcfnTGr8rS5n13nGUIe3mJTXb4=";
openSha256 = "sha256-mRUTEWVsbjq+psVe+kAT6MjyZuLkG2yRDxCMvDJRL1I=";
settingsSha256 = "sha256-c30AQa4g4a1EHmaEu1yc05oqY01y+IusbBuq+P6rMCs=";
persistencedSha256 = "sha256-11tLSY8uUIl4X/roNnxf5yS2PQvHvoNjnd2CB67e870=";

patches = [ rcu_patch ];
};



 # Gaming
 programs.steam = {
 enable = true;
 remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
 dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
 };

 # Enable OpenTabletDriver
 hardware.opentabletdriver.enable = true;
 hardware.opentabletdriver.daemon.enable = true;


# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
    #vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    alacritty
    kitty
    git
(pkgs.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ];
})
)
pkgs.dunst
    libnotify
    swww
    rofi-wayland
    discord
];

# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
#   enable = true;
#   enableSSHSupport = true;
# };

# List services that you want to enable:

# Enable the OpenSSH daemon.
# services.openssh.enable = true;


# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;

# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "24.05"; # Did you read the comment?

}

Now when I rebuild and switch I get this.

error: builder for '/nix/store/gd9lm4vg2y8z2wwrbkihd2g96lk3dnc1-user-units.drv' failed with exit code 1;
   last 1 log lines:
   > ln: failed to create symbolic link '/nix/store/x86sv3nnzlbl44pzkvka0znm35h4dm92-user-units/xdg-desktop-portal-gtk.service': File exists
   For full logs, run 'nix log /nix/store/gd9lm4vg2y8z2wwrbkihd2g96lk3dnc1-user-units.drv'.
error: 1 dependencies of derivation '/nix/store/gswialr4m7g7i44kjaa76hwkvkyaswj8-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kcy679dy5sk478pbia6bn01v1s79rgd5-nixos-system-nixos-24.05.1358.47b604b07d1e.drv' failed to build

I ran the nix log command and got this back.

warning:  The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/gd9lm4vg2y8z2wwrbkihd2g96lk3dnc1-user-units.drv^*'
ln: failed to create symbolic link '/nix/store/x86sv3nnzlbl44pzkvka0znm35h4dm92-user-units/x>
lines 1-1/1 (END)

I see the answer right there. But I actually don’t understand how to do that, and I have not yet found an example of someone detailing this problems solution. I’ve seen a few similar problems, and it sounds like I need to fix a broken link. I just don’t quite understand how to do that.

I tried to build the (what I assume is) /etc/nixos/configuration.nix you provided, but was getting other errors. Can you provide your /etc/nixos/hardware-configuration.nix too?

Sure thing!

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];

boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];

fileSystems."/" =
{ device = "/dev/disk/by-uuid/7e6f4be4-bfc0-4151-a837-b43946accb1f";
  fsType = "btrfs";
  options = [ "subvol=@" ];
};

fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/1659-D080";
  fsType = "vfat";
  options = [ "fmask=0022" "dmask=0022" ];
  };

 fileSystems."/home" =
{ device = "/dev/disk/by-uuid/ecb9b56e-efba-426b-b875-a00ab2fd369e";
  fsType = "btrfs";
 };

fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/2cfd0d53-9bbc-431a-8026-34d955d6d8ca";
  fsType = "btrfs";
};

swapDevices =
[ { device = "/dev/disk/by-uuid/92c98619-3bcd-4446-b121-1c10a39d3f6c"; }
];

# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp9s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp7s0.useDHCP = lib.mkDefault true;

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

I have not manually touched this yet so it should all still be original from install.

I double checked the config file and I realize that I copy pasted the wrong config file. I will edit and update this.

With both the old and new configs, I get a different error:

error: builder for '/nix/store/bpp6jbwcw0h4g2gpc9xz5b0ibzhgr9ih-xdg-portals.drv' failed with exit code 255;
       last 1 log lines:
       > error: collision between `/nix/store/lvsnx16bh8kki6pas0xr4jwdah5a1m8x-xdg-desktop-portal-gtk-1.15.1/share/applications/xdg-desktop-portal-gtk.desktop' and `/nix/store/9j6c0i0w2mv6ycr3pqjnyksmlwklzi5p-xdg-desktop-portal-gtk-1.15.1/share/applications/xdg-desktop-portal-gtk.desktop'
       For full logs, run 'nix log /nix/store/bpp6jbwcw0h4g2gpc9xz5b0ibzhgr9ih-xdg-portals.drv'.

My different error may be because I am using a different nixos channel than your machine (my NixOS machine is using flakes, on nixos-unstable).

While my error is different, maybe my resolution would work for fixing your error too. My error seems to be caused by the simultaneous existence of these two sections in your /etc/nixos/configuration.nix:

# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
# XDG portal
xdg.portal.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];

Enabling GNOME with services.xserver.desktopManager.gnome.enable = true; also sets those two XDG portals options (relevent source code from nixpkgs repo, nixos-unstable channel), so setting the xdg.portal.enable = true; is redundant. xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; causes the collision because the GNOME option defines a package override of pkgs.xdg-desktop-portal-gtk.

Assuming you want to keep GNOME installed, in addition to Hyprland, try removing the line xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];. The other line xdg.portal.enable = true; appears to do no harm but is redundant so you can delete this line too. Hopefully this change fixes your error as well.

1 Like

After trying the first method of removing

xdg.portal.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];

I get a new error.

error: creating symlink from '/nix/var/nix/profiles/.0_system' to 'system-13-link': Permission denied

I dont think I would want or need gnome so i also tried removing the lines

services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;

and re-enabling the xdg.portal lines. with that I get the error

error: creating symlink from '/nix/var/nix/profiles/system-14-link.tmp-38652-994948805' to '/nix/store/0m0j2nbbxrnpx7sg42w1haxgpfs4iy16-nixos-system-nixos-24.05.1358.47b604b07d1e': Permission denied

Now, I probably shouldn’t have done this, but since I can roll back or re-install in the wort case scenario I tried a sudo rebuild for both options.

Disabling xdg.portal lines had seemingly no effect.

Disabling Gnome however brought me to a black screen that I though was the TTY, but I could not enter commands. I could type, but no commands worked. So I then rebooted, selected that build config and was brought to a slightly different login than the one I’ve seen so far with Gnome. Checking some options at the top of the login screen near the power options I found that hyprland was running. Attempting to login though would just loop me right back to the login.

Now, I probably shouldn’t have done this, but since I can roll back or re-install in the wort case scenario I tried a sudo rebuild for both options.

nixos-rebuild switch certainly needs superuser permissions because /etc/nixos/configuration.nix defines and modifies nearly everything in the machine. /nix/var/nix/profiles is owned by root so the rebuild command needs sudo to create new files in that folder. Were you able to successfully run nixos-rebuild switch without sudo in the past?


Disabling Gnome however brought me to a black screen that I though was the TTY, but I could not enter commands. I could type, but no commands worked. So I then rebooted, selected that build config and was brought to a slightly different login than the one I’ve seen so far with Gnome. Checking some options at the top of the login screen near the power options I found that hyprland was running. Attempting to login though would just loop me right back to the login.

I also see the tty for a few seconds before GDM launches and displays its GUI. Not sure what the cause is.

With GNOME disabled, GDM needs to be configured to launch Hyprland. This can be done by adding this line to /etc/nixos/configuration.nix:

services.xserver.displayManager.defaultSession = "hyprland";

Note: during my testing, Hyprland launches but crashes immediately after logging in through GDM. Maybe this will work on your machine will work though, because I am testing your config with a VM (nixos-rebuild build-vm).

1 Like

nixos-rebuild switch certainly needs superuser permissions because /etc/nixos/configuration.nix defines and modifies nearly everything in the machine. /nix/var/nix/profiles is owned by root so the rebuild command needs sudo to create new files in that folder. Were you able to successfully run nixos-rebuild switch without sudo in the past?

I think I may have been confusing when I was experimenting with flakes and trying to install hyprland that way. Very sorry for that. This project has kept me up for a few nights and I guess more than one memory blurred.
Good news though. Dissabling the xdg.portals while keeping Gnome active along with the line provided

services.xserver.displayManager.defaultSession = "hyprland";

Did get hyprland to show up after a reboot. I went into the ~/.config/hypr/hyprland.conf to get rid of the initial display warning, enable waybar, and set a bind to rofi. But saving any alteration to the file unfortunately causes a hard freeze. Excruciatingly frustrating, BUT, that is progress. I’m almost wondering if it would be better to do a fresh install again with no desktop and try to go from there now that I know more lol. Thank you very much for your patience @testplayername. I would assume we should mark this issue as solved yes?

If the original issue is solved, you can mark this thread as solved to keep this forum a bit tidier.

Beginning your Linux journey with NixOS is no doubt frustrating on top of painful. I thought Arch Linux was annoying…

By default, Hyprland automatically reloads when it detects changes to its config. If it finds an error in the file, the Hyprland instance should display a red window with some debugging information, without crashing. A hard freeze may indicate an absolutely unusable hyprland.conf but without knowing more details and additional testing this is all just a guess.

As for making a user-level config for Hyprland through ~/.config/hypr/hyprland.conf I recommend using Home Manager instead of modifying the conf file directly, especially because Home Manager provides a full set of options for Hyprland which one of the maintainers of Hyprland uses extensively and provides a good example config. Of course, Home Manager significantly deepens the Nix rabbit hole and introduces yet another potential source of bugs. Most likely, you’ll want to use it. Welcome to Nix!

1 Like