Activity log for bug #2064563

Date Who What changed Old value New value Message
2024-05-02 05:01:46 Prasanna Loganathar bug added bug
2024-05-02 05:20:12 Prasanna Loganathar bug task added nix (Debian)
2024-05-02 08:23:18 Prasanna Loganathar description # Context - nix-bin can be setup in 2 ways. - One is to let .nix-defer user local directory handle both channels and packages. This will get placed into `/home/<user>/.local/state/nix/` - Second, is to let it all be symlinked into `nix/var/nix/profiles/per-user/<user>`. (This is handled by systemd-tmpfiles under `nix-setup-systemd` pkg. But very likely default installations do not enable system-tmpfiles for user, it'll likely be enabled globally, but user needs to enable manually) ## Current setup - nix-setup-systemd ends up setting symlinks for per-user into the user directory here: - /usr/share/user-tmpfiles.d/nix-daemon.conf - nix-setup-systemd also ends up setting up the NIX_PATH to per-user dir above making the assumption that it was completed in this file: - `/usr/lib/environment.d/nix-daemon.conf` Firstly, this will fail in default installations since there is unless the user enabled the systemd tmpfiles per user with ``` systemctl --user --now enable systemd-tmpfiles-setup.service ``` These symlinks will never be created and it's not in any of the docs. But after enabling, this sets up for the profile, but not for channels. It should also include symlinks for channels. This results in a broken installation, as `nix-env` will work after adding user channel as described in the docs. However all attempts to do `nix-shell -p <pkg>` will error due to: ``` warning: Nix search path entry '/nix/var/nix/profiles/per-user/<user>/channels/nixpkgs' does not exist, ignoring warning: Nix search path entry '/nix/var/nix/profiles/per-user/<user>/channels' does not exist, ignoring error: … <borked> at «none»:0: (source not available) … while calling the 'import' builtin ``` This is because there is no such symlink and NIX_PATH is set to the non-existent path. ## Current contents of ``` 4 #Type Path Mode UID GID Age Argument 3 d %h/.nix-defexpr 2 L %h/.nix-defexpr/channels_root - - - - /nix/var/nix/profiles/per-user/root/channels 1 d /nix/var/nix/profiles/per-user/%u 0755 5 L %h/.nix-profile - - - - /nix/var/nix/profiles/per-user/%u/profile 1 d /nix/var/nix/gcroots/per-user/%u 0755 ``` ## Solutions ### Solution 1 Simplest. Remove excess config. - Remove the symlinks entirely. Move /usr/share/user-tmpfiles.d/nix-daemon.conf to docs to remove depending on systemd-tmp files. - Remove `NIX_PATH` in /usr/lib/environment.d/nix-daemon.conf. When NIX_PATH is not set, nix handles the user profile automatically and works well. (unset NIX_PATH in the shell can workaround this at the moment neatly) ### Solution 2 More nix data inside /nix store - Add channels to the symlink in /usr/share/user-tmpfiles.d/nix-daemon.conf. - Auto-enable `systemctl --user enable systemd-tmpfiles-setup.service`? ProblemType: Bug DistroRelease: Ubuntu 24.04 Package: nix-setup-systemd 2.18.1+dfsg-1ubuntu5 ProcVersionSignature: Ubuntu 6.8.0-31.31-generic 6.8.1 Uname: Linux 6.8.0-31-generic x86_64 ApportVersion: 2.28.1-0ubuntu2 Architecture: amd64 CasperMD5CheckResult: pass CurrentDesktop: ubuntu:GNOME Date: Thu May 2 12:44:59 2024 InstallationDate: Installed on 2024-04-26 (6 days ago) InstallationMedia: Ubuntu 24.04 LTS "Noble Numbat" - Release amd64 (20240424) PackageArchitecture: all SourcePackage: nix UpgradeStatus: No upgrade log present (probably fresh install) # Context - nix-bin can be setup in 2 ways.   - One is to let .nix-defer user local directory handle both channels and packages. This will get placed into `/home/<user>/.local/state/nix/`   - Second, is to let it all be symlinked into `nix/var/nix/profiles/per-user/<user>`. (This is handled by systemd-tmpfiles under `nix-setup-systemd` pkg. But very likely default installations do not enable system-tmpfiles for user, it'll likely be enabled globally, but user needs to enable manually) ## Current setup - nix-setup-systemd ends up setting symlinks for per-user into the user directory here:   - /usr/share/user-tmpfiles.d/nix-daemon.conf - nix-setup-systemd also ends up setting up the NIX_PATH to per-user dir above making the assumption that it was completed in this file:   - `/usr/lib/environment.d/nix-daemon.conf` Firstly, this will be borked config in default installations unless the user enabled the systemd tmpfiles per user with ``` systemctl --user --now enable systemd-tmpfiles-setup.service ``` These symlinks will never be created and it's not in any of the docs. But after enabling, this sets up for the profile, but not for channels. It should also include symlinks for channels. This results in a broken installation, as `nix-env` will work after adding user channel as described in the docs. However all attempts to do `nix-shell -p <pkg>` will error due to: ``` warning: Nix search path entry '/nix/var/nix/profiles/per-user/<user>/channels/nixpkgs' does not exist, ignoring warning: Nix search path entry '/nix/var/nix/profiles/per-user/<user>/channels' does not exist, ignoring error:        … <borked>          at «none»:0: (source not available)        … while calling the 'import' builtin ``` This is because there is no such symlink and NIX_PATH is set to the non-existent path. ## Current contents of ```   4 #Type Path Mode UID GID Age Argument   3 d %h/.nix-defexpr   2 L %h/.nix-defexpr/channels_root - - - - /nix/var/nix/profiles/per-user/root/channels   1 d /nix/var/nix/profiles/per-user/%u 0755   5 L %h/.nix-profile - - - - /nix/var/nix/profiles/per-user/%u/profile   1 d /nix/var/nix/gcroots/per-user/%u 0755 ``` ## Solutions ### Solution 1 Simplest. Remove excess config. - Remove the symlinks entirely. Move /usr/share/user-tmpfiles.d/nix-daemon.conf to docs to remove depending on systemd-tmp files. - Remove `NIX_PATH` in /usr/lib/environment.d/nix-daemon.conf. When NIX_PATH is not set, nix handles the user profile automatically and works well. (unset NIX_PATH in the shell can workaround this at the moment neatly) ### Solution 2 More nix data inside /nix store - Add channels to the symlink in /usr/share/user-tmpfiles.d/nix-daemon.conf. - Auto-enable `systemctl --user enable systemd-tmpfiles-setup.service`? ProblemType: Bug DistroRelease: Ubuntu 24.04 Package: nix-setup-systemd 2.18.1+dfsg-1ubuntu5 ProcVersionSignature: Ubuntu 6.8.0-31.31-generic 6.8.1 Uname: Linux 6.8.0-31-generic x86_64 ApportVersion: 2.28.1-0ubuntu2 Architecture: amd64 CasperMD5CheckResult: pass CurrentDesktop: ubuntu:GNOME Date: Thu May 2 12:44:59 2024 InstallationDate: Installed on 2024-04-26 (6 days ago) InstallationMedia: Ubuntu 24.04 LTS "Noble Numbat" - Release amd64 (20240424) PackageArchitecture: all SourcePackage: nix UpgradeStatus: No upgrade log present (probably fresh install)