NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.44k stars 13.64k forks source link

Error building system when adding services.xserver.enable=true #136224

Closed kero0 closed 3 years ago

kero0 commented 3 years ago

Describe the bug

System works perfectly fine unless I add services.xserver.enable = true. This is currently limiting me to only using wayland and launching from tty instead of using a display manager.

Steps To Reproduce

  1. Add services.xserver.enable = true to config
  2. run sudo nixos-rebuild test from terminal

Additional context

Pastebin of result. Seems to imply that the issue has something to do with fonts.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.


[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.13.12, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210802_47e96bb`
 - channels(root): `"nixos-21.11pre312125.21c937f8cb1, home-manager, nixos-hardware"`
 - channels(MyName): `"home-manager, nixos-21.11pre307912.fe01052444c, nixos-hardware"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos````
Alexnortung commented 3 years ago

This is probably more related to NixOS rather than Nixpkgs, so I am not sure the discussion should be here.

However, would you mind sharing your entire configuration nix? Since the problem is more likely that xserver is in conflict with some other package or service as I don't believe just having services.xserver.enable = true in your configuration file would result in a build error.

kero0 commented 3 years ago

Here's a minimum version of my config where adding that line causes the same error: configuration.nix and hardware-configuration.nix

I've removed everything else from my config so the error has to be happening somewhere here.

kero0 commented 3 years ago

Interestingly after a few days of not working it just suddenly worked. I was commenting out one thing at a time to get it to build I commented out my nix.extraOptions, it built successfully. Then I re-added it and it still successfully built so I'm not really sure what happened.

Mindavi commented 3 years ago

By default nix caches the derivations, so it might be that it still doesn't work, but since the derivation is built it's happy now.

You could test with something like nix-build -A font-cursor-misc --check to force rebuilding (not 100% sure about the attribute name) with the different nix settings.

cideM commented 3 years ago

This is https://github.com/NixOS/nixpkgs/pull/133303 which was supposedly already fixed but is not yet in nixpkgs-unstable and friends. Building just the xorg.fontcursormisc derivation won't reproduce the issue since this happens by virtue of a NixOS module which will try to add default fonts (and something cursor related) when, among other things, xserver.enable = true.

kero0 commented 3 years ago

I think you're both right. I had done my search for similar errors quite a few hours before I posted so when I found that pull request I didn't see anybody mention the error and so I thought I was having a different issue, but it probably is the same one now that I see they are having the same error.

It also probably is only working because of some cached build, which it shouldn't be since that means that as things stand now, my config only builds based off some state, i.e. commenting out parts of the config and building part of it then building the other part later.

kero0 commented 3 years ago

Should I close this since it's already been fixed in that pull request?

cideM commented 3 years ago

I'd leave it open until the fix landed on nixpkgs-unstable, that way people who're affected can just look at this issue and don't have to open a new one.

cideM commented 3 years ago

This is still broken for me

Mindavi commented 3 years ago

The PR has gone through fully, so it might be that it's not solved.

https://nixpk.gs/pr-tracker.html?pr=133303

cideM commented 3 years ago

Indeed

~/private/nixpkgs on nixpkgs-unstable •
$ git branch --contains 9e8fcb0184170a97b4d0a933783bd7c83aff2ab2
  master
* nixpkgs-unstable

@rnhmjoj the fix you pushed doesn't seem to solve this issue for some (?) of us

rnhmjoj commented 3 years ago

What is the error you see?

I don't see any issue in any of the unstable channels (nixos-unstable, nixos-unstable-small, nixpkgs-unstable) with:

nix-build -I nixpkgs=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz '<nixpkgs/nixos>' -A vm --arg configuration '{ hardware.video.hidpi.enable = true; services.xserver.enable = true; services.xserver.dpi = 284; }'
cideM commented 3 years ago

I was getting the same error as OP, but just now I updated my flake and now I'm getting

$ sudo nixos-rebuild switch --flake .
building the system configuration...
error: undefined variable 'nvidiaSettings'

       at /nix/store/0lrz7njdb4dicrx2mwqjjf989far0imf-source/nixos/modules/hardware/video/nvidia.nix:292:20:

          291|     environment.systemPackages = [ nvidia_x11.bin ]
          292|       ++ optionals nvidiaSettings [ nvidia_x11.settings ]
             |                    ^
          293|       ++ optionals nvidiaPersistencedEnabled [ nvidia_x11.persistenced ];
(use '--show-trace' to show detailed location information)
$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.60, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210802_47e96bb`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
{
    "unstable": {
      "locked": {
        "lastModified": 1630140382,
        "narHash": "sha256-ntXepAHFlAEtaYIU5EzckRUODeeMgpu1u2Yug+4LFNc=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "08ef0f28e3a41424b92ba1d203de64257a9fca6a",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    }
}

Here's the configuration.nix but I don't have a whole lot of nvidia settings:

~/dotfiles on master
$ rg nvidia
hosts/nixos/configuration.nix
100:    videoDrivers = [ "nvidia" ];
rnhmjoj commented 3 years ago

That looks completely unrelated. I'm closing this issue as I'm pretty sure my original mistake has been fixed in all channels.