Seems like you notion of “install” is from apt-like distros.
But did you think about why there are declarative and imperative ways to install a package? configuration.nix and nix-env?
Now you try to combine both approaches under single interface sudo cpkg install foo
Will this work by modifying configuration.nix
in a magical way? Or would it be separated from configuration?
I’m a bit skeptical about proposed tool, but I’ll put my answers here.
Some programs, you can just add them to environment.systemPackages. Others (that require additional setup like Systemd services or other configuration) require NixOS options to be installed.
That’s easy. There exists two NixOS options:
- environment.systemPackages
- systemd.packages
Packages specified in environment.systemPackages
will change only nix-profile and PATH, packages specified in systemd.packages
will change /etc/systemd only. That’s separation of concerns. But usually specifying package in systemd.packages
is not enough - you have to setup separate user, var-dir, conf files, probably interconnections with other services… which goes out of managing /etc/systemd.
I’m trying to build a tool that hides Nix’s complexity behind what looks like a normal package manager
Oh, c’mon. That’s “normal” package manager tries to hide complexity, while NixOS makes it explicit, but declarative and reproducible.
or when I should use programs…enable
I think, that the problem “which to chose to install a package” is a legitimate user question, but The User of NixOS doesn’t face existing solutions and their decision consequences.
If I want to install Vim, should I sudo nix-env -i vim
or programs.vim.enable = true;
? I can think of pros and cons for both approaches, but other users may not have this intuition.
Is there any way I can efficiently get a list of options to use for a package install?
nix-instantiate --eval -E ‘map (x: “programs.${x}”) (builtins.attrNames (import <nixpkgs/nixos> { configuration = {}; }).options.programs)’ --json --strict | jq
This will give you list of available “progams.foo.*” namespaces. You can continue namespace tree traversal in same manner.