Find a file
Rovanion Luckey a413594baf installer: Handle edge case where the nix-daemon is already running on the system
On a systemd-based Linux distribution: If the user has previously had multi-user Nix installed on the system, removed it and then reinstalled multi-user Nix again the old nix-daemon.service will still be running when `scripts/install-systemd-multi-user.sh` tries to start it which results in nothing being done and the old daemon continuing its run.

When a normal user then tries to use Nix through the daemon the nix binary will fail to connect to the nix-daemon as it does not belong to the currently installed Nix system. See below for steps to reproduce the issue that motivated this change.

$ sh <(curl https://nixos.org/nix/install) --daemon

$ sudo rm -rf /etc/nix /nix /root/.nix-profile /root/.nix-defexpr /root/.nix-channels /home/nix-installer/.nix-profile /home/nix-installer/.nix-defexpr /home/nix-installer/.nix-channels ~/.nix-channels ~/.nix-defexpr/ ~/.nix-profile /etc/profile.d/nix.sh.backup-before-nix /etc/profile.d/nix.sh; sed -i '/added by Nix installer$/d' ~/.bash_profile

$ unset NIX_REMOTE

$ sh <(curl https://nixos.org/nix/install) --daemon

└$ export NIX_REMOTE=daemon

└$ nix-env -iA nixpkgs.hello
installing 'hello-2.10'
error: cannot connect to daemon at '/nix/var/nix/daemon-socket/socket': No such file or directory
(use '--show-trace' to show detailed location information)

└$ sudo systemctl restart nix-daemon.service

└$ nix-env -iA nixpkgs.hello
installing 'hello-2.10'
these paths will be fetched (6.09 MiB download, 27.04 MiB unpacked):
  /nix/store/2g75chlbpxlrqn15zlby2dfh8hr9qwbk-hello-2.10
  /nix/store/aag9d1y4wcddzzrpfmfp9lcmc7skd7jk-glibc-2.27
copying path '/nix/store/aag9d1y4wcddzzrpfmfp9lcmc7skd7jk-glibc-2.27' from 'https://cache.nixos.org'...
copying path '/nix/store/2g75chlbpxlrqn15zlby2dfh8hr9qwbk-hello-2.10' from 'https://cache.nixos.org'...
building '/nix/store/w9adagg6vlikr799nkkqc9la5hbbpgmi-user-environment.drv'...
created 2 symlinks in user environment
2020-01-23 14:48:53 +01:00
.github Remove .github/FUNDING.yml 2019-07-23 15:21:23 +02:00
config update config/config.{sub,guess} 2018-08-13 20:00:17 +00:00
contrib function-trace: always show the trace 2019-09-18 23:23:21 +02:00
corepkgs Remove most of <nix/config.nix> 2019-11-26 22:07:28 +01:00
doc/manual doc: touchup release notes for 2.3 2020-01-14 00:14:03 -05:00
m4 autoconf: Fix C++17 detection not working on Ubuntu 16.04. 2019-07-03 04:32:25 +02:00
maintainers upload-release.pl: Fix sshfs call 2019-09-04 21:44:40 +02:00
misc Make nix-daemon.plist less fragile on macOS 2019-10-09 12:52:01 +01:00
mk Fix precompiled-headers generation 2019-12-05 20:26:24 +01:00
nix-rust Merge branch 'libarchive' of https://github.com/yorickvP/nix 2019-12-19 14:47:18 +01:00
perl Make the Store API more type-safe 2019-12-10 22:06:05 +01:00
scripts installer: Handle edge case where the nix-daemon is already running on the system 2020-01-23 14:48:53 +01:00
src Fix clang warning 2020-01-22 21:20:01 +01:00
tests Fix derivation computation with __structuredAttrs and multiple outputs 2020-01-21 21:14:13 +01:00
.dir-locals.el Add .dir-locals.el for Emacs 2016-01-28 11:12:04 +01:00
.editorconfig Add .editorconfig 2017-06-05 22:57:28 +01:00
.gitignore Merge pull request #2748 from edolstra/rust 2019-11-29 19:33:31 +01:00
.travis.yml travis: enable linux builds 2019-10-31 16:37:33 +00:00
.version Bump version 2019-09-04 15:59:33 +02:00
bootstrap.sh bootstrap: Simplify & make more robust. 2011-09-06 12:11:05 +00:00
configure.ac Merge branch 'libarchive' of https://github.com/yorickvP/nix 2019-12-19 14:47:18 +01:00
COPYING * Change this to LGPL to keep the government happy. 2006-04-25 16:41:06 +00:00
local.mk Shut up about deprecated functions 2019-12-10 13:44:49 +01:00
Makefile Add some Rust code 2019-11-26 22:07:28 +01:00
Makefile.config.in libarchive proof of concept 2019-12-07 22:35:14 +07:00
precompiled-headers.h Fix macOS build 2019-11-07 11:53:28 +01:00
README.md Add Open Collective 2019-07-18 10:57:26 +02:00
release-common.nix Merge branch 'libarchive' of https://github.com/yorickvP/nix 2019-12-19 14:47:18 +01:00
release.nix Test PRECOMPILE_HEADERS=0 2020-01-13 21:44:35 +01:00
shell.nix Fix Nixpkgs dependency 2020-01-13 21:11:56 +01:00

Open Collective supporters

Nix, the purely functional package manager

Nix is a new take on package management that is fairly unique. Because of its purity aspects, a lot of issues found in traditional package managers don't appear with Nix.

To find out more about the tool, usage and installation instructions, please read the manual, which is available on the Nix website at http://nixos.org/nix/manual.

Contributing

Take a look at the Hacking Section of the manual. It helps you to get started with building Nix from source.

License

Nix is released under the LGPL v2.1

This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit.