VBox demo appliance, from Plasma to Gnome?

I am experimenting with the NixOS VBox demo appliance.

I wish to replace Plasma with Gnome.

The configuration.nix indicates:

# By default, the NixOS VirtualBox demo image includes SDDM and Plasma.
# If you prefer another desktop manager or display manager, you may want
# to disable the default.
# services.xserver.desktopManager.plasma5.enable = lib.mkForce false;
# services.xserver.displayManager.sddm.enable = lib.mkForce false;

# Enable GDM/GNOME by uncommenting above two lines and two lines below.
# services.xserver.displayManager.gdm.enable = true;
# services.xserver.desktopManager.gnome.enable = true;

So I tried to uncomment those four lines as instructed. When I make those changes, that segment of my configuration file therefore look like this:

# By default, the NixOS VirtualBox demo image includes SDDM and Plasma.
# If you prefer another desktop manager or display manager, you may want
# to disable the default.
services.xserver.desktopManager.plasma5.enable = lib.mkForce false;
services.xserver.displayManager.sddm.enable = lib.mkForce false;

# Enable GDM/GNOME by uncommenting above two lines and two lines below.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;

Next when I run $ sudo nixos-rebuild switch, I get this traceback:

(Full error)
error:
       … while evaluating the attribute 'config'

         at /nix/store/rlwgjmvkjn2wn74hcj4h7hcsdr7h9sxc-nixos-23.11/nixos/lib/modules.nix:320:9:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          321|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/store/rlwgjmvkjn2wn74hcj4h7hcsdr7h9sxc-nixos-23.11/nixos/lib/modules.nix:320:18:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          321|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: undefined variable 'lib'

       at /home/demo/nixos-configs/configuration.nix:78:47:

           77| services.xserver.desktopManager.plasma5.enable = lib.mkForce false;
           78| services.xserver.displayManager.sddm.enable = lib.mkForce false;
             |                                               ^
           79|
building Nix...
error:
       … while evaluating the attribute 'config'

         at /nix/store/rlwgjmvkjn2wn74hcj4h7hcsdr7h9sxc-nixos-23.11/nixos/lib/modules.nix:320:9:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          321|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/store/rlwgjmvkjn2wn74hcj4h7hcsdr7h9sxc-nixos-23.11/nixos/lib/modules.nix:320:18:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          321|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: undefined variable 'lib'

       at /home/demo/nixos-configs/configuration.nix:78:47:

           77| services.xserver.desktopManager.plasma5.enable = lib.mkForce false;
           78| services.xserver.displayManager.sddm.enable = lib.mkForce false;
             |                                               ^
           79|
building the system configuration...
error:
       … while evaluating the attribute 'config.system.build.toplevel'

         at /nix/store/rlwgjmvkjn2wn74hcj4h7hcsdr7h9sxc-nixos-23.11/nixos/lib/modules.nix:320:9:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          321|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/store/rlwgjmvkjn2wn74hcj4h7hcsdr7h9sxc-nixos-23.11/nixos/lib/modules.nix:320:18:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          321|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: undefined variable 'lib'

       at /home/demo/nixos-configs/configuration.nix:78:47:

           77| services.xserver.desktopManager.plasma5.enable = lib.mkForce false;
           78| services.xserver.displayManager.sddm.enable = lib.mkForce false;
             |                                               ^
           79|
  • What is this error trying to say?
  • What do I need to change to properly disable Plasma/SDDM and install Gnome/GDM?
  • What other information could I provide to help troubleshoot?

Here is my:

(Full configuration.nix)
{ config, pkgs, ... }:

{
  imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];
  
  # nix.settings.experimental-features = [ "nix-command" "flakes" ];  

  nixpkgs.config.allowUnfree = true; 
	  # Hyprland

  # Next six lines courtesy of Jennifer Darlene on 22 Jan 2024 to get basic Hyprland working
  programs.hyprland = {
    enable = true;
    xwayland.enable = true; # allow x11 applications
  };
  programs.sway.enable = true;
  console.useXkbConfig = true;

  environment.systemPackages = with pkgs; [
    # ... other packages ...
    google-chrome
    # thunar
    vscode
    qbittorrent
    chromium
    libreoffice
    python312
    # anaconda
    # sway
    # i3
    xdg-desktop-portal-hyprland    
    vim
    git
    
    # Next ten lines courtest of Jennifer Darlene on 22 Jan 2024 to get basic Hyprland working
    waybar # status bar
    mako # notification daemon
    libnotify # for mako
    swww # wallpaper daemon
    kitty # terminal
    rofi-wayland # wl equiv of rofi app launcher, window switcher ...
    networkmanagerapplet # tray applet for network manager -- nm-applet
    grim # screenshot utility
    grimblast # grim helper
    udiskie # automount removable media

  ];

#   services.xserver = {
#     enable = true;   
#     desktopManager = {
#       xterm.enable = false;
#       xfce = {
#         enable = true;
#         noDesktop = true;
#         enableXfwm = false;
#       };
#    };
#    displayManager.defaultSession = "xfce";
#   };

# Let demo build as a trusted user.
# nix.settings.trusted-users = [ "demo" ];

# Mount a VirtualBox shared folder.
# This is configurable in the VirtualBox menu at
# Machine / Settings / Shared Folders.
# fileSystems."/mnt" = {
#   fsType = "vboxsf";
#   device = "nameofdevicetomount";
#   options = [ "rw" ];
# };

# By default, the NixOS VirtualBox demo image includes SDDM and Plasma.
# If you prefer another desktop manager or display manager, you may want
# to disable the default.
# services.xserver.desktopManager.plasma5.enable = lib.mkForce false;
# services.xserver.displayManager.sddm.enable = lib.mkForce false;

# Enable GDM/GNOME by uncommenting above two lines and two lines below.
# services.xserver.displayManager.gdm.enable = true;
# services.xserver.desktopManager.gnome.enable = true;

# Set your time zone.
# time.timeZone = "Europe/Amsterdam";

# List packages installed in system profile. To search, run:
# \$ nix search wget
# environment.systemPackages = with pkgs; [
#   wget vim
# ];

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

}

This is the important part.

NixOS configuration module is written in Nix programming language, and it only has access to variables that are explicitly defined (plus Nix built-ins).

You need to add lib parameter to the function:

{ config, pkgs, lib, ... }:
{
  # the config…
}

NixOS module system will then be able to pass the value as an argument to the module function.

Hi @jtojnar! Thank you for your reply. Making that one minor change resolved the issue. I am now hailing from Gnome instead of Plasma. :slightly_smiling_face: