Skip to content

Use of environment.sessionVariables.PATH interferes with system rebuild #472

@alrunner4

Description

@alrunner4

Bug description

Use of environment.sessionVariables to set PATH causes system reconfiguration to fail.

Maybe this isn't the right way to configure PATH any more and this isn't really a bug, but it's not listed in the configuration documentation.

To Reproduce

$ cat /etc/nixos/configuration.nix
{ lib, pkgs, config, modulesPath, ... }:

with lib;
{
  imports = [
    "${modulesPath}/profiles/minimal.nix"
    <nixos-wsl/modules>
  ];

  wsl = {
    enable = true;
    wslConf.automount.root = "/mnt";
    defaultUser = "nixos";
    startMenuLaunchers = true;
  };

  # Enable nix flakes
  nix.package = pkgs.nixFlakes;
  nix.extraOptions = ''
    experimental-features = nix-command flakes
  '';

  system.stateVersion = "22.05";

  environment.sessionVariables = rec {
    HOME = "/mnt/c/users/alexca14";
    PATH = ["${HOME}/bin"];
  };
}
sudo nixos-rebuild switch

Logs

$ sudo nixos-rebuild switch
building Nix...
building the system configuration...
error: The option `environment.variables.PATH' is defined multiple times while it's expected to be unique.

       Definition values:
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos-wsl/modules/systemd/native':
           [
             "$PATH"
           ]
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/config/shells-environment.nix': "/mnt/c/users/alexca14/bin"
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.
(use '--show-trace' to show detailed location information)

WSL version

WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.4291
shasum -a 256 nixos-wsl.tar.gz
3893395087de58cc68ed1181ecf8cdaa06aac677c9665c2ff696901ab2096898

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions