4 ms·
I want to love Nix but I just can't get it. Worked with it for 14 months and found I struggled to make small changes meaning we had to depend on DevOps for thin
by exdsq 5y ago
I want to love Nix but I just can't get it. Worked with it for 14 months and found I struggled to make small changes meaning we had to depend on DevOps for things I could whip up in Docker and bash in minutes. I don't even really know why I struggle with it so much, but the startup I'm working for mentioned using it and I just shuddered thinking about it.
- bspammer 5y agoUnfortunately there’s no shortcut other than investing several hours reading tutorials and then repeatedly breaking stuff on your own machine until you start to understand. It’s worth it though. There’s something magical about having an entire machine configured declaratively.
- rgoulter 5y agoI think it's comparable to using Terraform. If you're only setting up one server in some cloud, then probably it's easier to just set that up through the admin dashboard compared to setting up Terraform. For such a limited usecase, the benefit of "infrastructure as code" is that at least what you've got is documented. But with using Terraform, all sorts of use cases are then enabled beyond what you'd want to manage manually. Using Nix instead of manually installing a bunch of stuff seems fine either way. But stuff like nix-shell paired with direnv seems pretty neat.
- bspammer 5y agoI actually really agree that Terraform is a good analogy - you're frontloading the effort in a way that hopefully will make things easier in the future. I use Terraform to manage my own personal AWS account. Recently I needed a Windows VM to run some random exe file. I could have created an EC2 instance adhoc through the web console but I did it through terraform instead. It probably took me about 30 minutes longer than it would have otherwise, but now I've got that terraform module ready to go if I ever need a windows instance again in the future. It's got a properly configured security group that only allows access from my VPN, and it outputs the IP and admin password automatically. I'll never have to solve that problem again (well, for a few years if we're being realistic).
- exdsq 5y agoSadly in a truly Nix'd up DevOps environment it takes so much more time than 'several hours'. I got to grips with a local NixOS computer - that was fine - but when you're working with 10kloc Nix environments it's just so so hard to grasp.
- chriswarbo 5y ago> we had to depend on DevOps for things I could whip up in Docker and bash in minutes I absolutely believe you (Nix has a bit of a learning curve), but just as a counterpoint I'd like to mention that I've been using Nix with all sorts of languages (compiled and interpreted), for various projects (local applications, cloud services, static HTML sites, etc.), on Ubuntu, NixOS and macOS. I recently had to interact with Docker for the first time and found it very bizzare (annoyingly, lots of documentation (e.g. that of AWS ECS) assumes its readers are already familiar with Docker!). It took many attempts to install it, using various different guides, versions, etc., many of which turned out to be obsolete (e.g. "docker machine" was recommended, but that's apparently replaced by "docker desktop", but now I'm hearing I should use "docker compose"?). After I eventually figured out how Docker works, I ditched it completely since I found it easier and more reliable to build container images using Nix and run them directly.
- exdsq 5y agoI'll give Nix another go, but I find it hard to just start scrapping things together. For example how would I create a dev environment for a simple Node app, managing Yarn dependencies and connections with a postgresql db? These are the sorts of things I'd love tutorials on doing
- chriswarbo 5y agoI'm not a heavy Node user, but I do have a project which happens to use Yarn. Not sure if it's the best approach, but this is how I'm creating the node_modules folder: nixpkgs.yarn2nix-moretea.mkYarnModules { name = "my-project-deps"; pname = "my-project-deps"; version = "1.0"; packageJSON = ../package.json; yarnLock = ../yarn.lock; } I copy things around, invoke commands, etc. using `nixpkgs.runCommand`, which runs shell code (a lot like rules in Make). I'm not sure about postgresql, since I've not used it before: - You could use Nix to install the packages, and manage it yourself. That wouldn't be particularly different from non-Nix setups. - You could install it on NixOS by specifying these options in your config https://github.com/NixOS/nixpkgs/blob/release-21.05/nixos/modules/services/databases/postgresql.nix#L41 https://github.com/NixOS/nixpkgs/blob/release-21.05/nixos/mo... (they're also listed at https://nixos.org/manual/nixos/stable/options https://nixos.org/manual/nixos/stable/options but that page is slow). Of course, that requires NixOS (or a VM). - You could run it in a container/VM, e.g. like https://nix.dev/tutorials/integration-testing-using-virtual-machines https://nix.dev/tutorials/integration-testing-using-virtual-... but that seems a bit more advanced.