Skip to content
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

New flake install instructions #740

Open
bestlem opened this issue Jul 13, 2023 · 12 comments
Open

New flake install instructions #740

bestlem opened this issue Jul 13, 2023 · 12 comments

Comments

@bestlem
Copy link

bestlem commented Jul 13, 2023

They don"t work.

The documentation needs to also say when editing flake.nix

Edit the two "simple" in the end of the file to the first part of the machine name (not including any .local or other domain) m

9OK mine now also fails due to lack of all the build users - but I think that is a bug #681 The default for new users should not need the extra line that is recommennded. Begginer documentation MUST be exact so the user can copy and paste the example and comments like edit this file and not good but can be dealt with but asking a begginner to set a variable does not work as where in the file does that edit get done.
And the response #681 (comment) looks like it is wrong to me as the steps listed here don"t work without the added line to suppress the check.

@emilazy
Copy link
Collaborator

emilazy commented Jul 13, 2023

The documentation needs to also say when editing flake.nix

Edit the two "simple" in the end of the file to the first part of the machine name (not including any .local or other domain) m

The flake installation instructions say the following:

Make sure to replace all occurrences of simple with your short hostname which you can find by running hostname -s.

Could you suggest how we could make this more clear for beginners?

9OK mine now also fails due to lack of all the build users - but I think that is a bug #681 The default for new users should not need the extra line that is recommennded. Begginer documentation MUST be exact so the user can copy and paste the example and comments like edit this file and not good but can be dealt with but asking a begginner to set a variable does not work as where in the file does that edit get done. And the response #681 (comment) looks like it is wrong to me as the steps listed here don"t work without the added line to suppress the check.

Are you using the Determinate Systems experimental nix-installer? That's not an officially-supported way to install Nix, and has some issues currently, although it's good software and we do try to support it. They tried avoiding user creation on macOS as an experiment, but it doesn't work properly and they disabled it. That was released as v0.10.0, so if you do a clean install with the same installer now you shouldn't have the same problem.

We could disable the build users check unconditionally, but it may make things more brittle for people using the official installer or the latest version of Determinate Systems' unofficial one. auto-allocate-uids doesn't really work on macOS yet, unfortunately, so it's not clear if we should be supporting it.

@bestlem
Copy link
Author

bestlem commented Jul 13, 2023

The documentation needs to also say when editing flake.nix
Edit the two "simple" in the end of the file to the first part of the machine name (not including any .local or other domain) m

The flake installation instructions say the following:

Make sure to replace all occurrences of simple with your short hostname which you can find by running hostname -s.

Could you suggest how we could make this more clear for beginners?

Make the highlighting the same for the 'simple' and the change in architecture.

I don"t have a large enough screen to have the instructions beside my editor so when I switched back my eyes were drawn to the highlighted issue.

As for the nix-installer I seem tom have the broken version i reported on the bug. I just seem to have bad timing.

@bestlem
Copy link
Author

bestlem commented Jul 14, 2023

Another way might be to number each substep - e.g. i) for the flake creation ii) for edit name then add not for architecture as step iii)

@bestlem
Copy link
Author

bestlem commented Jul 14, 2023

As it is I now do have in a new VM a path of

> echo $PATH                                                                    ~/.config/nix-darwin
/Users/dev/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin

But after a reboot - which I think is needed to create the /run entry

> darwin-rebuild switch --flake ~/.config/nix-darwin                                  ~/.config/nix-darwin
zsh: command not found: darwin-rebuild
> ls /run/current-system                                                              ~/.config/nix-darwin
ls: /run/current-system: No such file or directory
> sudo cat /etc/synthetic.conf                                                        ~/.config/nix-darwin
nix
run	private/var/run


@emilazy
Copy link
Collaborator

emilazy commented Jul 15, 2023

Are you sure the activation ran correctly? For instance was there an error about your nix.conf hash? (A reboot should not be required.)

@bestlem
Copy link
Author

bestlem commented Jul 15, 2023

Yes there was an errro about /.etc/nix and doing a clean install again and removing that with a rerun worked.

The Deterministic Systems Installer added the /etc/nix so that gave me the issue but it is now working

