Live data from Hacker News

NixOS 21.05

nixos.org

71–80 of 234 posts

Re: NixOS 21.05

#71
post #56
post #30

Earlier quoted context omitted.

Long time Arch user here but I'm growing more interested in NixOS by the day. I'm mainly “utilitarian” in my OS choice and other things being equal, Arch's AUR packages is what keeps me using it. How does the Nix ecosystem compare with AUR? Would you still recommend making the switch?

Almost everything I used on Arch is available on NixOS. In fact, for a lot of software I was able to use a more advanced configuration because NixOS makes it easier than Arch to set up. I only ran into one hiccup: NixOS has an open pull request for supporting plymouth for silent boot with a LUKS encrypted drive. For now, I am stuck with an ugly password prompt when I turn my computer on.

Great. That won't be a problem, as I love ugly password prompts.

Edit: Relocating /boot to a flash or SD-card is also a way to accomplish deniability of a cryptroot.

Re: NixOS 21.05

#72
post #50

Earlier quoted context omitted.

Nix is a great replacement for homebrew, but the lack of native support for Apple Silicon at the moment is a blocker for me.

https://github.com/NixOS/nixpkgs/pull/105026 this was recently merged so that should start rapidly improving.

The show's happening here now:

https://github.com/NixOS/nixpkgs/issues/95903

https://github.com/NixOS/nixpkgs/pull/125184

https://github.com/NixOS/nix/pull/4867

There's also not-directly-related cross-functional need here on the install process:

https://github.com/NixOS/nix/pull/4289

Re: NixOS 21.05

#73
post #67
post #30

Earlier quoted context omitted.

Long time Arch user here but I'm growing more interested in NixOS by the day. I'm mainly “utilitarian” in my OS choice and other things being equal, Arch's AUR packages is what keeps me using it. How does the Nix ecosystem compare with AUR? Would you still recommend making the switch?

I was able to make the switch over cold turkey after ~11 years of ArchLinux. By sheer happenstance, I blogged earlier this week about one particular killer feature that doesn't get enough air time: https://news.ycombinator.com/item?id=27344677 My not-flake-yet configuration can be found at https://github.com/rraval/nix

> I was able to make the switch over cold turkey after ~11 years of ArchLinux.

Encouraging to know that it's possible.

I'll explore your links.

Re: NixOS 21.05

#75
post #64

What do experienced nix-ers tend to do when they need to use software that's not up to date or available in nixpkgs? Are you guys knowledgeable enough to package everything yourselves, or do you just use buildFHSUserEnv until someone else works out the kinks? I didn't get a chance to figure out how to do the latter, but I'm curious because I've struggled as a new user.

We nixify all in-house development packages at work, it isn’t that bad once you get the hang of it, and comes with an awesome amount of ‘just works’ when integrating packages on custom devices down the road.

Re: NixOS 21.05

#76
post #67
post #30

Earlier quoted context omitted.

Long time Arch user here but I'm growing more interested in NixOS by the day. I'm mainly “utilitarian” in my OS choice and other things being equal, Arch's AUR packages is what keeps me using it. How does the Nix ecosystem compare with AUR? Would you still recommend making the switch?

I was able to make the switch over cold turkey after ~11 years of ArchLinux. By sheer happenstance, I blogged earlier this week about one particular killer feature that doesn't get enough air time: https://news.ycombinator.com/item?id=27344677 My not-flake-yet configuration can be found at https://github.com/rraval/nix

Congratulations on persevering with the program.

Re: NixOS 21.05

#77
post #38

How is managing python packages or ruby gems on NixOS? I remember the experience was not polished a few years ago.

In general it is very nice. A common method is you create a `default.nix` file in the project you are working on and use tools that manage the deps for you. For example: Rust+Cargo: https://gitlab.com/kevincox/watchlog/-/blob/22c877065f763b3d... Node+NPM: https://gitlab.com/kevincox/kevincox-web-compiler/-/blob/9fa... My only Ruby project is private but I just rolled my own with: export "GEM_HOME=$out" bundle install…

Are you up for explaining these gists? We use nix extensively at work and yet I’m having trouble wrapping my head around these. Node dependencies have been a thorn in our nixification of some packages, C / C++ has come easily.

