Search code examples
nixnixos

Why does my NixOS installation not have `~/.nix-profile/etc/profile.d/nix.sh`?


A NixOS user, I am studying the Nix Pills. They frequently reference ~/.nix-profile/etc/profile.d/nix.sh as a means of "entering the Nix environment". E.g. quoting from chapter 5:

I remind you how to enter the Nix environment: source ~/.nix-profile/etc/profile.d/nix.sh

However, my NixOS machine does not even have a ~/.nix-profile/etc directory, let alone a ~/.nix-profile/etc/profile.d/nix.sh file. My questions:

  1. Why might my machine not have ~/.nix-profile/etc?
  2. Is there an ordinary way to generate ~/.nix-profile/etc/profile.d/nix.sh?
  3. Is there straightforward alternative way to "enter the Nix environment" in NixOS?

Solution

  • I do not yet have answers to (1) and (2), but do have an answer to (3). That is:

    $ nix repl
    

    works to enter the nix environment.