By the way, is there some way to specify dependencies in C? Like requirements.txt in Python, where you put libraries names and versions and the user has to run a single command to install them (and without requiring root privileges)? Is this nix/tvix/guix an equivalent of pip?
Interesting, but the word "containers" is scaring me. I wanted just a simple tool to download and install several libraries and not a full Docker/Kubernetes level system...
But it looks like a good choice for running tests in CI.
devenv.sh autogenerates Nix specifications of container images for each of the development environments you define with it, and exposes them in a Nix flake for you. But if you don't explicitly ask Nix to build those for you, it doesn't.
My team's most complex devenv environment passes through some packages from Nixpkgs, exposing them in the flake, defines 3 or 4 development environments ('devShells') and also exposed (and includes in some of those devShells) some custom packages that just live in that repo and not in Nixpkgs.
Our simplest just uses all built-ins and defaults, exposes no packages, doesn't have a custom flake... there's basically nothing to it. It just uses devenv/Nixpkgs built-ins to add OpenTofu with some Terraform plugins to the path and plugs a Terraform linter into the project's pre-commit hooks.
There is some support for running long-lived processes via process-compose, which is inspired by docker-compose, but we don't yet need it for anything so we don't use it. (In the past I've rolled my own solution for this with Nix, direnv, and supervisord. Today I'd probably just use devenv.)
What I love about devenv is how cleanly it integrates with the wider Nix ecosystem in a no-nonsense way, as well as its great docs. I like that it
- it uses the Nix module system for configuration, based on a standard implementation (flake-parts) shared by other projects
- what it builds in, i.e., pre-commit hooks integration, exists in a separate repo also usable on its own via flake-parts
- the docs and the tool both support flakes-based setups, non-flakes setups
- if you want to let devenv automagically set up a flake for you, you can, but you can also use most of its features with a handwritten flake.nix customized to your liking
- while it exposes some configuration via yaml for simple uses, the full power of Nix is always available
- it takes care of all the little details you'd have to deal with if rolling your own (e.g., garbage collection, direnv integration) in a sensible way
For me, as a Nix user, it does a good job of keeping simple use cases simple, it has low lock-in, it uses familiar configuration interfaces, and it doesn't have too much magic.
I hope that helps you get a sense of what using devenv is like for simple use cases as well as what the more complex stuff might look like!
nix eco has project(s) which instead building full images just plug tiny shim linked into nix store. nix-snapshotter. fast and small. oci images spec allows to do nice thing with nix.
is there some way to specify dependencies in C? Like requirements.txt in Python, where you put libraries names and versions and the user has to run a single command to install them (and without requiring root privileges)?
I'd describe this as "(language-specific) package management".
"Requiring root privileges" is more/less equivalent to "packages get installed in a system-wide location".
There are some C or C++ specific package managers.. but, essentially what's missing is the ecosystem/culture for providing a packages for those. -- e.g. With the Rust, packages use Cargo.
Is this nix/tvix/guix an equivalent of pip?
Nix and guix are system package managers.
Since they're powerful tools, one popular use case is for providing dependencies for C projects.
Nix practically requires root for its installation. (i.e. installing it without root may be possible, but I'd think it's impractical). Although once installed, it can provide packages without needing root.
It's possible, just beware that other-distro versions of Nix are pretty aggressive at patching themselves into your shell profiles, which is often undesirable.
Comments
By the way, is there some way to specify dependencies in C? Like requirements.txt in Python, where you put libraries names and versions and the user has to run a single command to install them (and without requiring root privileges)? Is this nix/tvix/guix an equivalent of pip?
Check out devenv.sh from the Cachix people, it allows you to list stuff like pip for any language, including services / postgresql extensions:
Interesting, but the word "containers" is scaring me. I wanted just a simple tool to download and install several libraries and not a full Docker/Kubernetes level system...
But it looks like a good choice for running tests in CI.
Hi! Devenv user here:
devenv.sh autogenerates Nix specifications of container images for each of the development environments you define with it, and exposes them in a Nix flake for you. But if you don't explicitly ask Nix to build those for you, it doesn't.
My team's most complex devenv environment passes through some packages from Nixpkgs, exposing them in the flake, defines 3 or 4 development environments ('devShells') and also exposed (and includes in some of those devShells) some custom packages that just live in that repo and not in Nixpkgs.
Our simplest just uses all built-ins and defaults, exposes no packages, doesn't have a custom flake... there's basically nothing to it. It just uses devenv/Nixpkgs built-ins to add OpenTofu with some Terraform plugins to the path and plugs a Terraform linter into the project's pre-commit hooks.
There is some support for running long-lived processes via process-compose, which is inspired by docker-compose, but we don't yet need it for anything so we don't use it. (In the past I've rolled my own solution for this with Nix, direnv, and supervisord. Today I'd probably just use devenv.)
What I love about devenv is how cleanly it integrates with the wider Nix ecosystem in a no-nonsense way, as well as its great docs. I like that it
For me, as a Nix user, it does a good job of keeping simple use cases simple, it has low lock-in, it uses familiar configuration interfaces, and it doesn't have too much magic.I hope that helps you get a sense of what using devenv is like for simple use cases as well as what the more complex stuff might look like!
I think containers are completely optional and it can install and run everything directly.
nix eco has project(s) which instead building full images just plug tiny shim linked into nix store. nix-snapshotter. fast and small. oci images spec allows to do nice thing with nix.
devenv has container support if you're looking for it, but you can completely ignore it if (like me) you don't care
One way to wrap your head around it is apt/systemd in a pip-like config file.
I'd describe this as "(language-specific) package management".
"Requiring root privileges" is more/less equivalent to "packages get installed in a system-wide location".
There are some C or C++ specific package managers.. but, essentially what's missing is the ecosystem/culture for providing a packages for those. -- e.g. With the Rust, packages use Cargo.
Nix and guix are system package managers.
Since they're powerful tools, one popular use case is for providing dependencies for C projects.
Nix practically requires root for its installation. (i.e. installing it without root may be possible, but I'd think it's impractical). Although once installed, it can provide packages without needing root.
Yes, write either a shell.nix or flake.nix file
https://nixos.wiki/wiki/Development_environment_with_nix-she...
It's possible, just beware that other-distro versions of Nix are pretty aggressive at patching themselves into your shell profiles, which is often undesirable.
Yes, Nix can do that. Another (simpler IMO) alternative is vcpkg.