-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Multi user darwin installer #1453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👍 You should take a look at #1141 though. It mostly deals with Linux packaging but some of the code is similar. Ideally we could get a multi-user script for Linux too. |
Sounds good. I don't want to bog this down with general Linux support. I do want to get daemon support for the general Linux deployment case, but darwin is the easiest to start with I think. |
With this latest commit we have a chicken and the egg problem which is fixed by first merging #1454:
Step 2 is run due to #1449 The only difference between the instructions posted above and these here, are the profile was moved in to nix itself. |
Would it make sense to save |
d9199c3
to
e832b9f
Compare
Fixed, @veprbl. |
release.nix
Outdated
@@ -158,6 +158,9 @@ let | |||
substitute ${./scripts/install-nix-from-closure.sh} $TMPDIR/install \ | |||
--subst-var-by nix ${toplevel} \ | |||
--subst-var-by cacert ${cacert} | |||
shellcheck -e SC1090 $TMPDIR/install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does SC1090 mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SC1090: it doesn't know what . $var/file
means or resolves to, so it can't follow to /file
and figure out if your code is valid.
SC1091: similar to above, it can't source the file and statically check it.
SC2002: "Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead." except if I did sudo ... < thefile
it complains that sudo doesn't affect pipes.
I'll open PRs to apply this and 1454 to master, too. It is important that we release the updated nix version and it go out through to the nixpkgs-unstable channel prior to the installer being updated on nixos.org. Maybe this should be two separate version releases? .12 and then .13? |
Maybe patch releases? .12 and .12.1? |
These PRs are already to 1.11 though, so I meant 1.11.12 then 1.11.13. (as opposed to 1.11.12, 1.11.12.1) what do you think? |
e832b9f
to
98ac2a8
Compare
Right, I meant the thing you put in parens. Don't really care though :) |
I don't either :) |
Just tested the install script and it looks good 👍 |
|
Thanks @grahamc! A few comments/questions:
|
I don't disagree, but I take quite a bit of solace in the fact that almost all the code is either UI text output, or checking for problems before starting. This was an important goal to me, to make the experience friendly and help prevent as many problems at the outset as possible.
I was researching this last night. Travis-CI has macOS builders with root. If that works for you, I would be happy to make a thorough test suite for this code, using the travis-ci system. Unfortunately I don't think we can make this work in Hydra.
I disagree, because of the difficulties in the state transition. Being able to start clean and do the install the same way every time seems valuable. This removes any impurities caused by the single user model, for example NPM and Python tooling modifying the nix store. I think Nix's promise of reproduciblity makes this a safe and acceptable requirement for a user. Out of the many people I've had test this code, none of them balked at the idea of having to erase their store. Since the current code is only adding a small bit of code to the profiles now, we could remove the code performing backups.
I'd be totally happy to add a
I definitely agree, I don't like that either. I'm afraid of distributing configs with signed binary caches disabled, though. What would it take to patch and fix #1449? Fixing this would eliminate the need for this step, and allow users to benefit from signed binary caches.
We could do that. I thought about that, but liked the verbosity of the output, showing to the user exactly what was going on. Switching to a reexec (or asking them to run it under sudo directly) would make it hard to retain the verbosity, however I recognize that the verbosity may not be desirable. We could remove it.
Okay, I will remove that commit before this merges :) |
Thanks for the reply. Sounds good to me. Not super keen about depending on multiple CIs, but using Travis to test it is an option. (See #1152.) How does Travis give builders root? Using a VM? The libsodium issue is easily fixed, we could even do a new maintenance release for that. Stuff like a confirm flag can be added later if there is demand. |
It is possible to run macOS in Qemu: http://www.contrib.andrew.cmu.edu/%7Esomlo/OSXKVM/ and as far as I know the EULA says you can run 1 copy of macOS on 1 piece of Apple hardware. It'd be a bit of a waste to have a whole, capable Apple machine not running full-bore on other x86_64-darwin Hydra jobs. If we had an older Apple machine it could run Linux, have a If we got macOS-in-QEMU working, I'm not sure it is something we'd want in Nix's tree or Nixpkgs' tree ... it seems a bit tenuous, but maybe? I am not a lawyer. |
This uses the version I built last night:
|
scripts/install-nix-from-closure.sh
Outdated
fi | ||
|
||
printf '\e[1;31mSwitching to the Multi-User Darwin Installer\e[0m\n' | ||
"$self/install-darwin-multi-user" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exec
for that beautiful tail-call? :D
scripts/install-darwin-multi-user.sh
Outdated
|
||
echo "I am executing:" | ||
echo "" | ||
echo " $ sudo $cmd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider using printf %q
and not pass the command as a single string, lest there be any ambiguities.
…r root-owned files instead of making a scary warning.
9246e06
to
302e820
Compare
I deleted the first commit, and have added Travis tests. Still waiting on Travis to say if it passes. |
If https://travis-ci.org/grahamc/nix/builds/252864812 builds, it should be good to merge. I believe I have addressed all feedback. |
Err @grahamc for the printf " $ sudo"
printf " %q" "${cmd[@]}"
echo (
will print
|
except it is a single string due to the '$*': https://github.com/NixOS/nix/pull/1453/files#diff-2935a4d9174dece2a973aef5f0e25c97R213 |
93f315a
to
a31347d
Compare
fdd17b6
to
c821267
Compare
This PR passed on Travis: https://travis-ci.org/grahamc/nix/builds/253029042 and also closes #1459. |
Final build here:
|
Joy! |
FYI: this broke Need to change our short installation api or fix the script to not use stdin when it's taken. |
Furthermore, for example on travis-ci, we cache |
@grahamc Can we get an opt-out option in install-nix-from-closure.sh? It seems to me there are legitimate reasons to prefer single user install. Similarly, some sort of "quiet" option and a "noninteractive" option would be helpful when integrating this with CIs. |
@domenkozar I can't find where we cache Working on solutions here: 1.11-maintenance...grahamc:fix-stdin-errors
Opt-out? Hmm.. I'm not sure. I don't love nix without the daemon, and would rather we push everyone to the daemon. Do you have any specific example use cases that justifies the over-head of continuing to support single-user nix on macOS? Obviously advanced users will be able to go back to a single-user installation manually, but that is a different case as they're more prepared to handle the down sides. |
By Commit:
First commit makes iterating on the installers much faster, as it is able to cache the already built Nix. It includes a pattern I've begun to use, that if a dir contains a filed called
.nix-ignore-dir
, the directory is ignored. I can remove this commit if you don't like it.Second commit runs shellcheck on the existing installer file, and fixes numerous concerns it brought up. It seems a kindness to make sure these scripts operate as we expect.
Third commit extends the default installer to call a separate, darwin-specific installer to install a multi-user Nix, with the nix-daemon. I have now tested this process dozens of times on four different macs of my own, @LnL7's laptop, @copumpkin, @imalsogreg, and I think some others too. @wmertens is about to try it. It seems to work very well. I'm tracking this progress here: https://gitlab.com/grahamc/mac-nix-multi-user/issues/2
I have built this and uploaded the results:
or if you want to run the tests and try them over and over:
test.sh:
Closes #1061
cc @shlevy @matthewbauer @domenkozar