0

I've started using NixOS. As far as I understand Nix is a purpose built functional language to avoid side-effects. All packages are part of a giant attribute set but as everything is lazily evaluated there is no problem. By accessing one member you basically "make something happen", but even then a "derivation" is just a value and you also need to explicitly "build" it too.

I wonder how environment.systemPackages is exactly implemented then and where I can find the source of it? (I've tried searching through nixpkgs but there were too many false positive hits.).

I just want to understand the whole process and possibly even hack up a config file so that a local user could have a declaratively managed list of packages installed (similar to systemPackages for all) versus using an imperative way of (automatically) running nix-env -i. I've seen ~/.config/nixpkgs/config.nix examples and am able to implement the packageOverrides function. But this way I would be just able to create some sort of new meta-package "including" others ones (still nothing would get automatically installed) or am I mistaken? I've heared about a thing called overlays - how does this concept fit into the picture?

  • 1
    It might help to break down your question to something specific. – Chris Stryczynski Apr 6 at 21:48
0

In terms of how environment.systemPackages is implemented, I would assume this value would be retrieved from the various scripts like nixos-install, nixos-rebuild etc which can be found here: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/installer/tools

But it appears to just be a list (in the Nix language).

Having had a look at them myself, it would probably be helpful to first understand how Nix works and then the Nixos related functionality.

0

users.users.<name?>.packages is what I was looking for.

I will try to rephrase the second part of my question (which made it quite confusing, sorry about it)

Suppose I have something like:

blah = [ pkgs.hello ];

is there any function f so that I could do:

f blah

and that would make package hello present on the system.

By now I realized that this is sort of a contradiction, because if there was, Nix wasn't free of side-effects. So I suppose Chris Stryczynski is right, there is some external tool for which environment.systemPackages is a thing but blah isn't. However I can probably implement f as

environment.systemPackages ++ blah

or something (treat the code samples as pseudo code and not as syntactically correct Nix).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.