Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix profile remove --all keep nix itself by default #11715

Open
trim21 opened this issue Oct 18, 2024 · 5 comments
Open

nix profile remove --all keep nix itself by default #11715

trim21 opened this issue Oct 18, 2024 · 5 comments
Labels
feature Feature request or proposal

Comments

@trim21
Copy link

trim21 commented Oct 18, 2024

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Currently, nix profile remove --all will also remove nix itself, proposal to keep it by default, and require some extra flag or nix profile remove nix to remove it.

(I'm not using NixOS, but nixpkgs on debian, not sure how nix profile remove behave in NixOS.)

ref: #7966

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Priorities

Add 👍 to issues you find important.

@trim21 trim21 added the feature Feature request or proposal label Oct 18, 2024
@bobvanderlinden
Copy link
Member

Interesting one. I see a few solutions:

  • Skip Nix when using --all and warn that Nix hasn't been removed
  • Warn that Nix has been removed with instructions on how to reinstall it again using the store path of Nix.
  • Fail the operation altogether to avoid any removal and show error that Nix were to be removed with instructions on how to remove the other entries.

Detection of the Nix profile entry could be the current executable that is part of one of the store paths of a profile entry.

@trim21
Copy link
Author

trim21 commented Oct 19, 2024

Fail the operation altogether to avoid any removal and show error that Nix were to be removed with instructions on how to remove the other entries.

Sounds like this will make nix profile remove --all unusable at all?

@bryanhonof
Copy link
Member

bryanhonof commented Oct 21, 2024

Are you running nix profile as root, or do you have a single user Nix installation?
Because, I seem to have this distinction between the 2 profiles. The root one contains nix and nss-cacert, but the "user" one only has my installed packages.

$ nix profile install --profile ./bla nixpkgs#hello
$ ls
bla  bla-1-link
$ nix profile list --profile ./bla
Name:               hello
Flake attribute:    legacyPackages.aarch64-darwin.hello
Original flake URL: flake:nixpkgs
Locked flake URL:   github:nixos/nixpkgs/a9b86fc2290b69375c5542b622088eb6eca2a7c3?narHash=sha256-QUvb6epgKi9pCu9CttRQW4y5NqJ%2BsnKr1FZpG/x3Wtc%3D
Store paths:        /nix/store/0bc59ipsx1x8s9n2nc5h96cd4yhhrh28-hello-2.12.1
$ nix profile remove --profile ./bla --all
removing 'flake:nixpkgs#legacyPackages.aarch64-darwin.hello'
$ sudo nix profile list
warning: $HOME ('/Users/bryanhonof') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
Name:               nix
Store paths:        /nix/store/d88r5b1qv1fvz2j9qndz8sr31mqgz45x-nix-2.24.6

Name:               nss-cacert
Store paths:        /nix/store/9x1bbfhmnsycfq8p5y790jylnjiv0yif-nss-cacert-3.101

In the above example, running nix profile remove --all did not seem to impact the root profile.

@trim21
Copy link
Author

trim21 commented Oct 22, 2024

Are you running nix profile as root, or do you have a single user Nix installation? Because, I seem to have this distinction between the 2 profiles. The root one contains nix and nss-cacert, but the "user" one only has my installed packages.

single user Nix installation, nix is included in nix profile list, and my sudo doesn't have nix command.

In the above example, running nix profile remove --all did not seem to impact the root profile.

Yes, but it get removed from current user's profile

@bryanhonof
Copy link
Member

bryanhonof commented Oct 22, 2024

Okay, makes sense. Maybe we could check if argv[0] == thingTryingToRemoveFromProfile because that'd make little sense to remove from a profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal
Projects
None yet
Development

No branches or pull requests

3 participants