News for hackers. Stuff that matters.
Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @11:19AM (#34958195)
Graham here, CEO of DetSys. I'd be happy to answer any questions I can about the new installer and what we're up to!
Re:The Determinate Nix Installer by tikhonj on Monday February 27, 2023 @11:35AM (#34958452)
Does it work on macOS?

Edit: Oh, just saw the link to GitHub with the supported systems, missed that the first time I read the page.

Re:The Determinate Nix Installer by flexiondotorg on Monday February 27, 2023 @11:38AM (#34958499)
Yes, macOS is supported. X86_64 and Apple Silicon
Re:The Determinate Nix Installer by nicce on Monday February 27, 2023 @12:20PM (#34959146)
There are no binaries for every package in Apple Silicon (but there are many). Also, many Linux-purpose binaries install but they might not work after all. For example Buildah for Podman.
Re:The Determinate Nix Installer by pmarreck on Monday February 27, 2023 @11:54AM (#34958756)
This looks good. I know I'm about to speak towards the OS version and not the Nix that can run atop other distros, but I definitely had some hiccups on the way to my NixOS-on-ZFS-root install (1), such as the configuration of the root user, whether to declaratively or dynamically configure non-root users and wifi networks (and having a working wifi driver that worked with my onboard chip to begin with... I truly believe that linux installs should not be expected to have to bootstrap via Ethernet at this point). Admittedly, a few of these things were due to not using the official GUI installer, but IMHO the commandline non-GUI install of NixOS should be as painless as possible as well.

(1) https://openzfs.github.io/openzfs-docs/Getting%20Started/Nix...

Regarding your argument against Bash, isn't it true that this is just a different version of the same bootstrapping problem, and that downloading a temporary but specific Bash version would get around that? (I agree that working with Bash leaves a lot to be desired. But it's also more accessible to end-users to hack on, observe, and learn from, than a compiled Rust binary is. And tools like Copilot and ChatGPT and https://www.shellcheck.net/ make working in Bash MUCH more painless, I've found.)

Couple more questions: 1) Is your installer idempotent? (I think it is, since you track what's been done in a JSON structure; just confirming! If the JSON file is lost, are you still idempotent though? lol) 2) Are you a profitable company or just a group of Nix believers?

Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @12:02PM (#34958874)
Whew, let's go.

On NixOS: I generally agree, though it can be tricky to get that done with NixOS. I bet we can make some inroads there.

Easy questions:

> idempotent It isn't currently idempotent, but we're working on "curing" which brings some idempotency to it, and allows for "rescuing" installations that aren't working correctly. Curing will also support creating a JSON document for installs that don't already have one.

> profitable company or just a group of Nix believers We are a for-profit company, and we are a group of Nix believers :).

Bash:

Bash is really hard to get right, and really hard to make fast, and really hard to extend its featureset to more complicated use cases. We could "just" download a bash, but when we're trying to navigate disk encryption and APFS volumes and mounts ... it is quite a lot easier to write and test that code in a "bigger" language.

Also note that it isn't just Bash that we'd need to download, but coreutils and other utilities that Bash is really built on top of. We tried to fix a pretty simple bug last year in the Bash installer, and it took two weeks to validate a relatively straightforward, one line change was valid on all the platforms we target.

Re:The Determinate Nix Installer by aidenn0 on Monday February 27, 2023 @12:09PM (#34958978)
> Also note that it isn't just Bash that we'd need to download, but coreutils and other utilities that Bash is really built on top of. We tried to fix a pretty simple bug last year in the Bash installer, and it took two weeks to validate a relatively straightforward, one line change was valid on all the platforms we target.

This clarifies a lot of what confused me in TFA. I maintained millions of lines of bash code, some of which is decades old and run into only a single bash incompatibility that wasn't fixable with shopt. On the other hand, incompatibilities in programs bash is running are rampant, particularly between GNU and non-GNU systems (and even within GNU there are more surprises than you might think). The phrase "different bash implementations" was a major red herring for figuring out what you were talking about.

Re:The Determinate Nix Installer by pmarreck on Monday February 27, 2023 @12:20PM (#34959147)
Followup question then: Are you hiring? :) What type of work do you do? (is it "sysadmin-flavored," etc.?)
Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @12:32PM (#34959309)
We're working on broadening the use-cases that Nix is appropriate for. Things like https://zero-to-nix.com/, https://www.riff.sh/, and the Determinate Nix Installer's goal is to make installing Nix a "low cost" / "low risk" activity to bring people in.

We're always looking for good writers, Rust devs, and security folks. People who are in to these things should reach out with their resume: [email protected]. Note that existing Nix expertise is not required.

Re:The Determinate Nix Installer by vinceguidry on Monday February 27, 2023 @03:44PM (#34961604)
> but coreutils and other utilities that Bash is really built on top of

This really is the problem with bash. It doesn't have a stdlib. Posix tried but didn't succeed in sufficiently standardizing userlands. Bash is friendly and easy to hack on, but hard to manage at scale, for this reason. And this crops up all the damn time when you're working with compiled languages. Nobody wants to have two languages. But if one of your languages is compiled, then nobody wants to write and maintain literally everything in that language. At some point you need scripting. Bash is usually what's reached for. But OSX doesn't ship a recent bash. And your coders are probably running OSX. So you have to write scripts that target ancient bash so the devs can work locally, but also work in the cattle farm. You'll spend lots and lots of time fighting it. Or have ridiculous 'setup' docs that will trip up newbies and you'll have to troubleshoot their setups when they inevitably not follow them right or they just don't work leaving their personal systems in an unknown state.

Or just, yannow, use a scripting language to script with instead of a shell. Or, hear me out here, use the 'scripting' language to build your whole app. You very very very probably can. Ruby's object oriented and is way friendlier than bash, ditto for Python.

Re:The Determinate Nix Installer by abathur on Monday February 27, 2023 @01:08PM (#34959835)
> Regarding your argument against Bash, isn't it true that this is just a different version of the same bootstrapping problem, and that downloading a temporary but specific Bash version would get around that? (I agree that working with Bash leaves a lot to be desired. But it's also more accessible to end-users to hack on, observe, and learn from, than a compiled Rust binary is. And tools like Copilot and ChatGPT and https://www.shellcheck.net/ make working in Bash MUCH more painless, I've found.)

I haven't been working on the detsys rust installer, but I think I'm the person who's contributed the most to the official bash multi-user installer since Graham did a lot of work on it several years ago.

I ~like Shell, and I share your concern about it being less hackable. But the project has also been slowly bleeding goodwill around the lack of clean uninstall/reinstall for years, and I will make my peace with the compromises it takes to get there.

The problem isn't so much conjuring good shell expressions. Nix leans a lot on Shell, and I feel like the community has a fair number of people around who know Shell fairly well. The problems are more like:

- limited/tedious support for robust error-handling and recovery

- needing a significant amount of new code to handle removing what Nix adds (even though I've done a lot of work to develop the patterns to support eventually getting here)

- a fairly fat long tail of problems caused by things like edge-case environment/state differences (due to platform, due to users having surprising environments, etc.) and even flaky behavior on some systems

- screwing up the installer is fairly high stakes (and it's very common for even one-line changes to break the installer in some way for someone somewhere and end up needing to get reverted for a rethink)

- testing the installer is tedious (it's gotten a lot better over the past ~2 years--but that testing is also just covering the golden path), so iterating is slow

- writing and reviewing installer changes tends to entail (and sometimes suffer from a lack of) really broad knowledge of different platforms, shells, utilities, options, permissions, and user configuration ~patterns

Because the stakes are high and review is hard and testing is hard and iterating is slow, IME most of the people who are enthusiastic about working on it are naive about these headwinds. This might lead them to, say, submit a PR bigger than anyone will have the stomach to review/merge--or not have the time/energy to slog through weeks/months of review/edit/test iterations it takes to build high confidence in a big change. It's also a big drag on the number of people who have the stomach to continue making substantive installer PRs after they land one.

Before detsys started looking at the rust installer, I had picked at a POC for just bundling a bash and everything we touch (iirc at least coreutils, diff, patch). If their effort failed, that's definitely the approach I was going to recommend next to reduce the frequency with which we get bitten by a utility quirk/change. But that still would've left quite a bit of work to do to support uninstall and idempotent reinstalls.

I'm personally limiting the amount of non-fix work I do on the official installer to avoid falling into its gravity well and completely owning it. Once more, if any combination of the technical changes here are sufficient to multiply the number of people willing and able to touch the installer, I'll make my peace with the tradeoffs.

Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @02:05PM (#34960545)
This is such a good summary of all the issues we've been running into over and over, and part of the deep motivations of our work here.
Re:The Determinate Nix Installer by pxc on Monday February 27, 2023 @02:45PM (#34960971)
> if any combination of the technical changes here are sufficient to multiply the number of people willing and able to touch the installer, I'll make my peace with the tradeoffs.

Do you feel similarly about the Nix setup scripts that the installer works to ensure are sourced by user shells? I'd kinda love to see those go and be replaced by a little program that sets up a Nix environment and then launches a shell for you, kinda like the `login` program. The shell-based approach has made supporting incompatible shells kinda nasty and clunky.

Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @03:10PM (#34961255)
I certainly feel that way.
Re:The Determinate Nix Installer by abathur on Monday February 27, 2023 @03:45PM (#34961621)
I have managed to avoid fiddling with the init hook scripts themselves, so I hadn't actually thought about this specific idea. IDK if my thoughts will be productive/incisive.

I've definitely felt like the Nth-shell situation is untenable and that we'll either need to abstract a definition to generate the hooks from or find some other ~general/universal solution.

I like the way this suggestion sounds with respect to getting out of that maintainability problem, but I'm not sure if it'll work quite right?

Here's one crappy rabbit-hole we've gone down:

Since macOS changed its default shell to zsh, they've been overwriting /etc/zshrc with every update (this evicts Nix's hook, confuses/scares people, and makes them try to reinstall; note that they aren't using the Relocated Items treatment we'd expect from how they do this with most stuff in /etc/ including /etc/bashrc while it was still the default shell).

An enterprising zsh user PRed a fix that moves the hook to /etc/zshenv. macOS doesn't ship /etc/zshenv, so they don't overwrite it on update. It seems to work at a blush, but Nix and everything you install with Nix ends up at the end of your PATH instead of the beginning, so everything that depends on a PATH lookup will keep using your system utilities.

Why? IIRC because the /etc/zshprofile macOS ships will do "eval `/usr/libexec/path_helper -s`", and path_helper will add things from /etc/paths and /etc/paths.d to the left of the existing PATH. I suspect if we inject a binary or even a script to preconfigure this environment, the call to path_helper in the zsh init process is still going to leave everything we added at the end of the PATH. We could in theory add an /etc/paths.d/nix, but path_helper appends this after everything in /etc/paths, so it has the same problem. We could stick our Nix-related directories at the top of /etc/paths, but macOS does ship this file so we have no reason to have faith that macOS updates don't overwrite it or won't start doing so at some point.

(We might also be able to move this to /etc/zshenv and also define a `/usr/libexec/path_helper(){ ... }` function that behaves like WE want--but that could obviously have downstream effects on other code in user profile/init scripts that uses path_helper. No clue if this is common.)

Re:The Determinate Nix Installer by rmorey on Monday February 27, 2023 @12:08PM (#34958953)
I have nix currently installed from the official installer in multi-user mode on macOS - I believe it works fine, would there be any benefit to me uninstalling and reinstalling via your installer?
Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @02:13PM (#34960629)
I'm delighted to see your edit :). Our installer makes a few configuration choices that upstream doesn't, but the main driving goal for us is to be reliable, safe, and easy to undo.
Re:The Determinate Nix Installer by kirbyfan64sos on Monday February 27, 2023 @12:18PM (#34959107)
Does the multi-user mode work on SELinux-enabled systems and, if not, is it possible to install in single-user mode? The default installer's multi-user mode doesn't work with SELinux enforcing (https://github.com/NixOS/nix/issues/2374), and I didn't see a flag for enabling single-user mode when I used `install --help`. (There are some projects to make SELinux support work like https://github.com/dnkmmr69420/nix-with-selinux, but it's not clear to me if that would even work with this installer in particular.)
Re:The Determinate Nix Installer by Alekhine on Monday February 27, 2023 @12:25PM (#34959217)
I'm on Fedora and had to turn SELinux off to get nix to work properly.
Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @01:52PM (#34960392)
I commented elsewhere in the thread, but we have an open issue for SELinux support: https://github.com/DeterminateSystems/nix-installer/issues/1.... Hopefully we can get that rolling soon.
Re:The Determinate Nix Installer by pxc on Monday February 27, 2023 @02:36PM (#34960875)
* * *
Re:The Determinate Nix Installer by anon291 on Monday February 27, 2023 @12:22PM (#34959177)
What do you see as the biggest roadblock for Nix and how do you intend to address it?
Re:The Determinate Nix Installer by SuperSandro2000 on Tuesday February 28, 2023 @12:41PM (#34972311)
One if the bigger issues right now are mass rebuilds and content agreed derivations hopefully address that at least partly. Sadly there is not much work happening on them lately.
Re:The Determinate Nix Installer by bokchoi on Monday February 27, 2023 @01:46PM (#34960306)
Thank you, this is great! I love the focus on OSX support and on uninstalling. As a nix newbie, it can be difficult to resolve some issues and sometimes re-installing is the simplest option.

Is the end result of installing via the bash install script and this new installer the same? Can I use the new tool to uninstall nix installed via the bash script?

Re:The Determinate Nix Installer by grhmc on Monday February 27, 2023 @01:51PM (#34960379)
Thanks! The end result is not quite the same. For example, we turn on flakes, nix-command, and make a couple other minor tweaks to the Nix configuration to make what we think are user-friendly improvements. For example: https://github.com/DeterminateSystems/nix-installer/blob/mai...

Our installer also supports some environments that the upstream installer has a harder time with.

The new installer can't _yet_ uninstall a Nix installed from the upstream installer, but our upcoming work on "curing" will bring that.

Re:The Determinate Nix Installer by Laaas on Monday February 27, 2023 @04:47PM (#34962346)
I do wonder why auto-optimise-store isn't enabled by default. Is there a historical reason for it? Would Eelco accept a PR making it the default?
Re:The Determinate Nix Installer by bokchoi on Monday February 27, 2023 @01:49PM (#34960348)
Oh and as long as you're being opinionated about installing and making it easy for newcomers, have you considered including an option to install home-manager and nix-darwin? My uneducated guess is they are typically used by folks on OSX.
Re:The Determinate Nix Installer by pxc on Monday February 27, 2023 @02:38PM (#34960894)
* * *
Re:The Determinate Nix Installer by JamesSwift on Tuesday February 28, 2023 @02:13PM (#34973497)
Have you used home-manager as well? Would be interested to hear your thoughts on the two, and what specifically makes nix-darwin so nice overall. I haven't used it before, just home-manager.
Re:The Determinate Nix Installer by pxc on Tuesday February 28, 2023 @04:28PM (#34975083)
I've played with Home Manager, but I've never really used it long term as much as I have Nix-Darwin. (I'm not super interested in HM's dotfile management features, since I already have tools I like for that.)

What's nice about Nix-Darwin for me is mainly how NixOS-like it is. I like keeping its config under /etc and treating systems using it like NixOS. There are a few modules that I think are pretty impressive and atypical for the Nix world, like the Homebrew module. I'm not sure if HM has something comparable.

Re:The Determinate Nix Installer by JamesSwift on Tuesday February 28, 2023 @04:55PM (#34975441)
Homebrew is a big gap in home-manager. In fact, my current setup (and the most common I think) is to use homebrew for casks, home-manager for everything else (and I also do some Brewfile management with home-manager).
Re:The Determinate Nix Installer by pxc on Tuesday February 28, 2023 @05:50PM (#34976056)
Yeah, that's what I like about the Homebrew module for Nix-Darwin: it lets you declare your cask usage in your Nix config.

I agree that brew's cask support is generally worth using even if the rest of brew is best avoided in favor of Nix or other package managers.

Re:The Determinate Nix Installer by JamesSwift on Monday February 27, 2023 @02:20PM (#34960693)
Any thoughts on adding max-jobs/cores to the default config? I've always set mine to `max-jobs = auto` and `cores = (sysctl -n hw.ncpu)` on mac.
Re:The Determinate Nix Installer by SuperSandro2000 on Tuesday February 28, 2023 @12:40PM (#34972293)
Nix should use similar values already by default but if you are regularly build heavy builds those settings are not good enough and need tweaking.
Re:The Determinate Nix Installer by Wowfunhappy on Monday February 27, 2023 @09:39PM (#34964988)
What is the minimum (ie, oldest) version of macOS the installer will work on?