Skip to content

Switch to Nix 2.0 - #34636

Merged
Mic92 merged 38 commits into
masterfrom
nix-2.0
Mar 3, 2018
Merged

Mic92 merged 38 commits into
masterfrom
nix-2.0

Conversation

@edolstra

@edolstra edolstra commented Feb 5, 2018

Copy link
Copy Markdown
Member

Hopefully we can switch to Nix 2.0 for NixOS 18.03. Nix 2.0 should be released in the next few weeks. This PR makes 2.0 the default (by temporarily pointing nix to nixUnstable) and updates nixos-install to work with it. It also adds a command nixos-enter that factors out the functionality of nixos-install --chroot.

This factors out the functionality in nixos-install for running a
command inside a NixOS installation (nixos-install --chroot).
The use of Nix 2.0 significantly simplifies the installer, since we
can just pass a different store URI (--store /mnt) - it's no longer
needed to set up a chroot environment for the build, and to bootstrap
Nix into the chroot.

Also, commands that need to run in the installation (namely boot
loader installation and setting a root password) are now executed
using nixos-enter.

This also removes the need for nixos-prepare-root since any required
initialisation is done by Nix or by the activation script.
@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Feb 5, 2018
@FRidh FRidh added this to the 18.03 milestone Feb 5, 2018
@grahamc grahamc added the 9.needs: changelog This PR needs a changelog entry label Feb 5, 2018
@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Feb 5, 2018
It requires the existence of /proc.
The activation script already does this.
...so it appears in a new installation before rebooting the system.
The boot test now runs "nix verify" to ensure that all hashes are
correct.
E.g.

  nixos-install --root /tmp/mnt/ --no-bootloader --no-root-passwd

now works for non-root users.
This is already provided by devtmpfs.
Of course, you'll get a bunch of warnings from the activation script:

  $ nixos-enter --root /tmp/mnt/
  setting up /etc...
  mount: /dev: permission denied.
  mount: /dev/pts: permission denied.
  mount: /dev/shm: permission denied.
  mount: /sys: permission denied.
  /nix/var/nix/profiles/system/activate: line 74: /proc/sys/kernel/modprobe: Permission denied
  chown: changing ownership of '/run/wrappers/wrappers.0pKlU8JsvV/dbus-daemon-launch-helper': Invalid argument
  NOTE: Under Linux, effective file capabilities must either be empty, or
        exactly match the union of selected permitted and inheritable bits.
  Failed to set capabilities on file `/run/wrappers/wrappers.0pKlU8JsvV/ping' (Operation not permitted)
  chown: changing ownership of '/run/wrappers/wrappers.0pKlU8JsvV/unix_chkpwd': Invalid argument

  [root@nixos:/]#
This is useful in tests where we don't have network access. Passing
--substituters "" prevents wasting time by checking cache.nixos.org.
Since nixos-install doesn't require any special privileges anymore,
this Just Works. No more need for fakeroot / nixos-prepare-root.
This is no longer needed thanks to Nix 2.0 magic.
@dezgeg

dezgeg commented Feb 7, 2018

Copy link
Copy Markdown
Contributor

Do these installer changes also fix #27307 ?


# Run the activation script. Set $LOCALE_ARCHIVE to supress some Perl locale warnings.
LOCALE_ARCHIVE=$system/sw/lib/locale/locale-archive chroot "$mountPoint" "$system/activate" >&2 || true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bind mounting /etc/resolv.conf would be nice to have, if this tool is supposed to be a general-purpose tool.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that would be nice.

# Copy the NixOS/Nixpkgs sources to the target as the initial contents
# of the NixOS channel.
if [[ -z $noChannelCopy ]]; then
if [[ -z $channelPath ]]; then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, does this make the channel optional? I was just thinking of adding that feature to make-disk-image.nix, since it's quite annoying in many situations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it was already optional since we had the --no-channel-copy flag.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I guess I just haven't exposed that in the disk image machinery. I'll probably take a look after this is merged.

@Ericson2314

Copy link
Copy Markdown
Member

Looks like the hydra job (and of borg) have passed it?!?!?!

@edolstra

Copy link
Copy Markdown
Member Author

@vcunat Jobset is all green now so this should be good to merge.

@edolstra edolstra changed the title [WIP] Switch to Nix 2.0 Switch to Nix 2.0 Mar 2, 2018

@shlevy shlevy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@Ericson2314

Ericson2314 commented Mar 2, 2018 •

Copy link
Copy Markdown
Member

....did @vcunat want to have a final say on this, or @edolstra did you just ping him as one of the release managers?

@edolstra

edolstra commented Mar 2, 2018

Copy link
Copy Markdown
Member Author

Yeah, it should be up to the release managers.

@vcunat

vcunat commented Mar 2, 2018

Copy link
Copy Markdown
Member

If you feel it's ready, I believe you can go along. I haven't found time to really read the changes yet.

@copumpkin

Copy link
Copy Markdown
Member

I haven't had a chance to test the image building changes yet, but don't let me hold you up. If something goes wrong, I'll fix it or talk to you 😄

@7c6f434c

7c6f434c commented Mar 2, 2018

Copy link
Copy Markdown
Member

Now that the builds are performed in the target store, should it be documented that to have /tmp for the build also in the target filesystem, the user should set TMPDIR? (Or do I misunderstand the situation?)

url = "http://nixos.org/releases/nix/${name}/${name}.tar.xz";
sha256 = "0ca5782fc37d62238d13a620a7b4bff6a200bab1bd63003709249a776162357c";
};
}) // { perl-bindings = nixStable; };

@vcunat vcunat Mar 3, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edolstra: is it intentional that perl-bindings for nix1 come from are nix2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I see it's wrong, as nixStable itself has no perl stuff inside, but I still don't know surely if it should be nixStable.perl-bindings or perl-bindings { nix = nix1; }.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that looks like a mistake. That isn't even Nix 2's perl bindings.

@vcunat vcunat added 8.has: changelog This PR adds or changes release notes and removed 9.needs: changelog This PR needs a changelog entry labels Mar 3, 2018

@vcunat vcunat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binding issue seems a nitpick, really. It's only referenced by hydra and that seems unlikely to be used with nix1 anymore...

I can't see any other problem.

@vcunat vcunat closed this Mar 3, 2018
@vcunat
vcunat deleted the nix-2.0 branch March 3, 2018 17:12
@Mic92
Mic92 merged commit 729d72f into master Mar 3, 2018
@vcunat

vcunat commented Mar 3, 2018

Copy link
Copy Markdown
Member

^^ hehe, GitHub confusing people again. I have reported such case to them once or twice during the past year or two, but apparently it still happens sometimes.

@vcunat

vcunat commented Mar 3, 2018

Copy link
Copy Markdown
Member

Possibly a problem: #36268

@dezgeg

dezgeg commented Apr 14, 2018

Copy link
Copy Markdown
Contributor

I think these changes caused #38477. Previously, a mount --rbind /sys was done, but no longer, so I bet efivarfs is not getting mounted inside the nixos-enter chroot anymore.

@Janik-Haag Janik-Haag added the 12.first-time contribution This PR is the author's first one; please be gentle! label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 12.first-time contribution This PR is the author's first one; please be gentle!

Projects

None yet

Development

Successfully merging this pull request may close these issues.