nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.63k stars 1.74k forks source link

bug: nix nushell path environment variable does not have `$USER` and `$HOME` #4918

Open Livenux opened 7 months ago

Livenux commented 7 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

nushell $env.PATH per-user miss username. bash path

echo "/opt/orbstack-guest/bin-hiprio:/opt/orbstack-guest/data/bin/cmdlinks:/run/wrappers/bin:/home/livenux/.nix-profile/bin:/nix/profile/bin:/home/livenux/.local/state/nix/profile/bin:/etc/profiles/per-user/livenux/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/opt/orbstack-guest/bin" | split row ':'
╭───┬────────────────────────────────────────────╮
│ 0 │ /opt/orbstack-guest/bin-hiprio             │
│ 1 │ /opt/orbstack-guest/data/bin/cmdlinks      │
│ 2 │ /run/wrappers/bin                          │
│ 3 │ /home/livenux/.nix-profile/bin             │
│ 4 │ /nix/profile/bin                           │
│ 5 │ /home/livenux/.local/state/nix/profile/bin │
│ 6 │ /etc/profiles/per-user/livenux/bin         │
│ 7 │ /nix/var/nix/profiles/default/bin          │
│ 8 │ /run/current-system/sw/bin                 │
│ 9 │ /opt/orbstack-guest/bin                    │
╰───┴────────────────────────────────────────────╯

nushell path

 $env.PATH                                                                                                                                                  01/18/24 01:48:52 AM
╭───┬───────────────────────────────────────╮
│ 0 │ /opt/orbstack-guest/bin-hiprio        │
│ 1 │ /opt/orbstack-guest/data/bin/cmdlinks │
│ 2 │ /run/wrappers/bin                     │
│ 3 │ /.nix-profile/bin                     │
│ 4 │ /nix/profile/bin                      │
│ 5 │ /.local/state/nix/profile/bin         │
│ 6 │ /etc/profiles/per-user//bin           │
│ 7 │ /nix/var/nix/profiles/default/bin     │
│ 8 │ /run/current-system/sw/bin            │
│ 9 │ /opt/orbstack-guest/bin               │
╰───┴───────────────────────────────────────╯

flake.nix

{
  description = "A template that shows all standard flake outputs";

  inputs = {
    nix.url = "github:NixOS/nix";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";

    dwarffs.url = "github:edolstra/dwarffs";

    home-manager = {
      url = "github:nix-community/home-manager/release-23.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };

  };

  outputs = {self, nix, nixpkgs, dwarffs, home-manager, ... }@inputs: {
    nixosConfigurations = {
      nixos = nixpkgs.lib.nixosSystem {
        system = "aarch64-linux";

        modules = [
          ./configuration.nix
          ./users.nix
          dwarffs.nixosModules.dwarffs
          { nixpkgs.overlays = [ nix.overlays.default ]; }

          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.livenux = import ./home-manager.nix;
          }

        ];

      };

    };
  };

}

home-mager.nix

{ config, pkgs, ... }:
{
  home = {
    username = "livenux";
    homeDirectory = "/home/livenux";
    stateVersion = "23.11";

    packages = [
      pkgs.htop
      pkgs.fortune
    ];
  };

  programs = {
    home-manager.enable = true;

    neovim = {
      enable = true;
      defaultEditor = true;
      viAlias = true;
      vimAlias = true;
    };

    git = {
      enable = true;
      userName = "Livenux";
      userEmail = "livenux@mail.com";
     };
    nushell.enable = true;
  };
}

Maintainer CC

No response

System information

nushell

nix-shell -p nix-info --run "nix-info -m"                                                                                                          
error:
       … while calling the 'import' builtin
         at «string»:1:18:
            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nix-info) ]; } ""
             |                  ^

       … while realising the context of a path

       … while calling the 'findFile' builtin
         at «string»:1:25:
            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nix-info) ]; } ""
             |                         ^

       error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

bash

nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-linux"`
 - host os: `Linux 6.5.13-orbstack-00121-ge428743e4e98, NixOS, 23.11 (Tapir), 23.11.20240110.3dc440f`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.20.0pre20240113_cbd5553`
 - channels(root): `"nixos-23.11.2874.a2fe8d21f667"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
stale[bot] commented 4 months ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.