Skip to content

nix profile subcommands rely on index identifier #7961

@bobvanderlinden

Description

@bobvanderlinden

The main identifier for package entries in Nix profiles is the index. The index is quite bad as an identifier. Consider the following scenario:

$ nix profile list
....
3 flake:nixpkgs#legacyPackages.x86_64-linux.vim github:NixOS/nixpkgs/9952d6bc395f5841262b006fbace8dd7e143b634#legacyPackages.x86_64-linux.vim /nix/store/9hcby08vmd6k3zl3clwvlw5y5vkmc3z6-vim-9.0.0609
4 flake:nixpkgs#legacyPackages.x86_64-linux.cowsay github:NixOS/nixpkgs/9952d6bc395f5841262b006fbace8dd7e143b634#legacyPackages.x86_64-linux.cowsay /nix/store/azn0g0m6yg6m9vmdp3wq6wjbsd1znv44-cowsay-3.7.0 /nix/store/qgsl9bd6vvnpjaxhdnzg0xmycg3652c0-cowsay-3.7.0-man
5 flake:nixpkgs#legacyPackages.x86_64-linux.nano github:NixOS/nixpkgs/9952d6bc395f5841262b006fbace8dd7e143b634#legacyPackages.x86_64-linux.nano /nix/store/hhr8ijr2p5qf3lyklzyw8cndhsmpklsv-nano-7.2
$ nix profile remove 3
removing 'flake:nixpkgs#legacyPackages.x86_64-linux.vim'
$ nix profile remove 4
removing 'flake:nixpkgs#legacyPackages.x86_64-linux.nano'

In this case the numeric identifier in nix profile shifts with every change of the profile. In this case the user intended to remove vim and cowsay, but instead removed vim and nano. Very confusing.

The identifier in nix profile should be stable. It is probably up for debate what that should be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnew-cliRelating to the "nix" command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions