A shower thought about installing NixOS packages

At the end of the day, Linux packages are just programs.

So, do we really need environment.systemPackages and the like?

Why not install everything as either a service or a program (pseudo code):

{
  environment.systemPrograms = with programs; {
    bat.enable = true;
    gimp.enable = true;
  
    fish = {
      enable = true;
  
      vendor = {
        config.enable = true;
        completions.enable = true;
        functions.enable = true;
      };
   };

   starhip.enable = true;
}

This way, we can install and configure programs from one central location. Also it prevents installing, for example, docker both as a package and also enabling it via virtualisation.

I’ve not thought about this thoroughly, but maybe services can also be installed from the same location:

{
  environment.system = {
    services = {
    };

    programs = {
    }
  };
}

and:

  users.users = {
    ben = {
      isNormalUser = true;
      description = "Ben";
      extraGroups = [ "networkmanager" "wheel"];

      services = {
      };

      programs = {
      };
    };
  }

There’s a prospective PR to turn environment.systemPackages into an attrset which avoids all this boilerplate but allows cleaner overriding.

Also, with programs; is dead code here, since true and false are builtins.

2 Likes

Syntax: this line is a bit more verbose than the current starship word (inside the list).

1 Like

I mean, I guess you can already do this: puntbestanden/modules/profiles/workstation.nix at 99c20beebbd58cf062c9515012959df23114ae76 · dtomvan/puntbestanden · GitHub

Also works well for mixing packages from different sources: puntbestanden/modules/services/copyparty.nix at 99c20beebbd58cf062c9515012959df23114ae76 · dtomvan/puntbestanden · GitHub

Though that doesn’t work if you have multiple packages in the form of inputs.<...>.packages.<...>.default since inheriting those means setting the attrname default multiple times…

2 Likes

This was just pseudo code. I am relatively new to Nix…