Debian install fails if nix is already installed?

Hello all! I’ve been curious about using flox for a while. I finally had some time to install it.

The install experience didn’t go well:

pvieira@erisk:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy
pvieira@erisk:~$ 
pvieira@erisk:~$ nix --version
nix (Nix) 2.11.1
pvieira@erisk:~$ pvieira@erisk:~$ 
pvieira@erisk:~$ sudo dpkg -i ./flox.deb 
[sudo] password for pvieira: 
Selecting previously unselected package flox.
(Reading database ... 72011 files and directories currently installed.)
Preparing to unpack ./flox.deb ...
Unpacking flox (0.0.6-r58) ...
Setting up flox (0.0.6-r58) ...
Detected prior nix installation not performed using this package
dpkg: error processing package flox (--install):
 installed flox package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
 flox
pvieira@erisk:~$ 

So something goes wrong after the “Detected prior nix installation not performed using this package” step

I then created a fresh VPS on Hetzner Cloud with ubuntu 22.04 again. I did not install nix. The install succeeded!

pvieira@ubuntu-4gb-hel1-2:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy
pvieira@ubuntu-4gb-hel1-2:~$
pvieira@ubuntu-4gb-hel1-2:~$ sudo dpkg -i ./flox.deb
Selecting previously unselected package flox.
(Reading database ... 66833 files and directories currently installed.)
Preparing to unpack ./flox.deb ...
Unpacking flox (0.0.6-r58) ...
Setting up flox (0.0.6-r58) ...
Created symlink /etc/systemd/system/sockets.target.wants/nix-daemon.socket → /lib/systemd/system/nix-daemon.socket.
Created symlink /etc/systemd/system/multi-user.target.wants/nix-daemon.service → /lib/systemd/system/nix-daemon.service.
Processing triggers for man-db (2.10.2-1) ...
pvieira@ubuntu-4gb-hel1-2:~$ flox -v
Updating /home/pvieira/.config/flox/nix.conf
Updating /home/pvieira/.config/flox/gitconfig
+ NIX_REMOTE= NIX_SSL_CERT_FILE=/nix/store/5djs4y38r24s6n0lw3mx7x28lrc27p55-nss-cacert-3.83/etc/ssl/certs/ca-bundle.crt NIX_USER_CONF_FILES=/home/pvieira/.config/flox/nix.conf GIT_CONFIG_SYSTEM=/home/pvieira/.config/flox/gitconfig /nix/store/mlgmwa1m9zhqsayyh435afdwlnbgbsvc-flox-0.0.6-r58/libexec/flox/nix flake metadata github:flox/floxpkgs/master --no-write-lock-file --json 
warning: input 'capacitor' has an override for a non-existent input 'root'

One note that might be relevant: the nix install I have is the “Single-user installation”, as detailed here: Download Nix / NixOS | Nix & NixOS . I was wondering if this was the cause of the problem so I created yet another fresh VPS on Hetzner, where I installed the “Multi-user installation” before trying to install flox. Unfortunatelly I got the same error, though this time the installer seems to have advanced some more?

pvieira@ubuntu-2gb-hel1-1:~$ 
pvieira@ubuntu-2gb-hel1-1:~$ sudo dpkg -i ./flox.deb
[sudo] password for pvieira: 
Selecting previously unselected package flox.
(Reading database ... 40412 files and directories currently installed.)
Preparing to unpack ./flox.deb ...
Unpacking flox (0.0.6-r58) ...
Setting up flox (0.0.6-r58) ...

Configuration file '/etc/nix/nix.conf'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nix.conf (Y/I/N/O/D/Z) [default=N] ? D
--- /etc/nix/nix.conf   2022-11-29 14:04:33.909957808 +0000
+++ /etc/nix/nix.conf.dpkg-new  1980-01-01 00:00:00.000000000 +0000
@@ -1,2 +1,37 @@
-
 build-users-group = nixbld
+
+# Auto-scale builders
+max-jobs = auto
+cores = 0
+
+# Use sandboxed builds
+sandbox = true
+extra-sandbox-paths =
+
+# Default to use the upstream cache as well as the flox public store. Since not all paths in the
+# flox store are signed currently, we have to add trusted=1
+substituters = https://cache.nixos.org/
+trusted-substituters = https://cache.floxdev.com?trusted=1
+trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= flox-store-public-0:8c/B+kjIaQ+BloCmNkRUKwaVPFWkriSAd0JJvuDu4F0=
+
+# Hard-link files by file content address
+auto-optimise-store = true
+
+# Basic trust settings
+require-sigs = true
+trusted-users = nix @wheel
+allowed-users = *
+builders =
+
+# Expose functionality
+system-features = nixos-test benchmark big-parallel kvm
+sandbox-fallback = false
+
+# Keep compilers and such when running GC
+keep-outputs = true
+
+# Keep derivations when running GC
+keep-derivations = true
+
+# Enable required features
+experimental-features = nix-command flakes

