4 ms·
Hey! We've been working at Cachix to address this using https://devenv.sh/ https://devenv.sh/. It's primary targeted to improve DX and on-board users quickly.
by domenkozar 4y ago
Hey! We've been working at Cachix to address this using https://devenv.sh/ https://devenv.sh/.
It's primary targeted to improve DX and on-board users quickly.
- amardeep 4y agoThanks Domen, devenv.sh is quite nice, and have already started using it.
- domenkozar 4y agoDo you still experience these UX issues and lack of documentation?
- pbronez 4y agoDevEnv looks neat, maybe I’ll try it. I expect my main hurdle will be stuff that isn’t in NicPkgs. Especially for dev stuff, I’m going to want to pull in low-profile GitHub stuff or Python packages. What’s the escape hatch to bring those into the dev environment?
- rgoulter 4y ago> What’s the escape hatch to bring those into the dev environment? One thing you can do is try the Nix package manager on your Linux or macOS system. -- If it's not in nix, you can just do it the way you did things before. If you want to try NixOS: 1. Writing a package is only necessary for sharing code.. you can still just have Python, setup a virtual env, & run the program as you would. 2. You could use a tool like Podman or Docker, to run stuff in containers. I've heard stuff like https://github.com/containers/toolbox https://github.com/containers/toolbox helps this. (Among other solutions).
- chriswarbo 4y ago> What’s the escape hatch to bring those into the dev environment? The function `pkgs.runCommand` is useful if you just want to run some Bash commands https://nixos.org/manual/nixpkgs/stable/#trivial-builder-runCommand https://nixos.org/manual/nixpkgs/stable/#trivial-builder-run... The main difference compared to running commands in a normal terminal is that builds are sandboxed, with no network access by default: - If your commands need to download some particular files, you can have Nix fetch them separately (e.g. using `fetchurl`, `fetchGit`, etc.) and provide them to your commands via env vars. See https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers - If you don't know what will be downloaded, or there's no way to run in an 'offline' mode, then you can specify hash for the result (making it a "fixed output derivation"). That will give it network access, and Nix will check that the output matches the given hash for reproducibility (you can just make up a random hash to start with; Nix will reject the result, telling you its hash, which you can copy/paste into the definition :) ) The reasons I like this approach include: - Bash is familiar/traditional and mostly-compatible with e.g. official install instructions provided by many projects, Stack Overflow answers, blog posts and tutorials, etc. - Powerful/unrestricted, in case we need to do some fiddling between some steps - Nix often reveals problems with those familiar/traditional instructions; e.g. if some deeply-nested part of an installer happens to run Python, it will fail if Python wasn't explicitly listed in its dependencies (AKA `buildInputs`). Revealing and fixing such things up-front avoids the "works on my machine" problem. - Bash commands are often tedious and inflexible; so after writing a few of these we may find ourselves wanting more structure, more reusable parts, etc. which is exactly what the helper functions in Nixpkgs provide (like `pkgs.stdenv.mkDerivation`, `pkgs.pythonPackages.buildPythonApplication`, etc.). In contrastt, starting off with those helper functions can seem overwhelming, and the benefits may be hard to appreciate immediately.
- amardeep 4y agoFor python, you could just install bare python with venv and/or poetry and manage your dev python dependencies outside nix. For eg. if you were using devenv.sh, there is an example here: https://github.com/cachix/devenv/tree/main/examples/python-poetry https://github.com/cachix/devenv/tree/main/examples/python-p...
- tripdout 4y agoThis looks like a really nice UX improvement on top of typical Flake devshells.
- theptip 4y agoI think this project is really promising. My main concern is that it puts another layer of abstraction atop an already complex (and at times leaky) abstraction. I’d love to see more clear docs about what devenv is actually doing under the covers, and how to escape-hatch into Nix land when I inevitably need to tweak something. Also, similarly, how do I map Nix docs (often just a set of example expressions) into equivalent devenv incantations? (It’s been a few months since I last looked so maybe things have come along since then.)
- __MatrixMan__ 4y agoI think that's a valid concern. You read the nix pills and think you know what you're doing and then it turns out that the community has wrapped the things you've learned about in things you've never heard of, so you still can't learn from other people's repos.
- sbt567 4y agoThis. I've been actively trying nix-based tooling on and off for my projects because it is legitimately solve the problem around sandboxing, versioning, reproducibility, consistency, etc. Recently, I'm trying to use asdf (and its faster alternative, rtx) and I keep telling myself "huh, nix could solve this problem better". But, damn it is infuriating to learn. Like other commenter said, it is the escape hatch that I'm missing so much. I really really want to convince myself to learn nix The Right Way. But, it feels like you will have another learning curve when using a nix-wrapper tooling. I still have a high hope for the future of nix. And I believe the time nix will rise in popularity is when they have sorted the UX-related issues.
- __MatrixMan__ 4y agoOne thing that has helped somewhat is being more thorough in my exploration of repo's that are doing things that are similar to what I'm trying to do. I want to use nix with a nim project, so I wrote a script that walks through all of the repo's in nimble (nim's package manager) and then filtered those for ones that had a flake.nix in the repo root. Going through them was a helpful dose of context. It's like you gotta approach it from theory to practice and from practice to theory and eventually your efforts will meet in the middle. I think. I have glimmers of meeting in the middle happening.