[HN Gopher] NixOS and Flakes Book: An unofficial book for beginn...
___________________________________________________________________
NixOS and Flakes Book: An unofficial book for beginners (free)
Author : beeburrt
Score : 214 points
Date : 2023-10-09 09:26 UTC (13 hours ago)
(HTM) web link (nixos-and-flakes.thiscute.world)
(TXT) w3m dump (nixos-and-flakes.thiscute.world)
| anotherevan wrote:
| I'm expecting to receive my shiny new Framework 16 laptop in the
| new year. It will be my main workhorse/development machine. I
| vacillate between learning Nix and giving that a go, or sticking
| with Arch+Ansible to manage it.
| [deleted]
| justaj wrote:
| This does not seem to work for me as I'm getting a blank page.
| dlyons wrote:
| Nix has a great community of folks passionate enough to write
| free books ;)
|
| I've spent over a year making my personal Nix config work well
| for others: https://github.com/dustinlyons/nixos-config
| jhvkjhk wrote:
| I don't think a beginner should use Home Manager, because that's
| an extra layer on the already not-beginner-friendly Nix
| ecosystem.
| menthe wrote:
| Quite the contrary. Home-manager is literally the only thing
| that's worth using Nix. Anything beyond that is far too
| esoteric, unsupported, non backward compatible and continuously
| broken.
|
| My dotfiles managed by nix(-darwin) and home-manager breaks
| every time I update my pins, and I find myself having to bisect
| which commit introduced the issues. Given that, I just don't
| see how that would scale to a full OS, let alone to a team at
| work. 1000% better simpler with understandable Dockerfile and
| Kubernetes YAML manifests, or with Ansible YAML. At least every
| folk can StackOverflow and ChatGPT it to a working state, and
| have it work for a considerable amount of time without further
| maintenance.
| benreesman wrote:
| I think there's a consensus around a gap Witt respect to
| documentation, forums, porcelain, etc. in Nix world.
|
| But with all due respect, asserting that everything outside
| of home manager is "not worth using" is fertilizer.
|
| The fact that smart companies (TailScale and Shopify come to
| mind, but there are zillions) are willing to cope with those
| (obnoxious) gaps is very, very strong evidence that there's a
| lot worth using.
|
| git was considered too hard, inadequately documented,
| maliciously baroque for years before GitHub happened.
|
| Nix solves a harder (and more important) problem in a similar
| way.
| pseudonom- wrote:
| Unless I'm misunderstanding something, this is precisely why
| I don't use Home Manager. I've literally never had my NixOS
| setup break over the course of many years.
| sunsunsunsun wrote:
| Ya their comment does not match up to my experience at all.
| When I update my lockfile it very rarely breaks and if it
| does I just roll back a commit and wait a day and it's
| usually fixed.
| ar_lan wrote:
| This is... sort of the point, too. Rolling back is
| insanely easy - and it's version controlled so even if
| something obnoxious happened you (should) know the exact
| commit that broke something as well.
|
| In the very worst case, you update components
| individually until you find the offending one.
|
| I've used both NixOS and nix-darwin for 2 years
| professionally now as daily drivers, and have had
| generally nothing but great success. I'm not fearing an
| OS update actively breaking my environment (which I can't
| say the same for macOS, as much as I am a fanboy of
| Apple).
| 0x457 wrote:
| I think you should because it saves you from transitioning to
| HM later.
| turboponyy wrote:
| I think they definitely should, as this is where the greatest
| value lies in NixOS for personal use.
| OJFord wrote:
| Oh! The lack of (what I now know is) Home Manager is what made
| me drop Nix not long after trying it out briefly a while ago
| (well, several years now, maybe 2015-16). I really liked the
| sound of having all my config declarative and managed through
| Nix, but it's almost all in home - not everything even has
| system-wide config, and anyway it's easier to version control.
|
| So that's just to say I think it at least warrants a mention,
| it's helpful for a beginner to be aware of, even if they don't
| use it (once informed they can decide for themselves if they
| need that piece or not).
| cormacrelf wrote:
| Some people may enjoy going through an enormous learning
| curve to do configuration like that, but the benefits there
| are pretty abstract and personal, and the pressure to make
| the onboarding any easier is very low. It's partly because
| these kinds of users are willing to (a) suffer through a lot
| in the name of learning and feel good about having done that,
| and (b) read and write what appears to be a dozen book-length
| tomes of documentation, that it doesn't get any easier for
| beginners. I know because I was also one of them in 2015-16
| or thereabouts.
|
| Nix doesn't need any more home-manager tutorials, because it
| doesn't need any more small-time tinkerers. It would benefit
| more from becoming essential to a bunch of businesses who
| will become invested in making their own developer experience
| acceptable at scale, and who will have to improve Nix to that
| end.
|
| Pretty soon a bunch of people are going to realise they
| actually do need the exact same version of every tool in
| every toolchain on every machine in a team, to make use of
| the transformative caching abilities of tools like Bazel and
| Buck2. And if that catches on, I would not be surprised to
| see an alternative Nix frontend configured in Starlark, like
| every other tool in that arena. There's already a buck2-nix
| that generates dhall under the hood.
| seqizz wrote:
| I once saw someone who declared their user's home folder
| under /etc so they can do it without home manager. Nice out-
| of-the box thinking.
| curriculum wrote:
| I'm not sure if avoiding Home Manager is the right choice for
| everyone, but it worked well for me.
|
| Home Manager isn't necessary for declarative management of the
| user environment -- Nix flakes can do this, too. A long time
| ago, I kept a single `flake.nix` in my home directory
| describing the packages that each of my machines needed, and
| ran `nix profile install .#packages.<machine>` to install them
| into my user profile. By doing things this way, I learned a lot
| about writing flakes, and this transferred to other places I
| used Nix.
|
| What this doesn't do that Home Manager does is dotfile
| management, but that's actually why I avoided HM originally.
| First, HM's approach is a bit clunky for my taste: each change
| to the configuration must be followed by running `home-manager
| switch` for the changes to take effect. I found this to slow
| down the edit-and-test loop when making changes to my shell
| config, etc. Second, the idea of doing all configuration in the
| same Nix language is cool, but most of the documentation found
| online about configuring, etc., `git`, will refer to the tool's
| usual method of configuration.
|
| So instead, I made a quick Python script that manages package
| installation with Nix, and dotfile management with GNU Stow.
| The dotfiles and Nix configuration all go into the same git
| repository in my home directory, so they are tracked together.
| I've been using this approach to manage several machines for a
| few years now, and it's been more than sufficient for my needs.
| submain wrote:
| One way to make the dotfile editing feedback loop faster is
| to tell home manager to create a symlink as opposed to
| writing a new file every time.
|
| That way you don't have to do home-manager switch when a dot
| file changes.
| baryphonic wrote:
| I'm a beginner, and I set up my system with Home Manager and on
| MacOS Nix Darwin. It works extremely well, and both Home
| Manager & Nix Darwin are quite well-documented. The hardest
| part was figuring out the different arguments to various Nix
| functions (sometimes I wished Nix had types).
| mg74 wrote:
| Im a beginner and am working through getting Nix + Home Manager
| + Darwin working. Currently I am only setting it up on a MacOS
| vm's so I can nuke everything, but the end goal is to install
| it on my host system and manage everything I can with it,
| including home-brew.
|
| Yes, home-manager + darwin is added complexity that is making
| this harder for me; when I am encountering problems I am not
| always clear on where in the three systems it lies. But I
| probably wouldn't be journeying into Nix if it wasn't for home-
| manager + darwin; what I want is managing my workstation and
| setting up ad-hoc development environments, not configure
| servers.
| Zyst wrote:
| I started with just Nix-Shell in WSL with Home Manager. Then I
| have kept adapting that file for my Linux, OS X, and other
| needs. I didn't touch NixOS at all until years later. I'm
| really, really glad I started with Home Manager. It delivered
| value immediately, and I was instantly sold on the value
| proposition of a declarative file to manage dependencies with
| other associated benefits from the Nix world.
| grigio wrote:
| I think also an advanced user shouldn't use a weak abstraction
| weatherlight wrote:
| I found this interesting. I picked dup NixOS a few months back
| using configuration.nix and home.nix and completely avoided
| flakes all together because it was an experimental feature that
| will have breaking changes going forward.
|
| I feel like this book jumps into flakes too soon. it should have
| more around the configuration.nix file, its purpose and uses, and
| then show systematically why one may need a home.nix file and
| then maybe show why something like configuration.nix/home.nix
| might not serve some users (and then introduction flakes for
| those individuals.)
| SkyMarshal wrote:
| All that would make for an interesting blog post, if you're up
| for it.
| troupo wrote:
| To the author, make sure to go through your CSS and fix colors
| for code boxes
|
| At least half of the code is simply unreadable even to a person
| with good eyes. Some examples: https://nixos-and-
| flakes.thiscute.world/nixos-with-flakes/do... https://nixos-and-
| flakes.thiscute.world/nixpkgs/overriding etc.
|
| Simple black-on-white with no syntax highlighting is better than
| this.
| notfed wrote:
| Looks fine to me. Maybe our browsers are rendering differently.
| Can you be specific?
| mtlynch wrote:
| Not GP, but this is what I see: https://imgur.com/gTQ4J80
|
| I can read it, but I can understand having trouble with dim
| gray text on a black background.
| Filligree wrote:
| It depends on the total contrast on your screen.
| Unfortunately...
|
| On a high-contrast, high-brightness screen, white on black
| becomes glaringly bright and produces halos, while a pure
| white background actually hurts your eyes. So you default
| to gray-on-gray because that's what's pleasant, while
| higher contrasts are used in scenarios where you _want_
| glare.
|
| (Games and photographs, mostly.)
|
| On a low-contrast screen, which describes a lot of cheaper
| hardware, the exact opposite is true.
|
| The real issue is it's all relative to what your display
| hardware can do, instead of using absolutes. HDR modes fix
| that, but HDR is still rare.
| [deleted]
| [deleted]
| yu3zhou4 wrote:
| I like the UI of the website, is it some open source template?
| loveparade wrote:
| https://vitepress.dev/
| yu3zhou4 wrote:
| Thank you
| ralgozino wrote:
| this looks very similar to Docusaurus. Do you know any
| differences woth mentioning?
| slorber wrote:
| React vs Vue is a quite significant difference if you plan
| to customize it: you'd better be familiar with the
| underlying tech
| w0m wrote:
| Users seem to love it, but... Why should I use it?
|
| I have a number of personal machines, but I tend to mirror
| whatever I need to use at work; currently mostly Ubuntu.
|
| Nix seems Great to help cleanup my ansible deployments, but it
| also seems problematic with the lack of LTS releases to where I
| couldn't potentially roll out at work.
| flkiwi wrote:
| So, it took me an inordinate amount of effort to get to this
| point, but I find managing my nixos laptop to be idiotically
| easy now. And, to be clear, I'm not a developer. I just want an
| easy to use config that I can port over to a new laptop when
| the time is right (and maybe port a similar config over to my
| desktop as well, once I get around to installing NixOS).
|
| It's very weird, because I went from "WHY IN GOD'S NAME WOULD
| ANYONE WANT THIS?" to "my life is now measurably better" over
| the span of about 48 hours, and I have no idea what clicked.
| Something about adding flakes to the mix (NixOS + HM + flakes)
| broke the logjam. Or maybe it was simply how damned useful this
| config was to learn from:
|
| https://github.com/Misterio77/nix-starter-configs
|
| I went from that to a per-user, per-machine (with defaults for
| each) config in about an hour, and I haven't fundamentally
| changed that setup since. I have no idea why it's so compelling
| to me, but the combination of being able to tell the machine
| how to configure itself in one place with the ease of adding
| software ... I'm going to spin up a config this weekend and put
| it on my kid's laptop. There are other tools to accomplish the
| same thing, but NixOS is just so easy ... and poorly documented
| ... and has weird CLI conventions ... and doesn't do a super
| job of garbage control ... and
| master-lincoln wrote:
| Why write a book on an experimental feature (Flakes)? Is the API
| unlikely to change?
| infinisil wrote:
| Flakes has an unfortunate past [1]. The fact that so many
| people are using Flakes now and treating them as stable makes
| it effectively impossible to make drastic changes, even though
| the design is flawed in many ways [2]. Nevertheless, the Nix
| team is discussing the stabilisation in recent weeks, with the
| tendency to not make breaking changes, but improving the design
| in the long term.
|
| [1]: https://nix.dev/concepts/faq#why-are-flakes-controversial
|
| [2]: https://discourse.nixos.org/t/experimental-does-not-mean-
| uns...
| realo wrote:
| What I heard Eelco say in a recent conference is that 'nix
| build' will work with 'old flakes' but as soon as you do a
| 'nix flake update ' you might have to adapt your flake to the
| new conventions.
| Cu3PO42 wrote:
| For some more context: Flawed as they are, Flakes solve a
| large number of problems Nix experiences without them. This
| is why I, and presumably many others, use them even in their
| current experimental state.
|
| An RFC was recently accepted to commit to forming a plan
| towards stabilization of Flakes:
| https://github.com/NixOS/rfcs/pull/136
|
| Personally, I don't believe there won't be any breaking
| changes, but I also believe that the stabilization of Flakes
| is still a ways away and hope that there will be a reasonable
| migration path.
| Aerbil313 wrote:
| I sometimes just hope a new Nix but rewritten from scratch
| according to 2020s best practices instead of 2000s comes
| before too long.
|
| With a transpiler to convert Nix to whatever it uses.
| Nickel?
| beepbooptheory wrote:
| All I really want is the Guix api ontop of nixpkgs
| packages.
| Filligree wrote:
| I spent half of last week trying to make productive use
| of Nickel, and it's just... not a very fun experience.
|
| Maybe it'll be better someday? We can hope. It's
| certainly incomplete right now, and the documentation is
| mostly nonexistent, but I don't think my use-case
| (incrementally replacing Nix) is supported at all.
| infogulch wrote:
| Maybe I'm dreaming, but a nix-alike built on CUE would be
| fire.
| pmarreck wrote:
| At some point, my developer intuition says we'll get
| something with the core good ideas of Nix, but
| simplified.
|
| The problem is that implementation of these ideas is
| fairly hideously complex for the intelligences of most
| current humans, and that simplifying that complexity
| requires even MORE intelligence (or more years of more
| people staring at the problem until the simpler picture
| becomes clearer).
| callahad wrote:
| That's half the argument for Guix, and the same train of
| thought that led me to Mercurial back in the 2000's.
|
| For better or worse, Nix has owned the zeitgeist for
| several years now, and I'd be surprised to see it
| dethroned before the next paradigm shift.
| pmarreck wrote:
| > flake.nix is not written in Nix
|
| Well, how did I not even realize that until now? Wow. An out-
| loud "holy shit" was hearable over here as I learned THAT
| one.
| iopq wrote:
| Yes, it's basically a ready feature that's not currently the
| default
| toastal wrote:
| Why release a book under a software license instead of like
| Creative Commons?
| alexvitkov wrote:
| Because that's the licenses they know and interact with day to
| day. It's probably what most of the audience for this book id
| familiar with as well.
___________________________________________________________________
(page generated 2023-10-09 23:01 UTC)