dustinlyons / nixos-config

General purpose Nix configuration for macOS / NixOS with starter templates + step-by-step guides ✨
BSD 3-Clause "New" or "Revised" License
1.79k stars 113 forks source link

Installed new NixOS install using this repo, no GUI on reboot #42

Closed daniel-heppner-ibigroup closed 9 months ago

daniel-heppner-ibigroup commented 10 months ago

I followed the instructions to install a fresh install of NixOS on my PC by running the listed sudo nix run command. Upon reboot, I'm dropped in a login shell and the virtual terminal at F7 doesn't exist. A bit of a nix noob here so not sure what I'm missing!

dustinlyons commented 10 months ago

Hmm, something must have went wrong during install. Before rebooting, you should have been given an option to set a password. This is the root password.

Can you login as root in the terminal and share the output of

journalctl -xb

and

systemctl list-unit-files --state=enabled

?

daniel-heppner-ibigroup commented 10 months ago

Thanks for the quick response! Here’s a gist with the files in question. https://gist.github.com/danielhep/0c2bf9d8f57c025644538a645bc56bba

From: Dustin Lyons @.> Date: Thursday, January 11, 2024 at 2:38 PM To: dustinlyons/nixos-config @.> Cc: Daniel Heppner @.>, Author @.> Subject: Re: [dustinlyons/nixos-config] Installed new NixOS install using this repo, no GUI on reboot (Issue #42) Exercise caution. This is an EXTERNAL email. DO NOT open attachments or click links from unknown senders or unexpected email.

Hmm, something must have went wrong during install. Before rebooting, you should have been given an option to set a password. This is the root password.

Can you login as root in the terminal and share the output of

journalctl -xb

and

systemctl list-unit-files --state=enabled

?

— Reply to this email directly, view it on GitHubhttps://github.com/dustinlyons/nixos-config/issues/42#issuecomment-1888080505, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWETPO4PBMK2MJJRXAIRHV3YOBSVXAVCNFSM6AAAAABBXGB6AGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBYGA4DANJQGU. You are receiving this because you authored the thread.Message ID: @.***>

This email and any files transmitted with it are the property of Arcadis and its affiliates. All rights, including without limitation copyright, are reserved. This email contains information that may be confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not an intended recipient, please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error, please return it to the sender and then delete the email and destroy any copies of it. While reasonable precautions have been taken to ensure that no software or viruses are present in our emails, we cannot guarantee that this email or any attachment is virus free or has not been intercepted or changed. Any opinions or other information in this email that do not relate to the official business of Arcadis are neither given nor endorsed by it.

dustinlyons commented 10 months ago

Okay, that actually looks okay. What happens if you try this?

sudo systemctl start lightdm
daniel-heppner-ibigroup commented 10 months ago

Sorry about my above comment including email garbage. I'll reply from GitHub UI.

I'm getting Unit lightdm.service not found.. I saw that Syncthing is there, so it seems like some elements of the nix configuration applied.

It's not clear to me what your installer actually does. Where does the config end up for the system?

dustinlyons commented 10 months ago

It runs this script:

#!/usr/bin/env bash
set -exu

check_installer() {
  if [ -e /etc/NIXOS ]; then
    echo -e "\e[1;32mRunning in the NixOS installer environment.\e[0m"
  else
    echo -e "\e[1;31mNot running in the NixOS installer environment.\e[0m"
    exit 1
  fi
}

cleanup() {
  rm -rf nixos-config-main.zip nixos-config-main nixos-config
}

download_config() {
  curl -LJ0 https://github.com/dustinlyons/nixos-config/archive/main.zip -o nixos-config-main.zip
  unzip nixos-config-main.zip
  mv nixos-config-main/templates/starter nixos-config
  cd nixos-config
}

run_apply() {
  ./apps/x86_64-linux/apply
  if [ ! -f /tmp/username.txt ]; then
    echo -e "\e[1;31mError: /tmp/username.txt does not exist.\e[0m"
    exit 1
  fi
  export USERNAME=$(cat /tmp/username.txt)
}

run_disko() {
  sudo nix run --extra-experimental-features nix-command --extra-experimental-features flakes \
    github:nix-community/disko -- --mode zap_create_mount ./modules/nixos/disk-config.nix
}

setup_files() {
  sudo mkdir -p /mnt/etc/nixos
  sudo cp -r * /mnt/etc/nixos
  cd /mnt/etc/nixos
}

install_nixos() {
  ARCH=$(uname -m)

  case "$ARCH" in
    x86_64)
      FLAKE_TARGET="x86_64-linux"
      ;;
    aarch64)
      FLAKE_TARGET="aarch64-linux"
      ;;
    *)
      echo -e "${RED}Unsupported architecture: $ARCH${CLEAR}"
      exit 1
      ;;
  esac

  sudo nixos-install --flake .#$FLAKE_TARGET $@
  sudo chmod -R 775 /mnt/etc/nixos
}