Configuration file '/etc/nix/nix.conf'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nix.conf (Y/I/N/O/D/Z) [default=N] ? 
groupadd: group 'nixbld' already exists
dpkg: error processing package flox (--install):
 installed flox package post-installation script subprocess returned error exit status 9
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
 flox
pvieira@ubuntu-2gb-hel1-1:~$
pvieira@ubuntu-2gb-hel1-1:~$ sudo dpkg -i ./flox.deb
(Reading database ... 40571 files and directories currently installed.)
Preparing to unpack ./flox.deb ...
Unpacking flox (0.0.6-r58) over (0.0.6-r58) ...
Setting up flox (0.0.6-r58) ...
groupadd: group 'nixbld' already exists
dpkg: error processing package flox (--install):
 installed flox package post-installation script subprocess returned error exit status 9
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
 flox
pvieira@ubuntu-2gb-hel1-1:~$ 

I hope this can help to improve this installer. I’m available to try a new version when these problems are solved.

Hi there! Thanks for the feedback! We don’t support installing over an existing Nix installation on Linux. We should probably clarify the docs and error message as well as move the check for an existing Nix installation earlier in the installation script

Hi @paulovieira,

I just wanted to clarify the above slightly to say that we support the following options in the presence of a preexisting Nix installation:

  1. replacing the Nix installation with one managed by Flox
    • in which case we will ensure that your Nix version is up to date with all the required configuration settings
  2. installing flox using the existing Nix installation as documented in the Nix/Generic tab of the installation guide
    • in which case you will need to ensure that your Nix version is up to date with all the required configuration settings over time
      • we will provide hints as required when we notice missing settings or versions are out of date

If you’re a long-time Nix user then we would suggest going with option 2, but if you’re only just starting with Nix then we’re aiming to make the experience much better with option 1.

So what if you’ve already started down the path of installing Nix and want to revert to option 1 - what should you do? Ideally you would simply uninstall Nix and then install flox but unfortunately there is no one-step uninstaller for Nix (although there are a few recipes out there, e.g. this one for Mac).

Fortunately, our installers wrap the Nix installer, so should be able to adopt/reconfigure a preexisting Nix installation. As you’ve noted this isn’t working perfectly at the moment but we are working on it, and in the meantime we’ve found that the following method works for folks wanting to replace an existing Nix installation on Debian-based systems:

  • sudo rm -rf /nix
  • sudo dpkg -i flox.deb … select “Y” to replace nix.conf
  • sudo apt-get purge flox
  • sudo dpkg -i flox.deb … should work!

We’ll update this thread with further details as we work to improve the installer. Thanks again for the feedback!

Hello @limeytexan and @mkenigs !

Thanks for the detailed response!

After my initial post I noticed that my existing nix installation actually stopped working! I managed to solve the problem by completely uninstalling everything and re-install, but as you said, not everyone knows how to do that.

