nix-darwin
nix-darwin copied to clipboard
Documentation, what's missing?
The readme is pretty basic at the moment. What should be added?
I'd like to add some documentation of using this with the fish shell. The syntax is only slightly different, but examples in the README.md would've saved me a couple minutes.
Aside: This is fantastic! Thanks so much for making and releasing it. Since I occasionally have iOS work, I'm basically stuck on Darwin (for now) and this might be the final push I need to fully ditch Homebrew in favor of Nix. I'm happy to help develop and test this in any way I can. Don't hesitate to reach out.
If you could contribute, would be great! I personally don't use fish so I'm not very familiar with it.
But I can probably add a programs.fish module myself based on the one from nixos, that sets up the nix-darwin environment properly.
Sounds good. I might have a go tonight, depending on whether we have company or not.
What can we do to simplify installation process? I am not a big fun of current approach.
I was thinking about publishing nix-darwin to nixpkgs repo as a package and just having a single CLI nix-darwin.
For me perfect scenario would be:
- install nix normally : curl https://nixos.org/nix/install | sh
- then install nix- darwin : nix-env -i nix-darwin
- optionally setup dotfiles : git clone [email protected]:user/dotfiles.git ~/.dotfiles && ~/.dotfiles/install.sh
- and just rebuild by : nix-darwin rebuild
nix-darwin should like now read default config, and optionally we could define NIX_PATH to use different darwin.
What do you think?
Even darwin name is available in nix registry, so darwin rebuild, darwin option, would be great! :D
Installing the nix-darwin scripts with nix-env doesn't really make a lot of sense to me, this entire project might move to nixpkgs at some point but that's a different story.
I should probably create a bootstrap script like https://nixos.org/nix/install that people can use to install. Since nix-darwin supports launchd services, it's also possible to provide a multi user installer for nix that uses the nix-daemon service, but that will be a bit harder to get right.
Could we add an example of using nixops?
Edit: Trying this now.
Update: I'm getting ssh errors running nixops deploy on top of nix-darwin even though I can [nixops] ssh just fine..
I assume you are talking about distributed builds. The options are the same as for nixos, but debugging issues with this is pretty hard because you don't get a lot of information to work with. These are some issues I've run into when setting it up:
NIX_CURRENT_LOADhas to exist (services.activate-systemwill do this for you)- the machine was not in the know_hosts yet, what's important to know is that when using the nix-daemon this has to be done for root
- the signing key was not setup properly, I have some instructions for that here https://github.com/LnL7/nix-docker#create-a-signing-keypair (I think this is not required when using the nix-damon)
WARNING: don't use nix-build --check to verify if this is working correctly, it always builds locally.
Yeah, I think your second point there might be my issue. Thanks.
@LnL7 some documentation around generations and rollback might be helpful. I'm a little confused as to how generations relate to nix-env generations.
E.g: if I run darwin-rebuild --rollback right now it rolls back from 31 to 30. However, nix-env --list-generations prints:
1 2017-07-07 12:21:35
2 2017-07-07 12:21:35
3 2017-08-06 02:01:47
4 2017-08-21 05:42:01
5 2017-09-06 17:40:43 (current)
The nix-env only works on the user profile (~/.nix-profile) by default you can use --profile | -p to specify another profile. It works the same as on nixos, there's a small section on rolling back changes in the manual.
$ sudo nix-env -p /nix/var/nix/profiles/system --list-generations
576 2017-10-01 16:10:52
577 2017-10-01 16:38:56
578 2017-10-01 17:12:27 (current)
Sigh, having used NixOS (albeit briefly) I should have known this. Thanks!
There're no docs about how to run the tests -- trying to figure that out now myself!
@cbarrett Good point, added an example to the readme. 😄
It'd be nice to have more context for the questions posed by the installer (either in the README, or in the installer itself...):
Would you like edit the default configuration.nix before starting? [y/n]
Would you like to manage <darwin> with nix-channel? [y/n]
Would you like to load darwin configuration in /etc/bashrc? [y/n]
Would you like to create /run? [y/n]
It's easy enough to infer the consequences of either answer to the 1st and 3rd questions, but I don't have much grasp of the immediate or long-term implications of answering either way to the 2nd or 4th questions (or under what circumstances I might want to answer one way or the other).
Similarly, the installer process triggered the warning below 6 separate times (I don't see this warning in the source, so I assume they're just a side-effect of actions nix-darwin is taking):
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
Nonetheless, I don't have any sense of what this means for my install. Is it fine? Do I need to update other components? Did I answer a question wrong? Does the install otherwise need repair or remove/fix/reinstall?
Edit: removed notes on a lockfile issue I had; isolated cause and opened new issue.
I'm new to Nix and trying to convert my system setup from using Homebrew Bundle to Nix. I feel that nix-darwin is what I need but I am struggling to understand how to actually use it. I'd love to have some documentation on "Getting Started" with managing a macOS environment with nix-darwin.
While it's probably not what you're looking for, I finally worked on generating reference documentation for the options https://lnl7.github.io/nix-darwin/manual.
Other then certain options there's actually very little difference between this and nixos, if you're new to nix lost of stuff in the nixos manual (eg. https://nixos.org/nixos/manual/index.html#ch-configuration) also apply to this project. If you're looking for examples, there are a couple of simple configurations in the repo and a bunch of contributors have their dotfiles on github.
I think this is just a documentation hole, but let me know if I should resubmit as its own issue.
I've been working on a new python script that I'm running as a launchd agent, and had some debug code in while I set it up to handle a few signals. The signals passed fine when I was using kill to directly target the python process by PID, but I was a little confused at first when it wasn't receiving anything but SIGTERM if I used launchctl kill <signal> <service-target>.
It was pretty obvious once I pulled the pieces apart. I had just copy-pasted an initial service definition from somewhere else which set the script instead of command option. This made enough semantic sense at the time for me to move on as soon as it worked without thinking too deeply. I recall guessing that the script/command options may just provide distinct semantics for running a standalone script by path, and running a full literal command with arguments.
In my case, exec is swapping in the generated wrapper script, so it receives the signals from launchctl kill. I haven't re-verified this part in the bash docs, but since the wrapper is just bash AFAIR all un-trapped signals end up getting treated as SIGTERM and propagated to children.
When I specify the path of my python script as the command, the python process is what exec swaps in and the signals propagate as expected.
So...installed nix-darwin today. I'd have loved to have had some kind of description for these questions:
Would you like edit the default configuration.nix before starting? [y/n] Would you like to manage
with nix-channel? [y/n] Would you like to load darwin configuration in /etc/bashrc? [y/n] Would you like to create /run? [y/n]
I just went through the installation process, and I think I got most of it set up, but not everything. Here are the things I struggled with:
- On installation, I was asked whether I wanted to edit the configuration. I thought yeah, sure, but I ran into the same problem as described in this issue about
error: Using the nix-daemon requires build users, aborting activationbecause I tried activating an option. A little searching around this repo and I found the issue, so I managed to fix it, but it wasn't obvious. - I'd like to echo what was said previously about warnings about nix search paths and generally about the questions in abathur's comment.
- After the installation was finished, I didn't know what to do. I couldn't find any signs of anything having gone wrong, but I definitely didn't have the
darwin-rebuildcommands available. I tried opening a bash shell instead (usually use fish), but no difference. - Decided to try the 'manual install' steps. The fish commands fail to run with the following error message:
fish: Command substitutions not allowed
- I copied the result of the expression and ran the commands, but was told that my system couldn't find darwin in $NIX_PATH. So I went and copied the $NIX_PATH setting to my
config.fish. - I also manually sourced
/etc/static/config.fishin my fish config file. Should I need to do this? - Now I can evaluate
(nix-build '<darwin>' -A system --no-out-link), copy the path, and run the build. It seems to work. Maybe. I still don't have thedarwin-rebuildcommands in my path.
So I'd say all those are missing. And if I may take this chance to ask a question and get some help: how do I check whether the installation has worked as expected? And how do I get darwin-rebuild in my path?
Apart from this, though: very excited about this, so I'm happy to jump through a couple hoops to get there. Thanks!
Uninstalled nix again. Got the same questions. Still don't know what /run is exactly but I think it's used to symlink the current environment?
I think it's a little unreasonable to expect people to know how to answer all these questions when they may have no familiarity with it yet and there doesn't seem to be easily searchable documentation on what to do.
@spease I'm not sure how relevant it would be to fully explain them. The prompts are mostly there for posterity, unless you have a special setup you probably want/need all of them.
Even just saying that would be useful and give a strong hint that you should select “yes” unless you know you need to select “no”.
Came across this by accident.
https://dev.to/louy2/use-nix-on-macos-as-a-homebrew-user-22d
Currently installing nix-darwin. I was confused by "Would you like to manage <darwin> with nix-channel? [y/n]".
The source code is pretty straight forward. It's basically asking to add nix-darwin as a channel called "darwin":
https://github.com/LnL7/nix-darwin/blob/426d38710b656b0a31f8eaae6e0002206a3b96d7/pkgs/darwin-installer/default.nix#L77-L85
~~y is also the default:~~
EDIT: the default value is n.
https://github.com/LnL7/nix-darwin/blob/426d38710b656b0a31f8eaae6e0002206a3b96d7/pkgs/darwin-installer/default.nix#L74
I'm thinking it would be better to capitalize the default choice, just to make it a bit clearer.