NixOS rebooting randomly

Hello!
I’ve recently started experiencing random reboots on my NixOS system.

It used to, on occasion, glitch out for a while if I were to play some YouTube music while running a cargo command from the VS Code integrated terminal, or disconnect me from Slack huddles (while no video enabled) if I try to build a test in VS Code, but as of late it will restart for seemingly no reason. I’d log in and open two terminal instances and it would just restart.

I thought maybe it was VS Code so I downloaded the Helix editor, and still running into the same problem. I also tried messing around with my graphics settings in my config, but hasn’t seemed to change anything.

Any help is welcome, here is my system spec and config file:

  \\  \\ //     OS: NixOS 23.11pre534224.f99e5f03cc0a (Tapir) x86_64
 ==\\__\\/ //   Host: HP 8A78
   //   \\//    Kernel: 6.1.56
==//     //==   DE: GNOME 44.4 (Wayland)
 //\\___//      CPU: AMD Ryzen 7 PRO 5850U with Radeon Graphics (16) @ 1.900GHz
// /\\  \\==    GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series
  // \\  \\     GPU Driver: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:0123]
{ config, lib, pkgs, ... }:

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

  # Bootloader.
  boot.loader = {
    systemd-boot.enable = true;
    efi = {
      canTouchEfiVariables = true;
      efiSysMountPoint = "/boot/efi";
    };
  };
  # AMD Radeon mobile graphics settings
#  hardware = {
#    cpu.amd.updateMicrocode = true;
#    enableRedistributableFirmware = true;
#    enableAllFirmware = true;
#    opengl = {
#      enable = true;
#      driSupport = true;
#      extraPackages = with pkgs; [
#        rocm-opencl-icd
#        rocm-opencl-runtime
#      ];
#    };
#  };
#  boot = {
#    initrd.kernelModules = [ "amdgpu" ];
#  };

  # Setup keyfile
  boot.initrd.secrets = {
    "/crypto_keyfile.bin" = null;
  };

  # video capture from external device
  boot.kernelModules = [ "v4l2loopback" ];
  boot.extraModulePackages = [ pkgs.linuxPackages.v4l2loopback ];

  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/Chicago";

  # 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;
  services.xserver.videoDrivers = [ "amdgpu" ];

  # 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.
  sound.enable = true;
  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;
  };

  # Enabling due to issues with Wayland & screen sharing
  xdg = {
    portal = {
      enable = true;
    };
  };
  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  services.auto-cpufreq.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.chrisobrien = {
    isNormalUser = true;
    description = "Chris O'Brien";
    extraGroups = [ "networkmanager" "wheel" ];
    shell = pkgs.zsh;
  };

  # zsh & oh-my-zsh configurations
  programs.zsh = {
    enable = true;
    enableCompletion = true;
    autosuggestions.enable = true;
    shellAliases = {
      # Use the Sway Developer Fuel Flake
      swaydev = "nix develop github:fuellabs/fuel.nix#sway-dev -c zsh";
      vrrbdev = "nix develop github:fuellabs/fuel.nix#fuel-dev -c zsh";
      # Adds `.cargo/bin` to PATH ENV VAR
      pcargo = "PATH=$PATH:/home/chrisobrien/.cargo/bin";
    };
  };
  programs.zsh.ohMyZsh = {
    enable = true;
    plugins = [ "git" ];
    theme = "agnoster";
  };

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

  # Experimental features
  nix = {
    settings = {
      experimental-features = ["nix-command" "flakes"];
      extra-substituters = ["https://fuellabs.cachix.org"];
      extra-trusted-public-keys = [
        "fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8="
      ];
    };
  };

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment = {
    systemPackages = with pkgs; [
      brave
      (vscode-with-extensions.override {
        vscodeExtensions = with vscode-extensions; [
          bbenoist.nix
          matklad.rust-analyzer
          vadimcn.vscode-lldb
          pkief.material-product-icons
          tamasfe.even-better-toml
          esbenp.prettier-vscode
          ms-vsliveshare.vsliveshare
          vscodevim.vim
          catppuccin.catppuccin-vsc
          jdinhlife.gruvbox
          piousdeer.adwaita-theme
          zhuangtongfa.material-theme
          arcticicestudio.nord-visual-studio-code
          file-icons.file-icons
          eamodio.gitlens
        ];
      })
      gnomeExtensions.just-perfection
      gnomeExtensions.color-picker
      gnomeExtensions.pop-shell
      gnome.gnome-tweaks
      helix
      git
      zsh
      oh-my-zsh
      (slack.overrideAttrs
        (old: {
          installPhase = old.installPhase + ''
            rm $out/bin/slack

            makeWrapper $out/lib/slack/slack $out/bin/slack \
            --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
            --prefix PATH : ${lib.makeBinPath [pkgs.xdg-utils]} \
            --add-flags "--enable-features=WebRTCPipeWireCapturer"
          '';
        })
      )
      tdesktop
      pipes-rs
      tlp
      auto-cpufreq
      thunderbird
      discord
      cups
      brlaser
      alacritty
      colloid-icon-theme
      nordic
      neofetch
      xdg-desktop-portal
      xdg-desktop-portal-gnome
      obs-studio
      blender
      steam
      protonvpn-gui
      gphoto2
      # linuxKernel.packages.linux_5_15.v4l2loopback
      v4l-utils
      ffmpeg
      libreoffice
    ];

    gnome.excludePackages = with pkgs; [
      gnome.cheese
      gnome.gnome-music
      gnome-tour
      epiphany
      gnome.geary
      gnome.gedit
      gnome-text-editor
      gnome.gnome-contacts
      gnome.yelp
    ];
  };

  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true;
    dedicatedServer.openFirewall = true;
  };

  fonts = {
    packages = with pkgs; [
      fira
      fira-code
      jetbrains-mono
      powerline-fonts
    ];
  };

  # 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 = "22.11"; # Did you read the comment?

  nix.gc = {
    automatic = true;
    dates = "weekly";
    options = "--delete-older-than 7d";
  };

  system = {
    autoUpgrade.enable = true;
    autoUpgrade.allowReboot = true;
  };
}

The first thing I usually suspect for random reboots would be memory. nix-shell -p memtester and then memtester <amount_of_ram_to_test>G A more thorough test could be done by booting into a memtest86 session from a flash drive or what not.

Anything interesting in the logs? Something like journalctl -p 0..3 -x

1 Like

There are some Boot errors here, but they’re all dated back to July :confused:

memtester is pretty cool! Will come in handy at some point I can tell. It passed 300 cycles and no issues, so I think it’s safe to say the RAM is ok.

Here’s the output of journalctl just in case:

Jul 10 12:13:48 nixos gdm[1150]: Gdm: Failed to contact accountsservice: Error calling StartServiceByName for org.freedesktop.Accounts: Refusing activation, D-Bus is shutting down.
Jul 10 12:13:50 nixos kernel: watchdog: watchdog0: watchdog did not stop!
-- Boot 78086d4f44a64618abd13149d44f2a0b --
Jul 10 12:14:12 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.AZAL], AE_NOT_FOUND (20210730/dswload2-162)
Jul 10 12:14:12 nixos kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20210730/psobject-220)
Jul 10 12:14:12 nixos systemd[1]: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
Jul 10 12:14:12 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.VGA.LCD._BCM.AFN7], AE_NOT_FOUND (20210730/psargs-330)
Jul 10 12:14:12 nixos kernel: ACPI Error: Aborting method \_SB.PCI0.GP17.VGA.LCD._BCM due to previous error (AE_NOT_FOUND) (20210730/psparse-529)
Jul 10 12:14:13 nixos avahi-daemon[974]: Failed to read /etc/avahi/services.
Jul 10 12:14:13 nixos bluetoothd[1032]: src/plugin.c:plugin_init() Failed to init vcp plugin
Jul 10 12:14:13 nixos bluetoothd[1032]: src/plugin.c:plugin_init() Failed to init mcp plugin
Jul 10 12:14:13 nixos bluetoothd[1032]: src/plugin.c:plugin_init() Failed to init bap plugin
Jul 10 12:14:13 nixos bluetoothd[1032]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Jul 10 12:14:13 nixos bluetoothd[1032]: sap-server: Operation not permitted (1)
Jul 10 12:14:15 nixos pipewire[1286]: mod.x11-bell: XOpenDisplay() failed
Jul 10 12:14:19 nixos avahi-daemon[974]: Failed to read /etc/avahi/services.
Jul 10 12:14:20 nixos gdm-password][1546]: gkr-pam: unable to locate daemon control file
Jul 10 12:14:24 nixos gdm-launch-environment][1197]: GLib-GObject: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
Jul 10 12:21:41 nixos gdm[1176]: Gdm: Failed to contact accountsservice: Error calling StartServiceByName for org.freedesktop.Accounts: Refusing activation, D-Bus is shutting down.
-- Boot 36d0c3cb510e41059808f4e7744f6b43 --
Jul 12 19:37:37 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.AZAL], AE_NOT_FOUND (20210730/dswload2-162)
Jul 12 19:37:37 nixos kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20210730/psobject-220)
Jul 12 19:37:37 nixos systemd[1]: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
Jul 12 19:37:37 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.VGA.LCD._BCM.AFN7], AE_NOT_FOUND (20210730/psargs-330)
Jul 12 19:37:37 nixos kernel: ACPI Error: Aborting method \_SB.PCI0.GP17.VGA.LCD._BCM due to previous error (AE_NOT_FOUND) (20210730/psparse-529)
Jul 12 19:37:37 nixos kernel: i2c_hid_acpi i2c-SYNA30D2:00: i2c_hid_get_input: incomplete report (64/72)
Jul 12 19:37:37 nixos avahi-daemon[971]: Failed to read /etc/avahi/services.
Jul 12 19:37:37 nixos bluetoothd[1040]: src/plugin.c:plugin_init() Failed to init vcp plugin
Jul 12 19:37:37 nixos bluetoothd[1040]: src/plugin.c:plugin_init() Failed to init mcp plugin
Jul 12 19:37:37 nixos bluetoothd[1040]: src/plugin.c:plugin_init() Failed to init bap plugin
Jul 12 19:37:38 nixos bluetoothd[1040]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Jul 12 19:37:38 nixos bluetoothd[1040]: sap-server: Operation not permitted (1)
Jul 12 19:37:40 nixos pipewire[1285]: mod.x11-bell: XOpenDisplay() failed
Jul 12 19:37:45 nixos avahi-daemon[971]: Failed to read /etc/avahi/services.
Jul 12 19:37:46 nixos gdm-password][1548]: gkr-pam: unable to locate daemon control file
Jul 12 19:37:49 nixos gdm-launch-environment][1196]: GLib-GObject: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
Jul 12 19:53:49 nixos gdm[1172]: Gdm: Failed to contact accountsservice: Error calling StartServiceByName for org.freedesktop.Accounts: Refusing activation, D-Bus is shutting down.
-- Boot f59d10fc6ded47a3a744df0a77fdfb3b --
Jul 17 23:06:24 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.AZAL], AE_NOT_FOUND (20210730/dswload2-162)
Jul 17 23:06:24 nixos kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20210730/psobject-220)
Jul 17 23:06:24 nixos systemd[1]: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
Jul 17 23:06:25 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.VGA.LCD._BCM.AFN7], AE_NOT_FOUND (20210730/psargs-330)
Jul 17 23:06:25 nixos kernel: ACPI Error: Aborting method \_SB.PCI0.GP17.VGA.LCD._BCM due to previous error (AE_NOT_FOUND) (20210730/psparse-529)
Jul 17 23:06:25 nixos kernel: i2c_hid_acpi i2c-SYNA30D2:00: i2c_hid_get_input: incomplete report (64/72)
Jul 17 23:06:25 nixos avahi-daemon[958]: Failed to read /etc/avahi/services.
Jul 17 23:06:25 nixos bluetoothd[1032]: src/plugin.c:plugin_init() Failed to init vcp plugin
Jul 17 23:06:25 nixos bluetoothd[1032]: src/plugin.c:plugin_init() Failed to init mcp plugin
Jul 17 23:06:25 nixos bluetoothd[1032]: src/plugin.c:plugin_init() Failed to init bap plugin
Jul 17 23:06:26 nixos bluetoothd[1032]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.

To be clear I’ve been aware since installing NixOS about the bios thing, it shows up on boot each time I load up but hasn’t been an issue really

Random guess here: You could check if you see similar logs to this Ryzen - ArchWiki (section 4.1) the CPU type looks quite matching. The article points out the 59xxs but if you follow up the sources, ppl claim the behavior also for all other types of 5xxx Ryzen.

Happened just now while trying to configure night light, here’s the journalctl output:

Sep 03 13:05:02 nixos avahi-daemon[969]: Failed to read /etc/avahi/services.
Sep 04 01:34:26 nixos bluetoothd[1025]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Sep 04 01:34:26 nixos bluetoothd[1025]: sap-server: Operation not permitted (1)
Sep 04 01:34:31 nixos avahi-daemon[969]: Failed to read /etc/avahi/services.
Sep 04 02:30:22 nixos kernel: Out of memory: Killed process 6379 (rust-analyzer) total-vm:6998756kB, anon-rss:4843536kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:10016kB oom_score_adj:200
Sep 04 03:39:46 nixos avahi-daemon[969]: Failed to read /etc/avahi/services.
Sep 08 00:49:52 nixos bluetoothd[1025]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Sep 08 00:49:52 nixos bluetoothd[1025]: sap-server: Operation not permitted (1)
Sep 08 00:49:56 nixos systemd[1]: Failed to start NixOS Upgrade.
░░ Subject: A start job for unit nixos-upgrade.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit nixos-upgrade.service has finished with a failure.
░░
░░ The job identifier is 6374 and the job result is failed.
Sep 08 00:49:57 nixos avahi-daemon[969]: Failed to read /etc/avahi/services.
Sep 08 01:04:22 nixos gdm[1175]: Gdm: Failed to contact accountsservice: Error calling StartServiceByName for org.freedesktop.Accounts: Refusing activation, D-Bus is shutting down.
-- Boot d0a1dc7dd7584c9bbdc12a31819b1c3e --
Sep 08 10:54:36 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.AZAL], AE_NOT_FOUND (20210730/dswload2-162)
Sep 08 10:54:36 nixos kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20210730/psobject-220)
Sep 08 10:54:36 nixos systemd[1]: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
Sep 08 10:54:36 nixos kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GP17.VGA.LCD._BCM.AFN7], AE_NOT_FOUND (20210730/psargs-330)
Sep 08 10:54:36 nixos kernel: ACPI Error: Aborting method \_SB.PCI0.GP17.VGA.LCD._BCM due to previous error (AE_NOT_FOUND) (20210730/psparse-529)
Sep 08 10:54:36 nixos kernel: i2c_hid_acpi i2c-SYNA30D2:00: i2c_hid_get_input: incomplete report (64/72)
Sep 08 10:54:37 nixos avahi-daemon[986]: Failed to read /etc/avahi/services.
Sep 08 10:54:37 nixos bluetoothd[1040]: src/plugin.c:plugin_init() Failed to init vcp plugin
Sep 08 10:54:37 nixos bluetoothd[1040]: src/plugin.c:plugin_init() Failed to init mcp plugin
Sep 08 10:54:37 nixos bluetoothd[1040]: src/plugin.c:plugin_init() Failed to init bap plugin
Sep 08 10:54:37 nixos bluetoothd[1040]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Sep 08 10:54:37 nixos bluetoothd[1040]: sap-server: Operation not permitted (1)
Sep 08 10:54:40 nixos pipewire[1293]: mod.x11-bell: XOpenDisplay() failed
Sep 08 10:54:44 nixos avahi-daemon[986]: Failed to read /etc/avahi/services.
Sep 08 10:54:58 nixos systemd[1]: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
Sep 08 10:54:57 nixos gdm-password][1988]: gkr-pam: unable to locate daemon control file
Sep 08 10:55:01 nixos gdm-launch-environment][1201]: GLib-GObject: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
Sep 08 12:19:52 nixos avahi-daemon[986]: Failed to read /etc/avahi/services.
Sep 08 19:00:06 nixos bluetoothd[1040]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Sep 08 19:00:06 nixos bluetoothd[1040]: sap-server: Operation not permitted (1)
Sep 08 19:00:14 nixos avahi-daemon[986]: Failed to read /etc/avahi/services.
Sep 08 19:24:56 nixos avahi-daemon[986]: Failed to read /etc/avahi/services.
Sep 08 20:44:16 nixos bluetoothd[1040]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Sep 08 20:44:16 nixos bluetoothd[1040]: sap-server: Operation not permitted (1)
Sep 08 20:44:26 nixos avahi-daemon[986]: Failed to read /etc/avahi/services.
Sep 08 21:01:18 nixos avahi-daemon[986]: Failed to read /etc/avahi/services.
Sep 13 20:29:53 nixos systemd[1]: Failed to start NixOS Upgrade.
░░ Subject: A start job for unit nixos-upgrade.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel

@Quagmire any thoughts on the cause based on this?

I haven’t had this problem before, but maybe it’s this line in my configuration.nix?

system = {
    autoUpgrade.enable = true;
    autoUpgrade.allowReboot = true;
  };

Yes, autoUpgrade.allowReboot = true means that it will reboot if an auto update changed the kernel or something at that level. Though that should only happen once a day, and the default is at 4:40am, so if that’s not when this is happening to you, it’s not likely related. Another thing to check would be journalctl -b -1 -e after such a reboot happens. This will jump to the end of the logs from the last boot. If it was shutdown by a proper reboot command, like autoUpgrade.allowReboot would cause, then you should see proper shutdown messages in that log.