prompt_reboot() {
  read -p "Do you want to reboot now? (y/yes) " choice
  case "$choice" in
  y|Y|yes|YES ) echo -e "\e[1;32mRebooting...\e[0m" && sudo reboot;;
  * ) echo -e "\e[1;33mReboot skipped.\e[0m";;
  esac
}

cleanup
check_installer
download_config
run_apply
run_disko
setup_files
install_nixos
cleanup
prompt_reboot

You can check /etc/nixos and ensure the configuration is there. This project doesn't use a traditional configuration.nix, it's all built on flakes.

If you see the configuration, you can try to deploy it again to generate any errors:

nixos-rebuild switch --flake .#x86_64-linux

dustinlyons commented 10 months ago

That last command assumes the flake is in the current working directory.

. - current directory

# - flake target

x86_64-linux - target inside flake.nix defined as "x86_64-linux"

daniel-heppner-ibigroup commented 10 months ago

No errors upon running the deployment again. Looking around, I saw some lines under the xserver config for GPU drivers. I uncommented the lines for AMD, as I have an AMD GPU. However, (and I think this is a bug), the following lines are wrong since they're positioned under the services.xserver object, but it seems like they need to be on the top level.

      # Uncomment these for AMD GPU
      # boot.initrd.kernelModules = [ "amdgpu" ];
      # services.xserver.videoDrivers = [ "amdgpu" ];

I figured that out and upon rebooting I saw the AMD driver load, but still no display output and the lightdm service is not found.

daniel-heppner-ibigroup commented 10 months ago

In journalctl -u display-manager I see that it attempts to start on each boot but immediately shuts down.

dustinlyons commented 10 months ago

Okay, this is good you're surfacing this. I will eventually need to add to the installer the choice for nvidia and AMD and then choose the right options accordingly.

You're right that it needs to be at the top level, and videoDrivers = [ "nvidia" ] just needs to be videoDrivers = [ "amdgpu" ].

Here is the info on AMD GPUs: https://nixos.wiki/wiki/AMD_GPU

I'm not sure which card you have. Does this help at all?

daniel-heppner-ibigroup commented 10 months ago

I have a fairly recent card, a 6700XT.

I think I have the drivers configured correctly, but I'm still not getting a GUI. I haven't used lightdm before either, but running lightdm on the shell as root gets me a Failed to use bus name: org.freeddesktop.DisplayManager, do you have appropriate permissions?

I also see a "Failed to get D-Bus connection" in the journal for display-manager from an earlier reboot, but the more recent reboots it seems to be starting successfully.

dustinlyons commented 10 months ago

A few things to try:

systemctl list-unit-files --type=service | grep -E 'gdm|sddm|lightdm|xdm'

to check if multiple display managers are installed for some reason

sudo systemctl restart dbus

to restart the dbus to see any errors

journalctl -u lightdm and journalctl -u dbus

to check for errors

Remove this in the hosts/nixos.config

      screenSection = ''
        Option       "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}"
        Option       "AllowIndirectGLXProtocol" "off"
        Option       "TripleBuffer" "on"
      '';

not needed for AMD GPUs

or try to remove this for another displayManager

      displayManager.lightdm = {
        enable = true;
        greeters.slick.enable = true;
        background = ../../modules/nixos/config/login-wallpaper.png;
      };

Display manager options: https://search.nixos.org/options?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=displayManager

dustinlyons commented 10 months ago

Hi @daniel-heppner-ibigroup , any luck? Lots of good examples here of folks using AMD GPUs in their Nix configuration: https://github.com/search?q=initrd.kernelModules+%3D+%5B+%22amdgpu%22+%5D%3B&type=code

I'd love to help but unfortunately don't have an AMD GPU to test.

dustinlyons commented 9 months ago

Hi @daniel-heppner-ibigroup, I'm spending some time cleaning up Github Issues. I hope the answer above helps in some way. Let me know here (on this Issue) if you have any more questions.