To clarify if the problem is really related to the .deb package or not, I created another 2 fresh VPS with ubuntu 22.04. I installed the “single-user” in one of them and the “multi-user” in the other. They were working fine before I executed sudo dpkg -i /path/to/flox.deb (as described in https://beta.floxdev.com/docs/getting-started/install-flox/). The main conclusions:

  • in both cases the .deb installation failed
  • in both cases the nix installation is messed up somewhat (at least nix-shell doesn’t work anymore!)

This is serious since I would assume most of the beta testers using that .deb package are people who already have nix.

Below is the full copy-paste of the shell output, if it helps.

Single-user output

pvieira@flox-demo-2:~$ nix-shell -p go --run "which go"
/nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/bin/go
pvieira@flox-demo-2:~$ 
pvieira@flox-demo-2:~$ systemctl status nix-daemon
Unit nix-daemon.service could not be found.
pvieira@flox-demo-2:~$ 
pvieira@flox-demo-2:~$ systemctl status nix-daemon.socket
Unit nix-daemon.socket could not be found.
pvieira@flox-demo-2:~$ 
pvieira@flox-demo-2:~$ sudo dpkg -i ./flox.deb
Selecting previously unselected package flox.
(Reading database ... 67048 files and directories currently installed.)
Preparing to unpack ./flox.deb ...
Unpacking flox (0.0.7-r76) ...
Setting up flox (0.0.7-r76) ...
Detected prior nix installation not performed using this package
dpkg: error processing package flox (--install):
 installed flox package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
 flox
pvieira@flox-demo-2:~$ 
pvieira@flox-demo-2:~$ nix-shell -p go --run "which go"
/nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/bin/go
pvieira@flox-demo-2:~$ exit
logout
Connection to 65.109.139.62 closed.
pvieira@pvieira-hp:~$ ssh 65.109.139.62
pvieira@65.109.139.62 password: 
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-46-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Dec  4 11:37:33 AM UTC 2022

  System load:  0.0                Processes:             130
  Usage of /:   11.0% of 37.23GB   Users logged in:       0
  Memory usage: 19%                IPv4 address for eth0: 65.109.139.62
  Swap usage:   0%                 IPv6 address for eth0: 2a01:4f9:c012:5526::1


0 updates can be applied immediately.


*** System restart required ***
Last login: Sun Dec  4 11:15:29 2022 from 85.242.76.100
pvieira@flox-demo-2:~$ nix-shell -p go --run "which go"
error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': No such file or directory
(use '--show-trace' to show detailed location information)
pvieira@flox-demo-2:~$ 
pvieira@flox-demo-2:~$ systemctl status nix-daemon.service
○ nix-daemon.service - Nix Daemon
     Loaded: loaded (/lib/systemd/system/nix-daemon.service; disabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:nix-daemon
             https://nixos.org/manual
pvieira@flox-demo-2:~$ 
pvieira@flox-demo-2:~$ systemctl status nix-daemon.socket
○ nix-daemon.socket - Nix Daemon Socket
     Loaded: loaded (/lib/systemd/system/nix-daemon.socket; disabled; vendor preset: enabled)
     Active: inactive (dead)
   Triggers: ● nix-daemon.service
     Listen: /nix/var/nix/daemon-socket/socket (Stream)
pvieira@flox-demo-2:~$ 

Note that I verified that there is no nix-daemon units before the flox installation (as expected in the single-user version). After the failed attempt to install flox, and after and a logout/login, I get errors related to nix-daemon.socket. It seems flox tries to add the nix-daemon units?

multi-user output

pvieira@flox-demo-3:~$
pvieira@flox-demo-3:~$ sudo dpkg -i ./flox.deb
Selecting previously unselected package flox.
(Reading database ... 67048 files and directories currently installed.)
Preparing to unpack ./flox.deb ...
Unpacking flox (0.0.7-r76) ...
Setting up flox (0.0.7-r76) ...

Configuration file '/etc/nix/nix.conf'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nix.conf (Y/I/N/O/D/Z) [default=N] ? N
groupadd: group 'nixbld' already exists
dpkg: error processing package flox (--install):
 installed flox package post-installation script subprocess returned error exit status 9
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
 flox
pvieira@flox-demo-3:~$
pvieira@flox-demo-3:~$ nix-shell -p go --run "which go"
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «string»:1:25:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (go) ]; } ""
             |                         ^
(use '--show-trace' to show detailed location information)
pvieira@flox-demo-3:~$
pvieira@flox-demo-3:~$ systemctl status nix-daemon.service
● nix-daemon.service - Nix Daemon
     Loaded: loaded (/etc/systemd/system/nix-daemon.service; linked; vendor preset: enabled)
     Active: active (running) since Sun 2022-12-04 11:27:19 UTC; 8min ago
TriggeredBy: ● nix-daemon.socket
       Docs: man:nix-daemon
             https://nixos.org/manual
   Main PID: 23134 (nix-daemon)
      Tasks: 3 (limit: 2258)
     Memory: 479.0M
        CPU: 15.548s
     CGroup: /system.slice/nix-daemon.service
             └─23134 nix-daemon --daemon
pvieira@flox-demo-3:~$
pvieira@flox-demo-3:~$ systemctl status nix-daemon.socket
● nix-daemon.socket - Nix Daemon Socket
     Loaded: loaded (/etc/systemd/system/nix-daemon.socket; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-12-04 11:27:19 UTC; 8min ago
   Triggers: ● nix-daemon.service
     Listen: /nix/var/nix/daemon-socket/socket (Stream)
     CGroup: /system.slice/nix-daemon.socket
pvieira@flox-demo-3:~$ 

In the multi-user attempt I chose the default action (N).

Thanks @paulovieira for the fantastic detail. We’ll put our heads together on this and get back to you with a better solution ASAP. :+1:

Hi @paulovieira - very sorry for the delay re an update but I have been advised the engineers pushed an update to the installer yesterday that based on our tests should fix this issue. If it persists, please do let us know.