Re: NixOS 21.05

#78
post #32
post #8

Earlier quoted context omitted.

I still can’t quite figure out why it’s not more popular... then again, I don’t use it either, sadly, because it’s not as popular as I feel it deserves; I feel like there must be some reason it’s not used more, so in turn haven’t dedicated the time to learn it. Perhaps that’s cyclic...

Maybe figure out why none of the cloud providers provide Nix as their install OS image. If that happens, users will easily double and maybe more hands might fix the docs or perhaps it's a chicken egg problem but if it's the doc, it's easily solvable.

Running something like nixos-infect to convert an Ubuntu machine into NixOS is going to be a new user’s easiest part of using NixOS. After that, it’s a pretty steep learning curve (or a tutorial) to do anything interesting. I’m doubtful that deleting that first step would bring more users.

Re: NixOS 21.05

#79
post #16

Earlier quoted context omitted.

IMO the biggest blocker is documentation. The best way to figure out how to do something is typically to search around in the nixpkgs/NixOS options for what you're trying to do, then go read the code. There's very little in the way of "here's a common task that new users want to do and here's the blessed way to do it." Even something that should be Nix's MAJOR selling point, like "create a single repo that configures…

It sounds like nix provides an escape hatch [1] out of the declarative framework into something imperative, e.g. running `apt install $package`. And that seems like it would really ease adoption, since I would assume that it would allow a gradual adoption of the declarative mindset. [1] https://wiki.c2.com/?EscapeHatch

A few things which might count as "escape hatches":

The `runCommand` function lets us define a "package" by just executing bash code. This avoids all the "phase" machinery that most nixpkgs definitions use (those phases are great for fine-grained overriding; but we don't usually needed to override our own definitions). It takes 3 arguments: the output name, a set of env vars (including `buildInputs` which will populate $PATH) and a string of bash code (which can be multi-line using ''two quotes''):

    $ nix-build -E '(with import  {}; runCommand "hello.txt" { buildInputs = [ foo bar baz ]; } "echo hello > $out")'
    these derivations will be built:
      /nix/store/z6ffwc1jb70zwz2ly42gaalxnvm7q0gk-hello.txt.drv
    building '/nix/store/z6ffwc1jb70zwz2ly42gaalxnvm7q0gk-hello.txt.drv'...
    /nix/store/l6sd75hj4854pdzv4044ma42axc2v5v4-hello.txt
The sandbox can be selectively disabled (via whitelists), or turned off altogether, which allows builders to access arbitrary filesystem locations and the network. For example, if we have a Python pip project, and we want to take a baby step towards Nix, we could do this (assuming the sandbox is disabled):

    with import  {};
    runCommand "my-app"
      {
        buildInputs = [ (python3.withPackages (p: [ p.pip ])) ];
      }
      ''
        echo "Making mutable copy of app" 1>&2
        cp -r ${./.} "$out"
        chmod +x -R "$out"
        
        echo "Putting dependencies in place" 1>&2
        pip3 install -r ${./requirements.txt} --target "$out"/
      ''
There are all sorts of other tricks. For example, Nix will make immutable copies of files if we reference them directly like ./foo (these copies are stored in /nix/store). If we don't want that, we can reference a symlink instead, since the resulting "immutable snapshot" is just a link to our mutable, non-/nix/store path.

We can avoid having to hard-code hashes for "fixed output derivations" (like downloaded URLs) by overriding their `outputHash`, `outputHashAlgo`, `outputHashMode` and `sha256` to `null`.

I wrote up a bunch of these sorts of hacks at http://chriswarbo.net/projects/nixos/useful_hacks.html (although its a few years old, so might not be up to date)

Of course, these things aren't advisable; but they're very useful to get up and running quickly, and things can be made "more Nixy" later.

Re: NixOS 21.05

#80
If I wanted to use nixpkgs on macOS instead of my dotfiles manager (yadm) and Brewfile – I hear you can do that – would I have to expect missing software (vs. homebrew)? Just about how much pain should I expect, being completely new to NixOS?
Post reply on HN