** Description changed:

  # 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) 
+ - 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 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`
+   - `/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
+ 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  
+ 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 
- 
+ ## 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                             
                                                                   
+   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. 
+ - 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)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2064563

Title:
  Broken default installation of nix-bin and nix-setup-systemd

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nix/+bug/2064563/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to