8 ms·
Nix journey part 0: Learning and reference materials
- julianeon 4y agoIt feels like Nix is crossing some kind of developer awareness threshhold. For me as someone perusing various tech threads, this feels like the year that, among developers, Nix is going mainstream.
- tomberek 4y agoMy main mission is to make Nix and Nix-based technology mainstream. Please reach out if you are interested, have thoughts or ideas. (plus we're hiring: https://floxdev.com/careers https://floxdev.com/careers ) This involves improving Nix itself, as well as building tooling for teams and organizations to be successful.
- k__ 4y agoIt just needs a JS/TS to Nix compiler and we're good to go. lol
- baby 4y agoWe just adopted nix at work so it def. feels like that from my point of view. If anyone reads this, here’s why I’ve been avoiding (and building without it) even though I wish I could use it: - slow as hell on mac - doesn’t work well with a project that makes use of Rust. We have weird rules for building and being able to dev with the Rust side (basically the devshell will try not to create a derivation for the rust stuff). Also every update of cargo.lock or rust-toolchain will break the nix install. - doesn’t work well with my tools (vscode). There’s a nix env plugin but it doesn’t work with flakes. Direnv plugins exist as well but they didn’t seem to work for me. - the shell doesn’t work without passing -i for me. Some env vars seem to break my nix - the defaults don’t take mac into account, which is insane imo, I wrote about it here: https://mimoo.github.io/nixbyexample/ https://mimoo.github.io/nixbyexample/ In general it feels like all the devs that are working on nix are not on mac, don’t use vscode, prolly don’t use Rust as well.
- ParetoOptimal 4y ago> - doesn’t work well with my tools (vscode). There’s a nix env plugin but it doesn’t work with flakes. Direnv plugins exist as well but they didn’t seem to work for me. The direnv plugin works with flakes for me using sn envrc reading `use flake` and using the home manager package nix-direnv. > In general it feels like all the devs that are working on nix are not on mac, don’t use vscode, prolly don’t use Rust as well. I think this is untrue, especially for rust. I know vscode is pretty popular with nix users too. I'd encourage asking for help on https://discourse.nixos.org https://discourse.nixos.org. Maybe a separate thread per issue.
- zach_mitchell 4y agoAuthor here if anyone has questions
- clem 4y agoAny good resources on how to use flakes? I'm currently experimenting with having home-manager work via a flake but I haven't come across any good HOWTOs on common operations. For example, I'd like to update the flake dependencies similar to how I used to use "nix-channel --update" to freshen the dependencies used by home-manager.
- Filligree 4y ago"nix flake update" should be able to do that.
- JamesSwift 4y agoThis is a script I run every monday when I come into work to get the latest updates on my system [1]. It prints the flake hash when it runs, so I can also rollback if there are issues. [1] - https://gist.github.com/J-Swift/a4dad59843f1a1f512a72308031b5a44 https://gist.github.com/J-Swift/a4dad59843f1a1f512a72308031b...
- zach_mitchell 4y agoHere you go: https://nixos.wiki/wiki/Flakes https://nixos.wiki/wiki/Flakes https://tonyfinn.com/blog/nix-from-first-principles-flake-edition/nix-8-flakes-and-developer-environments/ https://tonyfinn.com/blog/nix-from-first-principles-flake-ed... The second link appears to be down at the moment so check back later.
- tonyfinn 4y ago[dead]
- SkyMarshal 4y agohttps://www.reddit.com/r/NixOS/comments/v2xpjm/big_list_of_flakes_tutorials/ https://www.reddit.com/r/NixOS/comments/v2xpjm/big_list_of_f...
- coldblues 4y agoMy current objective is to make an easy and reproducible configuration + live image installer. I want to automate the whole process. As soon as I plug in the USB stick, my preferred defaults should do their work without user input. Although, I really don't like Nix as a language. I really wish it would have used something like GNU Guile. Searching deep for nuggets of information isn't nearly as painful as the language itself. I might adapt to it in time, but still.
- mr337 4y agoNot for sure if you are working on SD card based things but this might get you half way there. We do this for loading RPIs https://github.com/Robertof/nixos-docker-sd-image-builder https://github.com/Robertof/nixos-docker-sd-image-builder
- tomberek 4y agoCan you clarify what parts you don't like. I think it's important to distinguish so I know what portions to work on (and figure out how to fix it). Is it: the language syntax itself, the idioms used in Nixpkgs, the module system, the common frameworks used to create package sets, or something else?
- eximius 4y agoThe language is in a weird place. The language itself is okay, but you're often trying to use the language to compute a result that meets an interface that is never defined. There is very poor ability to reason about the 'types'/shapes of arguments or the semantics of what outputs should conform to. It seems to require either 1) deep knowledge about the orchestration of the evaluation of the key files you interact with (e.g., what the inputs to configuration.nix will be) or 2) reading many, many examples which eventually have the hints you want.
- eximius 4y agoFlakes may be a step in the right direction, but I admit I've somewhat halted my journey after finally grokking how to use nix channels and configuration.nix. I haven't done any packaging or gotten into flakes as a unit of composable configuration. I know flakes are intended to make these things easier, but even the 'specification' for what makes a valid flake seems awfully vague.
- Chatter9220 4y agoSo, I don't quite grok nix. Am I supposed to use it instead of Ansible and Terraform? Where does it fit exactly?
- xyproto 4y agoWithout having properly tried it either, my general impression is that the pitch goes a bit like this: If you love Haskell and wants to make everything that has to so with packages on your system more like Haskell, Nix's got your back.
- aliasxneo 4y agoBecause it's functional? I've been using Nix in production for six months and I have no desire to learn Haskell.
- otabdeveloper4 4y agoNix is nothing like Haskell. The store is built on standard Unix primitives ("worse is better"), and the core language is basically a stripped-down Javascript reskin.
- pxc 4y agoPlaying with Nix did increase my interest in functional programming, which was very new to me when I started using Nix. But I've never gotten around to learning Haskell, and I don't think Nix is just for FP people.
- JamesSwift 4y agoIt is a powerful abstraction that ends up being a replacement for several kinds of tools depending on your use case. It can be a way to declaratively configure a system similar to ansible. It can be a way to isolate runtimes (e.g. ruby v2.8 and ruby v3.0) in different projects similar to rbenv / virtualenv. It can be a way to define an application in a self-contained way so that the target platform needn't have needed software installed beforehand similar to docker. It can be a way to install packages/software to your system in a well-defined way similar to many package managers.
- pikanix 4y agoregarding function docs, https://noogle.dev/ https://noogle.dev/ is a new search tool to that effect
- bsnnkv 4y agoI really needed this, thank you for sharing!
- peter_l_downs 4y agoThe nix package search website is OK, but it doesn't let you filter by the names of installed binaries. A lot of the time, you have a question like "what nixpkgs attribute do i install in order to get the `python3` command". I recently wrote a command line tool that allows you to do this. It uses the same elasticsearch index as the search website, but allows more powerful filtering. If anyone is thinking of getting into nix, please consider trying it out! https://github.com/peterldowns/nix-search-cli https://github.com/peterldowns/nix-search-cli
- zach_mitchell 4y agoI've also noticed this. If you install `rustc` it says that you get `rust-gdb`, but that's really just a wrapper script around `gdb`, which it doesn't install.
- thomastjeffery 4y agoAnd vice versa. It's tricky to know what the binary will actually be named. I have had to look directly in the /nix/store enough times that I lost count.
- tonyfinn 4y agoI will say this is not a nix specific problem and also not trivially solvable by policy because of packages that contain multiple binaries as produced by the upstream developer (e.g. grep/fgrep/egrep, pacman/makepkg/pacman-key, , go/gofmt, ffmpeg/ffprobe, qemu has about a billion, etc.).
- thomastjeffery 4y agoIt would be trivial to print the contents of the nix store that package uses. It would be pretty straightforward to show only what ends up in the path.
- OmarAssadi 4y agoCool! I love Nix, but really am not a fan of the Nix package listing website. So, it is nice to see. And I guess worth mentioning, but if you or anyone else is ever feeling a little less lazy than me and want to add more available metadata, some of my main gripes with the official site: - No easy way to see dependencies without viewing the package derivation source code. - No easy way to see "reverse" dependencies, period, as far as I am aware, short of basically grepping the entire nixpkgs repo, and even then you won't get a totally accurate answer. This seems like it'd be awful to implement given I don't think you can realistically know this information without evaluating the entirety of `all-packages.nix`. But it is something I miss about stuff like Arch Linux's package website. And I think in some ways, it is even more important with stuff like Nix if you intend to override a particular package globally, since you may end up needing to rebuild god knows how many things as a result. - No easy way to filter by package types, outside of the very small set of existing package sets (e.g., `vimPackages`, `mpvScripts, etc). As an example, I'd really like to be able to see all font packages in the nixpkgs repo, but there's just no nice way to do this easily, unlike some other package managers. It would be another kind of awful feature to implement, since there is not currently any grouping that I am aware of. You /can/ kind of grep the `all-packages.nix` file and get a rough idea by searching for what packages call `./data/fonts`, but actually parsing that is pretty rough, since not everything is as simple as `font-name = callPackage ./data/fonts/font-name {};` A good example of that parsing annoyance would be the noto-fonts [1]. - No easy way to see build options. For example, packages like `mpv` or `ffmpeg_5` have loads of different feature flags, some of which are unexpectedly disabled or enabled. Again, I think this would be not fun to implement. But it is something that I think Gentoo gets really right with the listing of 'use flags' on their package listings [2] (in fact, Gentoo's site kind of gets everything right; it feels like the gold standard to me). NetBSD/pkgsrc is another one of the few that does well, albeit with a less-fancy design [3]. [1]: <https://github.com/NixOS/nixpkgs/blob/96c0fdeb6accc9f76f18871b154fcb6680e3afdb/pkgs/top-level/all-packages.nix#L27754 https://github.com/NixOS/nixpkgs/blob/96c0fdeb6accc9f76f1887...> [2]: <https://packages.gentoo.org/packages/media-video/ffmpeg https://packages.gentoo.org/packages/media-video/ffmpeg> [3]: <https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/multimedia/ffmpeg4/index.html https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/multimedia/...>
- Havoc 4y agoWhat sort of time investment is required to get vaguely competent at nix? Mostly dabble in self hosting stuff and not sure it’s worthwhile.
- colordrops 4y agoBeen using it for about a year now. It took me a couple months of rebuilding my laptop and homelab in my spare time to really feel comfortable. I'm still no expert at the language but I understand it and have "cookbook" examples in my config repo for most things I want to do.
- nickysielicki 4y agoMy advice: stick exclusively to flakes and it becomes significantly less complicated. It’s a totally different experience when you have to deal with channels and their global state. There are tons of warnings about how flakes are experimental and this leads people who are new to nix to think that it’s going to be more straightforward to stick to the legacy method. It’s an unfortunate situation, because it’s a reasonable assumption but nothing could be further from the truth.
- rgoulter 4y agoI'd compare it to the time investment in vim or emacs. Getting some basic stuff done is unlikely to be difficult. (e.g. using `nix shell nixpkgs#fd` to try out the `fd` tool). Getting a solution to a problem you have right now might be a quick copy-and-paste effort, or it might be a weekend's worth of tinkering to get even an unidiomatic solution. Gaining familiarity with it does take a long time though. Most NixOS users will be modest about their confidence in writing Nix code (albeit, most NixOS users are also very passionate about the advantages of Nix & NixOS can be).
- pxc 4y agoJumping in and running NixOS on my desktops at work and home is how I really learned it. I'd say that aside from routine usage, several hours of doing something at least a little 'custom' with it (packaging something new, defining project environments, writing or modifying NixOS modules, writing your first override, packaging for a new language ecosystem, etc.) per week will have you feeling pretty comfortable after just a few months. Basic stuff is easy, though, and I'd say it only takes a week or two for administering a VPS or something like that to start feeling really good. Something about the iteration loop with nixos-rebuild is satisfying and somehow very freeing. So you'll get that early payoff in a few days or maybe a couple weeks. Then you'll hit a wall and some problem will seem way harder than the experience so far. But you'll figure it out, and after a few months of occasional walls like that, real difficulties will become pretty rare. In a year, you'll be addicted. :) For me, the Nix learning curve was challenging, but it was not a grind. It has frequent moments of payoff that start pretty early. I'd say my main advice for keeping it enjoyable is just this: don't hesitate to engage the community if at any point you feel stumped. Nix has a truly outstanding community in terms of both technical expertise and generosity. Seeking help will accelerate your learning journey a lot, and make it feel less effortful.
- oslac 4y agoAha, yet another tutorial since nobody can agree on anything about it seems. I can set up a nice development environment within VSCode using development containers in like 2 or 3 clicks that I can just yeet to to my GitHub for anyone to use and you don't need this kind of PhD for it. For an average programmer or team, this stuff needs to be heavily, massively, streamlined / centralized to a single Best Practice.
- benniomars 4y agoI've always heard about nix operating systems. So when asked if I preferred an nix environment for development or windows, it was an easy answer. Now there is nixOS and a programming language called nix. I know this annoys me more than it should do, but it also keeps me away from the nix language and nixOS because I think the name is such a obvious stupid decision, that I'm worried what else stupid decisions they made and I don't want to invest my own time finding out.
- z3t4 4y agoI know people use various heuristics for quality assessment, but using the name is new to me and makes me even more anxious about naming things.