32 ms·
Zero to Nix, an unofficial, opinionated, gentle introduction to Nix
- jhoechtl 4y agoI read of Nix now and then. Seems its more than a fad. Why should I invest time? What makes it stand out?
- colordrops 4y agoIt's basically checking in your OS to git. It never gets crufty and almost never breaks. There's a lot more to it but those are the core ideas and I'm typing on my phone.
- grawp 4y agoNO. He asked about Nix NOT NixOS... do not conflate them together. Nix an extremely generic tool for much much much more than what you have said.
- colordrops 4y agoIs Nix used for anything besides configuring a computer? I said "a lot more to it" as well...
- JamesSwift 4y agoYes, its used to guarantee reproducible scripts (so, e.g., you can use `jq` and not require someone have jq installed and not require running through docker) and dev environments as well (which is really great for both version locking as well as polyglot projects).
- colordrops 4y agoI use nix shell for development and reference uninstalled packages from scripts as well. I think we both understand what Nix is capable of. I still don't find any issue with my initial comment that Nix at its core is for maintaining a reproducible system from config files in git. My point wasn't to be pedantically perfect but rather to communicate a core use case in laymen's terms for the uninitiated.
- alchemist1e9 4y agoIf you are building a complex system with a large number of cascading dependencies then nix can literally save your sanity, however you have to get over the initial steep learning curve. If your work tends to be more isolated and self contained on stable unchanging mainline or mainstream versions of any dependencies you have. Then it’s not worth your time and you won’t appreciate or understand it’s value.
- flexiondotorg 4y agoClosing in on 20 years of existence doesn't really qualify for fad I'm just starting a serious learning journey with Nix after flirting with the idea for a few years. Mostly because I find myself endlessly working on tooling to support the projects I work on that Nix already does extremely well. The feature I am most sold on is the ability to invoke clean complex development environments, that bring themselves to existence automatically as I traverse directories. If you work in code or in DevOps, Nix is totally worth a look.
- throwaway894345 4y agoIt may not be a fad, but there's a lot of rose-colored hype that masks a world of tedium. New prospective users should be prepared for a lot of uphill grind with respect to configuring packages or defining their own packages. Every time I try to do seemingly simple tasks in Nix, I end up spending hours on the Nix discord channel trying to work out a solution with seasoned users (who invariably struggle to work out a reasonable solution). Often times I end up having to try to figure out how to package some obscure C dependency deep in the dependency tree with its own bespoke build system and so on. Nixpkgs is also pretty poorly organized (or at least I can almost never find the package I need) and this is pretty critical because something as simple as answering "what type does this function take?" requires a ton of searching around Nixpkgs (largely due to the lack of type annotations or even informal documentation). The CLI tool surface is also not particularly intuitive, and there are different tools for different problems and no consensus about which tools to use (or at least the official docs often disagree with popular opinions in the community). You have to be aware of whether you're just using the Nix package manager or whether you're using NixOS because it will affect the way you write your configuration and often snippets on the Internet implicitly assume one or the other such that you will spend a lot of time trying to fix snippets or find the right snippet for your use case. MacOS is still a second-class citizen in the Nix world and a fair amount of stuff doesn't work properly (although I can't think of specific examples off hand). The Nix expression language seems unnecessarily unfamiliar to mainstream programming languages--I don't object to the functional nature, but I still spend quite a lot of time consciously thinking about syntax even though I've been using Nix on and off for ~7 years now (compared with e.g. typescript which I've barely touched and yet is trivial to read). Normally I don't complain about syntax, but you can do very little in the Nix world without reading and writing a bunch of nixlang and even if the other problems were resolved this alone would make it difficult to sell in most organizations since every developer would have to figure out how to work with it (package management is high-touch). I'm a big believer in Nix's high-level approach to declarative systems, but the whole UX of Nix is so poor that foregoing declarative systems altogether is quite a lot less painful than using Nix in my experience. I'm rooting for it, but it really feels like Nix needs a product manager or something (no disrespect to the maintainers; these are difficult problems and I'm sure I wouldn't do a very good job). New users should beware.
- dandanua 4y agoI found NixOS to be usable (though it has limits in comparison to other distributions), reliable and reproducible(!). You can add and remove packages without polluting the system. Potentially it can save you time in the future. Moving to another hardware is a breath.
- superkuh 4y agoNix is for people who have entirely given up on the idea of system libraries. There is no system. Unless someone else has already done the work every single random bit of .c code, or whatever, you try to compile or run will require you to explicitly set the system libraries available/required to run it in a set of config files. It's like building a custom OS container for every single program you run. For some people this is good because future shock has made relying on system libaries to run things very troublesome. So troublesome it compares to the above.
- grawp 4y ago- Nix is a purely functional language with lazy evaluation. - One of its types is a derivation which is basically an immutable result of some script / application / other build system ran in sandbox with exactly specified environment. - Calling derive with same inputs generates same derivation. - It's lazy... only when something tries to access derivation's files or other properties its build script is run. You can use derivations as (/ to represent) - packages - generated configuration files / settings - containers - whole OS images ... e.g. I'm building raspi SD card images using Nix.
- rgoulter 4y ago> Why should I invest time? It's not for everyone. Specifically, because Nix's 'costs' are upfront (for likely future benefit), nix isn't well suited to just-get-it-done pragmatic attitudes. -- e.g. if you'd prefer to just launch VMs from the web console, over using a tool like Terraform, then Nix isn't going to be for you. Nix isn't too difficult to use. I'd say it's 95% wonderful, 5% huge pain to deal with. (Writing new nix code can be very hard). As to why it's worth learning: > What makes it stand out? Nix provides very expressive control over packages of software. e.g. With nix, it's easy to have multiple versions of the same software running on the same system. Whereas, with package managers, if you upgrade, you aren't able to easily also keep the old version around. Some of the use cases Nix allows are pretty neat: - You can declare a set of development tools to be made available. So, when you load up the project, you don't have to copy-paste "apt-get install...". This is especially useful for side projects you might not touch all the time. - There's a "nix run" command, which can act a bit like "docker, without containers": it will download the package, and run it on the host. - NixOS makes use of Nix so that the system configuration is all declared starting from a single file. Rolling back changes to system configuration is easy, in case you accidentally misconfigure the system. -- This can be used to build container images or VM images. - Nix can be used to declare what packages you want installed for your user, and declare the configurations for these files. This allows ensuring you have a familiar setup quickly on a new computer. All sorts of programming involves dealing with packages. To clarify a bit on the details: nix declares packages in a pure way, using all of its inputs (source code, compiler, library dependencies; which are themselves declared with nix), and builds these in an isolated/non-global directories. Packages are 'installed' by symlinking to where the package is placed.
- fuball63 4y agoHow does Nix compare to Environment Modules: https://modules.sourceforge.net/ https://modules.sourceforge.net/ Am I correct in understanding they are similar, except Nix has the "pure" package building?
- rgoulter 4y agoI'm not familiar with Environment Modules. I see they're popular in HPC? One difference: On Nix's homepage (https://nixos.org https://nixos.org), the first word which stands out is "reproducible". -- If I search the read the docs for "reproducible", the word shows up once. https://modules.readthedocs.io/en/latest/index.html https://modules.readthedocs.io/en/latest/index.html Not sure if there's anything recent, but links from this may be useful: https://github.com/freuk/awesome-nix-hpc https://github.com/freuk/awesome-nix-hpc
- unshavedyak 4y agoFor me, i use it on my Desktop because i love things being stable for my work environment. I don't want an upgrade over the weekend to cause problems come Monday morning. I've had my system get "borked" on updates in the past, and Nix lets me revert very very easily. Also upgrading libraries for one App can easily be isolated from breaking other applications and etc. It's got tons of flaws (to me), but the core idea to me is a foundation for a super stable system. I both love Nix and hate it. It's so good that myself, a large critic of the OS, still uses it.
- seanw444 4y agoFor me, the "borking" issue is largely resolved by running Btrfs. Just make a snapshot shortly before updating, and then I can revert to it if needed.
- unshavedyak 4y agoMy problem is i don't know what gets borked immediately after updating unless it's catastrophic. Ie i've gone a fair bit of time before i realized some specific functionality of some program no longer works due to some unrelated change in an underlying dependency that i was unaware of. Oof. Granted Btrfs sounds great though, i've not used that. It would certainly help.
- seanw444 4y agoYeah that's true. That's where the "largely" part of my comment does some work. I just take occasional snapshots before I do things that I'm concerned may be catastrophic. But it definitely won't catch everything. It helps that I run Arch, and I update packages once a day, which only leaves me with under 40 (small) packages usually. So a quick cursory glance at which ones are updating usually tells me what to be cautious of. Display driver update, kernel update, etc. If I'm not sure what went wrong, but I at least have a working snapshot, then I can get done what I need to get done, and then go back to troubleshooting. Rather than just having a broken system regardless.
- tripdout 4y ago
- aendruk 4y agoNixOS has been my daily driver for just over a year and my impression is that it’s still all a big experiment. A promising one, but far from a polished product so try to avoid that framing. The Nix community is doing exciting work but in the long run I wouldn’t be surprised to see another project take its place in the mainstream once the ideas have matured. The current space has much of the same chaos as projects like Oh My Zsh or Spacemacs and needs to be treated more like an active hobby. All that considered, the core paradigm is a breath of fresh air and I can’t imagine going back to a mutable system.
- tylerjl 4y agoI think the nix community is doing an increasingly-better job at addressing several outstanding issues, and although the OP link resolves one of them - the getting-started experience - the "why" that you highlight here is still a hard one to answer without getting into the technical weeds. I ran an informal Twitter poll a few months ago and this question (the "why" instead of "how") was the most-requested kind of content. One potential answer to this is, "imagine building and running software with lockfiles for _literally everything_". I'm not just talking about _versions_ of dependencies or shared libraries - which nix does - but also things like: - Locking the current point in time (nix resets the build sandbox to the unix epoch) - Locking out network conditions (all build dependencies need to be fetched and therefore expressed as part of the instructions and not left to "at some point during the build") - Locking out access to any system state (again, builds occur in a sandbox populated only with what you indicate within the build instructions) That's what's behind the marketing for reproducability and repeatability. If you lift those principles into new and interesting applications, the various other uses for nix fall out of it: - NixOS takes the principle of those nix builds and applies to it building not just packages, but the system entirely, like the files it places in /etc or the running kernel. - Projects like devenv[1] or flake devShells in general re-use the portability of a fully-defined nix package to ship hard-to-break executables into share-able devshells so your peers can work with the bit-for-bit same version of Terraform or python (without worrying about what version of /lib/libssl.so they may have) - Since nix "owns" the _entirety_ of the inputs and outputs to a piece of built software, shaping it into different artifacts becomes trivial. For example, as long as you're able to build a rust project with nix, nix easily lets you kick out a minimal OCI container (without needing to write a `Dockerfile`), or produce a tiny qemu clone of your system (or any system) by feeding your NixOS configuration into a function that produces images instead of configuring your running system. Hopefully that's helpful, sorry if it isn't - but nix is sort of alien software, and nix people are still learning how to best share its potential with others! edit: list formatting [1]: https://devenv.sh/ https://devenv.sh/
- blueflow 4y agoI recommend to sit back and wait until the hype has subsided. Later, when the starting problems subsided and documentation has improved, it might be worth a try. Provided that ever happens.
- jcastro 4y agoI am glad someone is doing this. There's lots of things in nix I want to try and use but the tooling and docs are just a bridge too far for me, if someone's going to give the initial ux a do over then I'm down for that!
- grhmc 4y agoThanks, Jorge! I think the nix3 interface and the Flakes solve a lot of UX problems. Maybe we could do a bit of a user study, to see where you get hung up?
- Athas 4y agoDon't those still give you a terrible error message if you use them in a default config?
- grhmc 4y agoThey do, and using the installer we recommend enables Flakes and the Nix command out of the box: https://zero-to-nix.com/start/install#up https://zero-to-nix.com/start/install#up. We think flakes and the new interface are the future, and we're working to bring it home.
- unshavedyak 4y agoWhat's the `nix3 interface`? I use NixOS with Flakes, but frankly it's quite obtuse lol. I don't even know how to specifically update my `nix`. I updated to the latest release the other week and my `nix` CLI is on `2.11`. Are you referencing a 3.0 version of the `nix` CLI? If is there a summary somewhere on what is different between 2.xx and 3.0? Though i still have no clue how to update to 3.0 if i wanted to. Searching for `nix` is incredibly obtuse given the language is Nix and the OS is Nix. (I know i know, Nix, NixOS, Nixpkgs, but you know what i mean)
- edolstra 4y agoIt refers to the new CLI, i.e. the "nix" command. The old CLI is the nix-* commands (nix-env, nix-store, etc.). The new CLI and flakes are still marked experimental, but the plan is to stabilize them and call that "3.0". So it won't be very different from the current 2.12 - you just won't need to enable some experimental features anymore to get the new CLI/flakes.
- AndrewUnmuted 4y agoNix and NixOS have had a similar sort of effect on me as Gentoo and FreeBSD have in the past. They have helped to expand my consciousness in the realm of systems administration and have helped me achieve new heights with my low latency audio configuration. For this reason, Nix and NixOS have become indispensable to my workflow. NixOS introduces a new form of declarative configuration, fusing Gentoo's highly configurable nature with BSD's unified configuration file approach. For me, it's absolutely perfect until my own laziness bites me in the butt. If you want to do a gentle dive into Nix, resist the temptation to go full "NixOS" and learn the Nix build/environment system first. It will make things a lot easier for you in the long run.
- cole-h 4y agoI'd also suggest that, once you _do_ feel comfortable enough to step foot into NixOS territory, that you start off by version-controlling your configuration. It doesn't necessarily have to be public, but I've found it very helpful in the past when I've had to debug various issues due to misconfiguration by me.
- wingmanjd 4y agoDo you symlink your config repo to /etc/nixos or something else? So far, I've just been rsyncing my config repo folder after I modify it.
- grhmc 4y agoYou can actually put your NixOS config anywhere. Assuming you're not using flakes, `nixos-rebuild` finds the config through NIX_PATH: grahamc@scruffy:~/ > echo $NIX_PATH nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels you can change the `nixos-config` value to point to somewhere else, or call it like this:`nixos-rebuild -I nixos-config=./configuration.nix`
- cole-h 4y agoI don't; my config lives in ~/flake, and I run `nixos-rebuild ... --flake ~/flake` whenever I update it.
- aendruk 4y ago> Zero to Nix is opinionated because it advocates learning and using flakes and treating channels as deprecated. I think I need a “Channels to Flakes”. I have an existing system configuration that seems to work fine without flakes. What am I missing out on?
- tylerjl 4y agoIn your specific case - a _channel_ versus a flake _input_ - consider how you're tracking your system configuration. If you have an /etc/nixos/configuration.nix, then your system can be reconstituted _only_ if you have that configuration.nix in addition to the revision that your channel is currently on. Compare this with a system defined in a flake's `nixosConfiguration`, which accepts its version of nixpkgs from the flake's input, so you can rebuild/recreate the system from the flake entirely without needing to piece together other bits of state like the current channel revision/nixpkgs checkout.
- Athas 4y agoIs this more deterministic than pointing Nixpkgs at a specific commit/tarball in the configuration? I have often done this to make reproducible builds in other Nix settings and it has worked well.
- grhmc 4y agoIt is: using Flakes you're thrusted into a more pure evaluation mode by default, and it creates a (standard) artifact of the revision you're on: the flake.lock. You can get almost all the benefits Flakes brings without Flakes using alternatives like niv.
- Athas 4y ago> It is: using Flakes you're thrusted into a more pure evaluation mode by default, and it creates a (standard) artifact of the revision you're on: the flake.lock. Can you name a specific example of the kind of nondeterminism/nonreproducibility I risk by simply pinning Nixpkgs itself (or to be more principled, using Niv)?
- QuiCasseRien 4y agoThe same Zero to NixOS would be highly appreciate.
- aendruk 4y agoWhat are your thoughts on the section about NixOS?
- flexiondotorg 4y agoI like the idea of a NixOS section.
- QuiCasseRien 4y agoZero to Nix and its NixOS section is elegant and simple. It has already been said many times but NixOS suffer from a poor and a fragmented documentation. The Official Nixos Manual is a very good start to install Nixos. But that's it. It does not explain all the logic behind NixOS for already experienced user. Because yes, Nixos is absolulety not for beginners ! Nixos is a kind of blackbox where once you've luckily found the site https://search.nixos.org/options https://search.nixos.org/options it comes with all the options you were looking for. You need a sysadmin background to understrand theses options like (ie: services.nginx.virtualHosts.<name>.locations.<name>.extraConfig). A reverse dictionary of how we used to do things with traditionnal distro and how to do with Nixos should be a very good start ! At least, the extrem big fucking issue is the complete mess between Nixos/Nix/Flake/Home Manager. Theirs documentation and definition are often "recursive dependant" in a way you are completely lost. If i compare to AUR (ArchLinux User Repository), the learning curve to create a custom package is quite easy. For Nix, it requires an amount of concentration, reads and skills to do the same. This discourage users.
- grhmc 4y agoWe've been tossing the idea back and forth inside to try and find the right way to approach it. I totally agree.
- 0xCMP 4y agoI am a huge fan of all the work Determinate Systems is doing to make Nix easier to use for everyone.
- grhmc 4y agoThank you =)! I'm really happy to hear that the work we're doing is landing with you.
- bbsimonbb 4y agoWhat problem does this solve?
- qbasic_forever 4y agoIt's right there in the heading! "Declarative, reproducible development environments"
- pxc 4y agoSome problems Nix solves, as concisely as possible: - dependency conflicts - build reproducibility - configuration management - configuration drift - package management on restricted systems (i.e., installing stuff when you're not root) - shared library duplication - inconsistent state/broken system after a botched upgrade This makes it nice for setting up development environments, building containers, and deploying servers. (A lot of people also enjoy using it for their dotfiles, since it works on macOS as well as across all Linuxes. I personally love it on desktops and development workstations as well.)
- lacker 4y agoIs Nix good at dealing with cuda dependencies? I am always frustrated trying to deploy cuda-based environments onto machines with different sorts of GPUs.
- aidenn0 4y agoI've setup pytorch with CUDA on nix and it was quite straightforward, but never tried anything more exotic.
- JamesSwift 4y agoUX feedback: for an opinionated guide targeted at newbies, I think the 'concepts' page should be much more of a guided introduction. I click on it and have a big basket of things in _alphabetical order_. I think it should be a top-to-bottom ordering of how a user should read them if encountering for the first time. Maybe have a separate glossary page if thats what you are going for with the alphabetical order.
- grhmc 4y agoThanks for this. Our goal is to keep people on the "rails" of the quick start, with the Concepts as a way to fill out knowledge people are curious about. I wonder if we should downplay the concept docs in service of that? Or put more CTA's to go take the quickstart?
- aendruk 4y agoIf that’s the intention the naming of the quick start misleads me. I typically skip the example at the beginning of documentation and go straight into the meat of it. In this case it sounds like I inadvertently skipped the main content.
- flexiondotorg 4y agoI like the idea of having a flow through, at least, some of the concepts in the order they should be introduced.
- JamesSwift 4y agoIf thats the intent, then it seems the Quick Start is what I'd adjust to be more linear then : ) Again, it looks like a basket of equally-weighted links that a user is free to click into at leisure. It seems more like a directory of useful links rather than a "highly opinionated" guide to get me from zero to proficient. Compared to something like the sveltekit docs [1] (randomly pulled because I was viewing it today) its much easier to understand the flow of topics, and I think a user can assume they should read them in the presented order unless they understand a given topic already. [1] - https://kit.svelte.dev/docs/introduction https://kit.svelte.dev/docs/introduction
- VWWHFSfQ 4y ago> echo "Hello Nix" | nix run "nixpkgs#ponysay" why on earth would you make # any kind of a special character in commands. who thought of that
- edolstra 4y agoIn most shells, "#" is not special unless it's preceded by whitespace. So > echo "Hello Nix" | nix run nixpkgs#ponysay also works.
- aendruk 4y ago$ echo a#b a#b
- aidenn0 4y agoAre you complaining because it's not on some latin keyboards, or for some other reason? A lot of other characters are already taken either by shell or by the nix expression language.
- groestl 4y agoOff topic, but I wonder if the authors of zero-to-nix.com are aware that their project name actually reads quite funny for German speakers (as "Nix" in German also means Zero)
- syrrim 4y agoThe pun also works in english, so I imagine they are.
- maartenh 4y agoThe original author is Dutch. In Dutch, "niks" (same pronunciation as Nix), actually means "nothing". His nickname is niksnut, which means "good-for-nothing".
- grhmc 4y agoIndeed, "zero to nix" was our jokey "working name." We never actually came up with a better name, so here we are :).
- lynndotpy 4y agoI wish guides like these contained screenshots. Do people use Nix for desktop OSes? As a VM they SSH into? A collection of config scripts that they don't directly issue commands to? I certainly can't tell from a quick glance of this guide
- whateveracct 4y agoScreenshots of what exactly? Installing packages? Running nixos-rebuild switch? I guess screenshots of a bunch of text.
- lynndotpy 4y agoYes! Assuming that is what "using Nix" looks like for an expected use case, that would be informative for someone who does not know what using Nix looks like.
- whateveracct 4y agoYou will like nixos.org then :) https://nixos.org/ https://nixos.org/ Lots of examples if you scroll down!
- lynndotpy 4y agoOh this is completely and exactly what I was thinking of, thank you! :)
- flexiondotorg 4y agoZero to Nix introduces Nix, not NixOS the operating system. So, there's not really a need for screen shots as Zero to Nix it teaching how best to install and use Nix on any Linux or macOS. For that, code snippets are convenient I think.
- MikeTheGreat 4y agoFrom the questions in the parent post I wonder if it would be good to have a clear definition of what Nix is, what NixOS is, how they're different, and when to use each? Could just be a short paragraph, but if the site is for people just starting out it might be helpful...
- jt2190 4y agoJust my two cents: Nix doesn’t guarantee “reproducible”, just “repeatable”. (I think it’s helpful to keep these technical concepts distinct, and to introduce the right terminology when teaching, since it makes elaboration easier in the future.)
- kissgyorgy 4y agoCan you elaborate? From what I understand, Nix packages are mostly reproducible as they are running great lengths for that, to the point where every time in Nix land is the exact same.
- Filligree 4y agoNot bit-for-bit reproducible. Package builds can be nondeterministic, binaries can have embedded timestamps (e.g, build time), and so on. They should be semantically equivalent, but it's not fully guaranteed.
- dd_ 4y agoYou're not wrong overall, but your example is. In the build environment, the current time is set to the epoch which removes that variability. An upcoming feature of nix is content addressed builds which use the output hashes to determine the store path. This should make it much more transparent which builds are reproducible and which are not.
- Filligree 4y ago> In the build environment, the current time is set to the epoch which removes that variability. The amount of time per build can vary. Embedded timestamps will all be in January 1970, but even a single second difference means the binaries are no longer bit for bit identical -- and that assumes the embedded timestamp isn't microseconds.
- infogulch 4y ago
- JoelMcCracken 4y agoI have tried several times to dig into nix and make it stick. Each time I get a little further along, but I always get to the same stuck point: things that I am trying to combine are unclear to me how they should fit together, and/or there are just massive amounts of code for what should be a simple thing. Nix flakes has indeed made it all quite a bit easier. But, sadly, in the interim, there are lots of things in an in-between state.
- moojd 4y agoAs someone who uses nix daily for work and home, I've found that there is always a nice concise way to accomplish what I want, but finding that solution is extremely difficult. It seems like the best (and sometimes only) documentation is the code itself, so until you get comfortable with the language you are missing a majority of the documentation. It's a catch-22, you have to know nix to learn nix. It really shouldn't have to be that way.
- MisterTea 4y agoWhat does opinionated mean is this case? I read through a bit and didn't see any strong opinions.
- cole-h 4y agoThe most obvious example is that using the installer in the quick start enables the flakes and nix-command features automatically, even though they are still considered experimental by upstream.
- aendruk 4y ago# What's opinionated about Zero to Nix Zero to Nix is opinionated because it advocates learning and using flakes and treating channels as deprecated. Zero to Nix also deviates from official recommendations in that it recommends installing Nix using Nix Installer rather than the official Nix installation script. https://zero-to-nix.com/about#whats-opinionated-about-zero-to-nix https://zero-to-nix.com/about#whats-opinionated-about-zero-t...
- MisterTea 4y agoTo me using the word opinionated is a deterrent. Any time I hear the word opinionated used it usually means the opinion(s) expressed are overly strong, stubborn, and/or negative. I was expecting the guide to call out issues with the official documentation in a way that could upset the people working on the official docs. But this is just an alternative method. Hardly opinionated.
- aendruk 4y agoThe term has gained a specialized meaning in computing over the last decade or so. > Opinionated software means that there is basically one right way to do things […] Non-opinionated software leaves lots of flexibility to the user https://stackoverflow.com/q/802050 https://stackoverflow.com/q/802050 Providing only a single answer for how to do things is helpful for beginners who haven’t yet formed a basis upon which to make informed decisions.
- 4y ago
- drakerossman 4y agoIf you don't mind, a shameless plug: https://drakerossman.com/blog/nixos-for-apt-yum-users-a-gift-that-keeps-on-giving https://drakerossman.com/blog/nixos-for-apt-yum-users-a-gift... I am doing a similar series of NixOS-related stuff, currently got only a single article out, yet quite "meaty". You may want to check it out for a more streamlined approach in learning nix/NixOS which also compares it to familiar concepts from other Linux distributions. Will be releasing way more complete articles in the nearest future, hopefully within the next 2-3 weeks.
- baby 4y agoMy own shameless plug: nix by example https://mimoo.github.io/nixbyexample/ https://mimoo.github.io/nixbyexample/
- pxc 4y agoI really like the foreword, as it captures the best reason to use NixOS on a personal device: it makes your computer yours again. And that feels really good. It can make computers fun again when they've gotten dreary.
- Phlogi 4y agoIf I could push this to my kindle as an epub with an index. It would be great if these document frameworks would support it. At least a PDF.
- pxc 4y agoI used to do that with my e-readers via Pocket
- biggestlou 4y agoQuite duly noted! I'd love to provide other formats and will investigate this very soon. I can't guarantee that I'll come up with a solution given how vast and variegated the space is, but it's worth trying.
- unsupp0rted 4y ago> Welcome! It's great to see that you're interested in Nix. I sure am! What is Nix?
- MuffinFlavored 4y agoI would love to see a discussion from somebody who really likes Nix on why it isn't ready for prime time yet/just play devil's advocate aloud on why it isn't the greatest thing since sliced bread. I feel like I must not be doing anything "serious" enough to need package reproducibility at that high level. I'm aware of things like git checkout/tags, package-lock.json, Cargo.lock, Docker image tags. What is a real world use case where Nix isn't overkill? I've read toolchains but... nvm (node version manager), rustup. I still Rust on a machine once and I never think about it again. It feels like the Kubernetes of package management/build if you will complexity wise. "Do we really need this or is it just what everybody else is doing?"
- biggestlou 4y agoThis is a 100% fair point and I do agree that people can be overzealous with pushing Nix. For many projects, Nix is indeed overkill, and it's worth pointing out that some tools, like pnpm, have taken important cues from Nix. In many cases good enough really _is_ good enough and saying "just install npm using Homebrew or whatever you prefer" is totally fine. But when good enough isn't good enough and teammates and would-be contributors burn an hour installing dependencies just to push a small fix, that's where Nix can really shine. Another sweet spot is larger orgs where knowing that you can run `nix develop` in any repo and get everything you need is a legit superpower.
- hiimshort 4y agoI love Nix, all of my machines run NixOS, but I think it's 5-10 years out from widespread adoption. Currently the biggest issues have to do with severely lacking documentation, lack of developer tooling (missing things like LSP), very slow iteration cycles, confusing or impossible to understand errors, and even naming (Nix refers to the language, package manager, cli, community, etc). That said, right now it's still the best tool I've ever used. Nix is great at a few things: reproducible development environments, reproducible builds, and reproducible systems. I introduced Nix at my last job to do most of these things and it helped onboarding dramatically: Nix-based development environments with automatic activation, Nix-based Docker image builds which reuse the work done for the dev environment, and Nix-Darwin configuration to configure systems with one command. It's incredibly powerful and you're able to use as much or as little as you like. So the amount of "overkill" is variable. Of course, the problem here is that knowledge of Nix itself is necessary to build and maintain these things. Due to the reasons outlined previously, it is quite an investment. I believe it is worth it given the stability, flexibility, and efficiency Nix can provide.
- smasher164 4y agoI'm glad this guide is focused on flakes. If you're starting out with Nix, forget about home-manager, nix-env, and the pre-flake configuration model.
- licebmi__at__ 4y agoBut what if I manage my home-manager configuration with flakes.
- smasher164 4y agoUsually you’re on a single-user system anyway though. You should be able to manage all that with your global configuration.nix. You’ll also get the benefit of rollbacks.
- pxc 4y agoHome Manager is nice if you're on non-NixOS, where you don't have a configuration.nix. :)
- smasher164 4y agoI use configuration on macos as well, so I'm not sure what you mean?
- pxc 4y agoYeah, Home Manager is more redundant if you're using Nix-Darwin for a configuration.nix. Non-NixOS Linux doesn't have an equivalent module system to Nix-Darwin, though, so if you want a module system for declarative config there it's Home Manager.
- smasher164 4y agoI see. Yeah that's a shame.
- 4y ago
- whs 4y agoI'm trying Nix this weekend, and I'm surprised that many part of the core nixpkgs library are mostly undocumented. For example, searching with `"stdenv.isLinux" site:nixos.org -site:discourse.nixos.org -site:releases.nixos.org` returns a single result in total, which only contain the one usage of the function but no other list of available stdenv.is* functions.
- capableweb 4y agoMaybe `isLinux` is not the best example, as it's pretty much a self-documented boolean. But when I'm in the general situation you describe, I tend to just search github.com/NixOS/nixpkgs in order to figure out usage, if it's not documented elsewhere already. Here is an example for isLinux specifically: https://github.com/NixOS/nixpkgs/search?q=isLinux https://github.com/NixOS/nixpkgs/search?q=isLinux Reading through how the stdenv stuff is working might help as well, the generic lists a bunch of "is" booleans: https://github.com/NixOS/nixpkgs/blob/7e325cb89453651dbe9a17b67a4f85c4f71d4c08/pkgs/stdenv/generic/default.nix#L147 https://github.com/NixOS/nixpkgs/blob/7e325cb89453651dbe9a17... In general I agree, things are vastly under-documented, and that makes it kind of hard, and only solution I've found is digging deeper into sources. Which had the happy side-effect of me understanding NixOS better as well.
- suumcuique 4y agoI've been dipping my toes into the Nix ecosystem recently, having a dev environment per project with direnv is neat but how does this work with IDEs like VSCode or IntelliJ IDEA? For example, if I define a specific JDK in my project with Nix, will IntelliJ be able to pick this up? Does anyone have any good resources on how to set this up? BTW, for others who just want to try it out without having to install anything on your system, there are docker containers you can use as a sandbox: docker run -it nixos/nix bash
- casept 4y agoFor vscode, I like the `arrterian.nix-env-selector` extension. Can IntelliJ be configured to simply use whatever JDK belongs to the `javac` in PATH? If so, it should suffice to simply start it in a `nix-shell`. If not, maybe setting `JAVA_HOME` in your `.envrc` could help?
- pxc 4y agoVSCode and IntelliJ also both have direnv plugins for importing env vars from direnv after the fact. You can use that alongside direnv's Nix integration to load those variables without relaunching your editor/IDE!
- biggestlou 4y agoomg how did I not know about these?!?
- bryanlarsen 4y agoI've just been starting my Emacs from the direnv to ensure it has the right dev tools. This works, but can be annoying. It'd be nice to have a better solution.
- pxc 4y agoDoes emacs-envrc work with nix-direnv?
- weitzj 4y agoHow fast is nix on delivering security patches? I am looking for arguments to use it in an enterprise setting given the declarative nature but unless there is somebody who will sell you a support contract and Guarantee security updates it seems like a hard sell
- SuperSandro2000 4y agoIt is actually slower than Ubuntu which can be see with the recent git update BUT if you know you need this patch or update it enables you to achieve that with overlays pretty easy and fast and if you know what you are doing you can reduce the rebuild amounts to near zero. You also need to remember that behind NixOS there is not a big corp like canonical but mostly a community with way to much time. If you ever tried to build an Ubuntu package with a custom patch you will know how painful it is and unmaintainable. Not with nix. Easy maintenance included with automatic, atomic rebuilds and applying the patch to the next software version if the source code didn't change.
- djm_ 4y agoAs a Mac-using Python shop, we had serious file-sync performance issues when mounting our codebase inside a container via docker-compose. Nix completely freed us from them and allowed us to develop with Python natively speedily and without all the serious faff & headaches that usually comes with getting reproducible builds on everyone machines. If you'd like to know more, I spoke at DjangoCon Europe late last year [1] on our setup; it's still paying serious dividends for us! Happy to answer more. [1] https://www.youtube.com/watch?v=Mx3yiE_CJOY https://www.youtube.com/watch?v=Mx3yiE_CJOY
- pxc 4y agoThis is great! Also directly answers some questions commenters have given elsewhere on this submission, e.g., 'why not Docker?'.
- djm_ 4y agoYes! And it’s actually not either/or for us, we still use Docker Compose to run our services (Redis, PostgreSQL, etc) that don’t require file syncing with the host. It’s good at that.
- anton96 4y agoAbout NixOS, there's something really basic that I cannot seem to grasp. I had already installed many linux distro's with time, after the years I was really found on KDE and ZFS. I've stumbled upon this tutorial with great interests and yet I can't start to see what is the expected install workflow. Are you expected to write your nix config file booting on the live medium, how could you easily transfer this config file to your install medium. As much as I understand that targeting the right ZFS dataset and so should not be included in box and I was still happy to find some mention of it in the official doc. I don't understand this mix of an all seeing doc, spanning across many technologies and configurations set and yet what I could call the context is rather absent.
- pxc 4y agoAre you referring to impermanence or the erase-your-darlings config? This tutorial is for Nix itself, not the operating system based on it, which is why it doesn't include install instructions for NixOS. For a normal NixOS setup with ZFS, traditionally you just partition manually, then mount the datasets how you want for NixOS under /mnt, and the nixos-generate-config command generates a hardware-configuration.nix file which automatically includes all of those mounts for your to-be-installed NixOS system. You tweak configuration.nix on the target media under /mnt/etc/nixos/configuration.nix, and then run nixos-install and reboot into the new system.
- tripdout 4y agoJust made an account to say that I think this is great - a well structured, well explained, and most importantly guided introduction to Nix is exactly what's needed to get into it. Would also be awesome to see something like this for NixOS.
- SuperSandro2000 4y agoTwo years ago I didn't know a thing about nix, NixOS or functional programming. I wanted to manage multiple machines with a sort of config file. Shouldn't be that hard, right? Removal of packages should be done automatically without explicitly removing the package. So brew and ansible failed already with those, to me at the time, pretty basic requirements. Building deb meta packages was inconvenient and they broke every single time when I didn't update a machine for some weeks. Managing requires, replaces, conflicts was cumbersome and often put me into hard problems. Then I learned about nix. First it seemed rather complex. Why does it need to do everything different? Strongly believing that it won't solve my problems and it isn't worth the rather steep learning curve. I tried two weeks to find alternatives but there where none and slowly nix seemed to be the only available solution to my problem which first didn't seem to be that complicated... Here I am now. With LOTs of struggle and sweat. Never gave up debugging the most strange errors and very often fixing them in the end. Starting as a total beginner and very slowly becoming a very big fan, advocate and contributor to NixOS. Not regretting the journey. Being happy to have remove all Debian frickel kisten from my life. :) PS: If you run NixOS 22.05 or older: Some parts of the code for your machine is from me. How awesome is that? Couldn't have imagined that two years ago.
- Laaas 4y agoThanks for your work for Nix Sandro.