Nixpkgs "standard library"

Hi,

Is there any project/repo that contains “standard library” functions extracted from the Nixpkgs repo?

Currently reading the Nixpkgs manual, and it seems that the Nixpkgs repo consists of

  • functions that actually help build (cross-platform) packages (written using the Nix builtin’s/primitives)
  • collection of packages

Tried to find decentralization examples, but there aren’t many (or I didn’t find them). I like Cachix and the philosophy behind it, but that is for already built packages (unless I misunderstand something, which is more than possible).

Some of the resources found:

Thank you!

PS. Also posted this on Stackoverflow.

2 Likes

A lot of the functions you refer to rely on packages to provide the commands used to implement them, so the seperation between functions and packages (outside of lib at least) is not so clear.

If you want to have a custom package repository, you can either import nixpkgs to get access to the bits of it you want, or just maintain a custom Nixpkgs tree.

Personally, I prefer the latter, because it ensures that the version of Nixpkgs is always the version your custom packages were written for.

1 Like

Started thinking about this again, in that it would be nice to be able to refer to the Nixpkgs standard library as a package itself that could be pinned to a specific version1 - and also to opt out of it altogether if one wishes.

[1]: To make sure that a given function is available, and that availability is not tied to where we are in the Nixpkgs commit tree. I know that something like if builtins ? getEnv then builtins.getEnv "PATH" else "" can always be used but standard libraries are usually versioned for a reason.

Just found the Reddit post Using Nix without nixpkgs where @parkerhoyes already figured out how to use Nix without Nixpkgs, and also posting the repo parkerhoyes/nix-busybox-bootstrapper) as a reference.

@tad 's comment also caught my eyes:

What could be interesting is packaging up stdenv as a flake to make use-cases like this possible, but that’s a future development.

The entire thread is illuminating.

4 Likes