Skip to content

Error actvating user in headless WSL #1074

Description

@pshangov

When building with a flake, the user activation process complains that there is no display server:

.wslconfig

[wsl2]
guiApplications=false

flake.nix

{
    inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
        nixos-wsl.url = "github:nix-community/NixOS-WSL/release-26.05";
    };

    outputs = { self, nixpkgs, nixos-wsl, ... }: {

        nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
            system = "x86_64-linux";
            modules = [
                nixos-wsl.nixosModules.wsl
                {
                    system.stateVersion = "26.05";
                    wsl.enable = true;
                }
            ];
        };

    };
}

nixos-rebuild switch

...
reloading user units for nixos...
Error: Failed to open dbus connection

Caused by:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
warning: user activation for nixos failed
restarting sysinit-reactivation.target
Command 'systemd-run -E LOCALE_ARCHIVE -E NIXOS_INSTALL_BOOTLOADER -E NIXOS_NO_CHECK --collect --no-ask-password --pipe --quiet --service-type=exec --unit=nixos-rebuild-switch-to-configuration /nix/store/n4yhvzhp0zc8sy27b0crklk1z93ncq44-nixos-system-nixos-26.05.20260611.a037402/bin/switch-to-configuration switch' returned non-zero exit status 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions