Commit Graph

890 Commits

Author SHA1 Message Date
Guillaume Maudoux
36c560552d Create to daemon-socket folder during install
(cherry picked from commit 1bec333788)

[Bjørn: This fixes Nix 2.3 multi-user/daemon installs on modern
non-NixOS distros.]
2023-10-26 14:31:46 +02:00
Domen Kožar
eda79305b6
installer: use native aarch64-darwin 2021-07-02 14:08:01 +02:00
Alyssa Ross
a25f0a8730
install-multi-user.sh: add link to forum
Introduced in master in eab14a642c.
2021-06-02 08:32:47 +00:00
Patrick Hilhorst
c9dcfa50f8
throw freenode down the memory hole
(cherry picked from commit 822e338e5c)
2021-06-02 08:10:59 +00:00
Domen Kožar
406a70159a
Merge pull request #4805 from YorikSar/zsh-nix-profiles-2.3
Fix iterating over $NIX_PROFILES in Zsh (backport to 2.3)
2021-05-14 12:22:27 +02:00
Yuriy Taraday
419797128d Fix iterating over $NIX_PROFILES in Zsh
NIX_PROFILES is space separated list of directories, and passing it into
for as is is considered to be 1-element list with the whole string. With
shwordsplit option Zsh emulates other shells in this regard ans
implicitely splits unquoted strings into words.

Fixes #4167.
2021-05-14 12:09:58 +04:00
Travis A. Everett
dd50221e8a
fix nixbld user name/uid for macOS
(cherry picked from commit 0431cf6d09)
Signed-off-by: Domen Kožar <domen@dev.si>
2021-03-26 09:24:10 +01:00
Maximilian Bosch
85329cac35
scripts/install-nix-from-closure: only show progress if a terminal is used
While the progress dots during the copying of the store work fine on a
normal terminal, those look pretty off if the script is run inside a
provisioning script of e.g. `vagrant` or `packer` where `stderr` and
`stdout` are captured:

    default: .
    default: ..
    default: .
    default: .
    default: .

To work around this, the script checks with `-t 0` if it's
running on an actual terminal and doesn't show the progress if that's not
the case.

(cherry picked from commit d9367a2dd1)
2021-01-25 20:14:10 +01:00
Travis A. Everett
6456941993
enable Darwin.arm64 to install x86_64 binary
Throwing @thefloweringash under the bus if this doesn't work, but it
sounds like Apple Silicon devices can use the x86_64 binary for now.

Fixes #4058

(cherry picked from commit 4864df6d6b)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-11-20 10:51:51 +01:00
Travis A. Everett
51a4a5e1cf
adapt to apfs.util flag diff in catalina/big sur
Fixes #3957. Just runs both forms to minimize moving parts.

(cherry picked from commit fe807904e5)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-10-20 12:21:45 +02:00
Travis A. Everett
613297a528
replace xpath with xmllint --xpath; simplify
As mentioned in previous commit, Big Sur changes the syntax for the
xpath command slightly.

In the process of testing out replacements for these, I noticed a few
small simplification wins.

(cherry picked from commit e736f8f6e4)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-10-20 12:21:45 +02:00
Travis A. Everett
72b8673e06
fix xpath and conditional bugs; xpath -> xmllint
- xpath -> xmllint: xpath's cli interface changed in Big Sur
  rather than add conditional logic for picking the correct
  syntax for xpath, I'm changing to xmllint --xpath, which
  appears to be consistent across versions I've tested...

- /plist/dict/key[text()='Writable']/following-sibling::true[1]
  doesn't do quite what's expected. It was written to try to
  select a <true /> node paired with the Writable key, but it
  will also select the *next* <true /> node that appears even
  if it was paired with another key.

- I think there's also a logic bug in the conditionals here.
  I'm not sure anyone ever actuall saw it, thanks to the xpath
  bug, though. With the xpath fix, this conditional passes if /nix
  does not exist, / IS writable, and the version is Catalina+.

  I think it meant to test for /nix does not exist, / is NOT
  writable, and the version is Catalina+. I reworked this lightly
  to make it a little clearer at the code level.

(cherry picked from commit 1f02b65c59)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-10-20 12:21:44 +02:00
Travis A. Everett
14c7e77bc4
update macOS version handling for Big Sur
Keeping this commit narrow for reviewability, but some of these
conditionals will change in subsequent commits in this PR.

Fixes #3852.

(cherry picked from commit 9c3dc9d7ca)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-10-20 12:21:41 +02:00
Eelco Dolstra
00a52f61f4
Installer: Set a known umask
Fixes #1560, #2377.

(cherry picked from commit 924712eef1)
2020-10-12 16:57:26 +02:00
Jörg Thalheim
4281bc6227
docs/installer: add correct curl flags
also see https://nixos.org/download.html

(cherry picked from commit 3685f4eec6)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-07-08 14:20:54 +02:00
Daiderd Jordan
a836abc5bd
installer: don't require xz on darwin
On macOS the system tar has builtin support for lzma while xz isn't
available as a separate binary.  There's no builtin package manager
there available either so having to install lzma (without nix) would be
rather painful.

(cherry picked from commit 4e6d7cb55a)
2020-05-28 12:29:03 +02:00
Domen Kožar
e15dc6783a
installer: fix unused variable
(cherry picked from commit 3d3c219d91)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 16:23:25 +02:00
Domen Kožar
f117c54318
Fix installer script bugs
- --no-channel-add didn't have effect on multi-user installation
- some new flags didn't work at all
- document all installer flags

(cherry picked from commit 1a5ac894e9)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 15:51:40 +02:00
Domen Kožar
6c96858cad
Allow passing extra nix.conf to installer
(cherry picked from commit 573ff8dfca)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:04 +02:00
Domen Kožar
0c478b103b
install-multi-user: allow overriding user count
(cherry picked from commit 90b0c630a0)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:04 +02:00
Domen Kožar
b90d289785
scripts/create-darwin-volume.sh: remove unused variable
(cherry picked from commit 2a7ea2eb6c)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:04 +02:00
Daiderd Jordan
6117afc4b8
installer: don't clobber synthetic.conf
(cherry picked from commit d3df1889a1)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:03 +02:00
Travis A. Everett
248c9f7c78
focus on golden-path covering most scenarios
This should handle installation scenarios we can handle with
anything resembling confidence. Goal is approximating the existing
setup--not enforcing a best-practice...

Approaches (+ installer-handled, - manual) and configs each covers:

+ no change needed; /nix OK on boot volume:
  All pre-Catalina (regardless of T2 or FileVault use)

+ create new unencrypted volume:
  Catalina, pre-T2, no FileVault

+ create new encrypted-at-rest volume:
  Catalina, pre-T2, FileVault
  Catalina, T2, no FileVault

- require user to pre-create encrypted volume
  Catalina, T2, FileVault

(cherry picked from commit 2b0a81d92d)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:03 +02:00
Daiderd Jordan
e61e8c2588
installer: refuse apfs volume creation when FileVault is enabled
(cherry picked from commit 477d7c2d07)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:03 +02:00
Daiderd Jordan
f9c6c0a764
install: make synthetic.conf and fstab checks stricter
(cherry picked from commit bc24c09968)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:03 +02:00
Daiderd Jordan
da5a1fad71
install: improve output and error handling
(cherry picked from commit 04f597c3f4)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:03 +02:00
Daiderd Jordan
ebfa913825
install: hide the store volume on darwin
(cherry picked from commit caface1980)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:03 +02:00
Daiderd Jordan
5a16236307
install: show macOS 10.15 message with --daemon
(cherry picked from commit 083bb3bbfc)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:03 +02:00
Daiderd Jordan
b05437f306
install: also configure ~/.zshenv
The default login shell for users on macOS 10.15 changed from bash to
zsh.  So while generally nonstandard we need to configure it to make nix
function out of the box on macOS.

(cherry picked from commit 10202628b9)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Daiderd Jordan
1c56f18a81
install: configure and bootstrap synthetic.conf on darwin
Starting macOS 10.15 /nix can't be creasted directly anymore due to the
readonly filesystem, but synthetic.conf was introduced to enable
creating mountpoints or symlinks for special usecases like package
managers.

(cherry picked from commit 0726ad5825)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Pavol Rusnak
a98841ff1b
Expose installer configuration environment variables via command line flags
(cherry picked from commit 9e12b2f5b8)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Pavol Rusnak
64db25b1f9
Introduce NIX_INSTALLER_NO_CHANNEL_ADD which skips nix-channel --add
(cherry picked from commit 46be11b762)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Greg Price
c4ce89f151
installer: Set files read-only when copying into store
After installing Nix, I found that all the files and directories
initially copied into the store were writable, with mode 644 or 755:

  drwxr-xr-x 9 root root 4096 Dec 31  1969 /nix/store/ddmmzn4ggz1f66lwxjy64n89864yj9w9-nix-2.3.3

The reason is that that's how they were in the unpacked tarball, and
the install-multi-user script used `rsync -p` without doing anything
else to affect the permissions.

The plain `install` script for a single-user install takes care to
do a `chmod -R a-w` on each store path copied.  We could do the same
here with one more command; or we can pass `--chmod` to rsync, to
have it write the files with the desired modes in the first place.

Tested the new `rsync` command on both a Linux machine with a
reasonably-modern rsync (3.1.3) and a Mac with its default, ancient,
rsync 2.6.9, and it works as expected on both.  Thankfully the latter
is just new enough to have `--chmod`, which dates to rsync 2.6.7.

(cherry picked from commit 26851dd2c2)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Philipp Middendorf
18b1e65158
installer: also test for xz to unpack
(cherry picked from commit 9450dece24)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Robert Hensing
a49950d817
README, error msg: http -> https
(cherry picked from commit 9080d5d924)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Eelco Dolstra
b278892471
nixos.org/releases -> releases.nixos.org
(cherry picked from commit e063c71a79)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Rovanion Luckey
c4702f938c
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

(cherry picked from commit a413594baf)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:02 +02:00
Michael Forney
47a12576ff
Pass -J to tar for xz decompression
Some tar implementations can't auto-detect compression formats, so
they must be specified explicitly.

(cherry picked from commit 43eb7b6756)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:01 +02:00
Eelco Dolstra
dd9c8a5f60
Remove $NIX_USER_PROFILE_DIR
This is not used anywhere.

(cherry picked from commit 1c3ccba0f5)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:01 +02:00
Michael Forney
8673883b40
Pass -P to cp to preserve symlinks
This is commonly the default behavior with -R, but POSIX leaves the
default unspecified.

(cherry picked from commit 10414d467b)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 11:39:01 +02:00
Greg Price
f5941e14e0
installer: Fix terminal colors.
The install-multi-user script uses blue, green, and red colors, as
well as bold and underline, to add helpful formatting that helps
structure its rather voluminous output.

Unfortunately, the terminal escape sequences it uses are not quite
well-formed.  The relevant information is all there, just obscured
by some extra noise, a leading parameter `38`.  Empirically, the
result is:

 * On macOS, in both Terminal.app and iTerm2, the spurious `38` is
   ignored, the rest of the escape sequence is applied, and the colors
   show up as intended.

 * On Linux, in at least gnome-terminal and xterm, the spurious `38`
   and the next parameter after it are ignored, and what's left is
   applied.  So in the sequence `38;4;32`, the 4 (underline) is
   ignored but the 32 (green) takes effect; in a more typical sequence
   like `38;34`, the 34 (blue) is ignored and nothing happens.

These codes are all unchanged since this script's origins as a
Darwin-only script -- so the fact that they work fine in common macOS
terminals goes some way to explain how the bug arose.

Happily, we can make the colors work as intended by just deleting the
extra `38;`.  Tested in all four terminals mentioned above; the new
codes work correctly on all of them, and on the two macOS terminals
they work exactly the same as before.

---

In a bit more technical detail -- perhaps more than anyone, me
included, ever wanted to know, but now that I've gone and learned it
I'll write it down anyway :) -- here's what's happening in these codes:

An ECMA-48 "control sequence" begins with `\033[` aka "CSI", contains
any number of parameters as semicolon-separated decimal numbers (plus
sometimes other wrinkles), and ends with a byte from 0x40..0x7e.  In
our case, with `m` aka "SGR", "Select Graphic Rendition".

An SGR control sequence `\033[...m` sets colors, fonts, text styles,
etc.  In particular a parameter `31` means red, `32` green, `34` blue,
`4` underline, and `0` means reset to normal.  Those are all we use.

There is also a `38`.  This is used for setting colors too... but it
needs arguments.  `38;5;nn` is color nn from a 256-color palette, and
`38;2;rr;gg;bb` has the given RGB values.

There is no meaning defined for `38;1` or `38;34` etc.  On seeing a
parameter `38` followed by an unrecognized argument for it, apparently
some implementations (as seen on macOS) discard only the `38` and
others (as seen on Linux) discard the argument too before resuming.

(cherry picked from commit 7313aa267b)
2020-04-10 10:49:33 +02:00
Eelco Dolstra
6c90e3b9ac install-multi-user.sh: Remove unused variables
https://hydra.nixos.org/build/104119659
(cherry picked from commit 2f96a89646)
2020-01-04 14:10:29 +01:00
Steven Shaw
e1fb586138 Fix unset variable in installer
(cherry picked from commit f0ec4b4ce4)
2020-01-04 14:09:14 +01:00
Matthew Bauer
7a011ded77 Copy instead of linking launch agent
On Catalina, the /nix filesystem might not be mounted at start time.
To avoid this service not starting, we need to keep the launch agent
outside of the Nix store. A wait4pid will hold for our /nix dir to be
mounted.

Fixes #3125.

(cherry picked from commit 0847f2f1b3)
2020-01-04 14:06:29 +01:00
Eelco Dolstra
0fb4744467
nix-env: Create ~/.nix-defexpr automatically
(cherry picked from commit c9159f86cc)
2019-10-10 00:00:58 +02:00
Eelco Dolstra
f66108f738
nix-env: Create ~/.nix-profile automatically
(cherry picked from commit 9348f9291e)
2019-10-10 00:00:54 +02:00
Eelco Dolstra
fe51fbaf81
Typo
(cherry picked from commit 9277e72cb0)
2019-10-09 23:58:55 +02:00
Eelco Dolstra
1c10f739eb
nix-profile.sh: Remove coreutils dependency
(cherry picked from commit 61a6176aca)
2019-10-09 23:57:41 +02:00
Eelco Dolstra
2522757e83
nix-profile.sh: Don't create .nix-channels
This is already done by the installer, so no need to do it again.

(cherry picked from commit 26762ceb86)
2019-10-09 23:57:35 +02:00
Eelco Dolstra
923b6bd83c
Remove some redundant initialization
(cherry picked from commit c43d9f6131)
2019-10-09 23:57:30 +02:00