nix icon indicating copy to clipboard operation
nix copied to clipboard

Imperative package management as a high-level interface for a declarative format

Open domenkozar opened this issue 3 years ago • 5 comments

Nix currently stores the profile at ~/.nix-profile/manifest.json in machine readable specification to be able to make operation on the profile.

The main goal of imperative package management is that it's easy to use, but I'd like we also add that it's possible to convert into declarative package management at some point.

Adding something like nix profile export that generates a flake would go a long way for automating getting into Nix the correct way.

domenkozar avatar Jan 27 '21 13:01 domenkozar

I've been chewing on a related thought: being able to concretize or export or a ~shell derivation from the implicit or ephemeral one created by running nix-shell -p <package>.

It occurred to me when I ran some nix-shell -p for something that doesn't exist, and the error shows that it's creating one:

$ nix-shell -p whoopsie
warning: --- Entry not found --------------------------------------------------------------------------------------------------------------------------------------------------- nix-shell
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: --- UndefinedVarError --------------------------------------------------------------------------------------------------------------------------------------------------- nix-shell
at: (1:94) from string

     1| with import <nixpkgs> { }; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (whoopsie) ]; } ""
      |                                                                                              ^

undefined variable 'whoopsie'

abathur avatar Jan 31 '21 17:01 abathur

I marked this as stale due to inactivity. → More info

stale[bot] avatar Jul 30 '21 20:07 stale[bot]

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/new-users-using-nix-not-nixos-wrong/9996/9

nixos-discourse avatar Oct 23 '21 17:10 nixos-discourse

Quick import/export. Not perfect, if you use a local "path:/" for nixpkgs it may not exist at the time of import.

export_profile(){
    nix profile list | cut -d' ' -f2
}
import_profile(){
    cat export | xargs nix profile install
}

tomberek avatar Feb 11 '22 12:02 tomberek

https://stop-using-nix-env.privatevoid.net/

domenkozar avatar Aug 06 '22 17:08 domenkozar

a method for specifying profiles declaratively would be gratly appreciated, as we see with nixos and home manager declarative configuration is really nice, i would like a per profile declarative configuration method. home manager is per user and nixos is per computer a per profile one could be useful.

dark-ether avatar Oct 16 '22 21:10 dark-ether

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-do-nix-profiles-and-flakes-fit-together/28139/4

nixos-discourse avatar May 13 '23 15:05 nixos-discourse

[nix profile] If you really need to imperatively manage some of your packages, this is your best option.

Let's just say that not everybody will be helped by home manager or whatever abstraction we build on top of it until there's been a bunch of very serious development in that part of the ecosystem.

nix profile install is great. There should be a nice and clear way to upgrade your global packages and it would be nice if there was some more visual feedback, but other than that, it's good.

I don't see a hard use case for why this should be converted to declarative other than to say: I'm going to go to another machine and I want the same global packages there without having to type everything. So a way to 'freeze' your current profile state into a flake or something would be nice to snapshot it and check it in.

Though also this isn't super important since the idea with a standard usage of nix would be to have a relatively thin set of global packages and have custom shells for any projects that are activated when needed.

alper avatar May 15 '23 08:05 alper

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/flakes-as-a-unified-format-for-profiles/29476/9

nixos-discourse avatar Jun 28 '23 08:06 nixos-discourse