Sorry for the noise here.

@emilazy
Copy link
Collaborator

emilazy commented Jul 15, 2023

#731 should fix the partial activation and give a clearer error in that case. Will leave this open for the docs issue.

@frencojobs
Copy link

I also installed nix using deterministic system's installer and it wrote /etc/nix/nix.conf. Now, nix-darwin is asking me to either remove it or rename it as a backup. These are the content of the file, as generated by the installer.

# Generated by https://github.com/DeterminateSystems/nix-installer, version 0.10.0.
build-users-group = nixbld
bash-prompt-prefix = (nix:$name)\040
auto-optimise-store = true
extra-nix-path = nixpkgs=flake:nixpkgs
experimental-features = nix-command flakes auto-allocate-uids

Is it safe to just remove them? I'm aware the last line will be generated by nix-darwin because it's configured in flake.nix like this,

# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";

But, shouldn't I also add configurations like this, so that the original behavior from installer is restored?

nix.settings.build-users-group = "nixbld"

@Enzime
Copy link
Collaborator

Enzime commented Jul 25, 2023

@frencojobs build-users-group defaults to nixbld when using the Nix daemon, so it's not necessary to explicitly specify, but you can add it to your config if you'd like

@dstcruz
Copy link
Contributor

dstcruz commented Sep 13, 2023

If you comes here from having a fresh nix install, might be nice to point out that the --extra-experimental-features is needed for doing a flake install? Would be nice for simpler copy-pasta of the command, like:

> cd my-flake-directory
> nix --extra-experimental-features 'nix-command flakes' run nix-darwin -- switch --flake .#simple

Unless you guys think it is pretty safe to assume that if someone is trying to do a flakes based system they would already know this.

@britter
Copy link

britter commented Oct 27, 2023

I've also installed Nix using the Determinate Systems installer. After initializing a nix-darwin flake using nix init flake -t nix-darwin I ran into the problem reported by @frencojobs. I fixed by renaming nix.conf and running the command suggested by @dstcruz. I can now switch my system using nix run nix-darwin -- switch --flake .. However I don't have darwin-rebuild in my PATH which is why I get

darwin-rebuild switch --flake .
fish: Unknown command: darwin-rebuild

Any advice on how to get darwin-rebuild into PATH?

EDIT: I think I ran into #122. I fixed this using the following workaround: #122 (comment)

@ydewit
Copy link

ydewit commented Mar 7, 2024

I installed nix using Determinate Systems' installer and then I installed nix-darwin.

This is what Determinate Systems installed for /etc/nix/nix.conf:

# Generated by https://github.com/DeterminateSystems/nix-installer.
# See `/nix/nix-installer --version` for the version details.

build-users-group = nixbld
experimental-features = nix-command flakes repl-flake
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
extra-nix-path = nixpkgs=flake:nixpkgs
upgrade-nix-store-path-url = https://install.determinate.systems/nix-upgrade/stable/universal

And this is what nix-darwin wrote for /etc/nix/nix.conf (it renamed the previous one to nix.conf.before-nix-darwin:

# WARNING: this file is generated from the nix.* options in
# your nix-darwin configuration. Do not edit it!
allowed-users = *
auto-optimise-store = false
build-users-group = nixbld
builders = 
cores = 0
experimental-features = nix-command flakes repl-flake
extra-sandbox-paths = 
max-jobs = auto
require-sigs = true
sandbox = false
sandbox-fallback = false
substituters = https://cache.nixos.org/
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
trusted-substituters = 
trusted-users = root

The nix-darwin install succeeded but I was not able to install packages even with a plain nix-shell -p .... And the reason is that nix.conf was missing extra-nix-path = nixpkgs=flake:nixpkgs.

I then added the following to nix-darwin's flake.nix and things started to work again:

      ...
      nix.settings.experimental-features = "nix-command flakes repl-flake";
      nix.settings.extra-nix-path = "nixpkgs=flake:nixpkgs";
      ...

Note that I also added the experimental-features line to make sure that repl-flake was enabled (it is enabled in the Determinate Systems install).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants