Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 622658 - sys-apps/nix sets PATH so does not play nice with existing tools
Summary: sys-apps/nix sets PATH so does not play nice with existing tools
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Sergei Trofimovich (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-25 03:22 UTC by Paul Preney
Modified: 2017-08-27 21:18 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Preney 2017-06-25 03:22:27 UTC
Although sys-apps/nix works well, it sets the start of PATH to $HOME/.nix-profile/{bin/sbin}. Depending on what is installed via Nix, this causes the Nix profile to override equivalent installed programs. While this is required for Nix, this is bad for using tools within Gentoo.

For example, consider a Gentoo system with clang v4, GCC v4.9.4, and GCC 5.4.0 installed. If one installs clang v3.9.1 using Nix, then Nix' symlinks prevent the system's programs from being used. This is acceptable if one is using clang v3.9.1 --but if one is using clang v4 or GCC v4/5 then Nix' binaries (e.g,, ar, etc.) will be used --not the systems. Worse Nix' symlinks are not 100%, e.g., clang++ is defined but not clang++-3.9 which means to use clang++-3.9 from Nix one actually has to use clang++ although one can run clang-3.9. This can result in a user easily running the wrong compiler tool. It may also cause issues running build scripts within a user's account when the system tools are desired.

These issues can be avoided by not setting the PATH in /etc/profile.d/nix.sh and instead do something like the following:

In /etc/profile.d/nix.sh define the following two functions:

function enable_nix()
{
  # Add Nix profile dirs to PATH
}

function disable_nix()
{
  # Remove Nix profile dirs from PATH
}

so one can type "enable_nix" or "disable_nix" on the command line to turn on or off the ability to use nix.

The default should be that nix is off and let the user turn it on manually or in their .profile / .bashrc / .zshrc etc.

In this way, the user will enable nix when he/she wants to use it --but it is otherwise disabled.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2017-06-25 07:37:56 UTC
Thanks for the report Paul! It sounds like it makes sense
but I would not do that change downstream.

Can you file a feature request upstream and try to settle on
a design solution that suits both you and upstream?

There is a lot of issues though thus might take a while to sort it out https://github.com/nixos/nix/issues

I can suggest a few workarounds:

Option 1: Disable profile.d population as 'USE=-etc_profile sys-apps/nix' and add needed code to uer's .rc files

Option 2: write a patch agains nix's nix.sh and drop it to /etc/portage/patches/sys-apps/nix (https://wiki.gentoo.org/wiki//etc/portage/patches)

Thanks!
Comment 2 Toralf Förster gentoo-dev 2017-07-14 17:44:13 UTC
I found at my tinderbox images something like this i ´n the error lgos :

inderbox@mr-fox ~ $ cat logs/*
stat: cannot read file system information for '%u': No such file or directory
WARNING: bad ownership on /nix/var/nix/profiles/per-user/root
stat: cannot read file system information for '%u': No such file or directory
WARNING: bad ownership on /nix/var/nix/gcroots/per-user/root
stat: cannot read file system information for '%u': No such file or directory
WARNING: bad ownership on /nix/var/nix/profiles/per-user/root
stat: cannot read file system information for '%u': No such file or directory
WARNING: bad ownership on /nix/var/nix/gcroots/per-user/root
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2017-07-15 11:34:10 UTC
(In reply to Toralf Förster from comment #2)
> I found at my tinderbox images something like this i ´n the error lgos :
> 
> inderbox@mr-fox ~ $ cat logs/*
> stat: cannot read file system information for '%u': No such file or directory
> WARNING: bad ownership on /nix/var/nix/profiles/per-user/root
> stat: cannot read file system information for '%u': No such file or directory
> WARNING: bad ownership on /nix/var/nix/gcroots/per-user/root
> stat: cannot read file system information for '%u': No such file or directory
> WARNING: bad ownership on /nix/var/nix/profiles/per-user/root
> stat: cannot read file system information for '%u': No such file or directory
> WARNING: bad ownership on /nix/var/nix/gcroots/per-user/root

This is a bit different bug. Fixed it as: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=49ad8d2c53d2f21f4867e147b6ad97cbcb706c79