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

Install instruction for nixos in package search recommend nix-env #672

Closed
1 task
symphorien opened this issue Jan 27, 2021 · 6 comments
Closed
1 task
Labels

Comments

@symphorien
Copy link
Member

Introduce your stance

nix-env is awkward to use, nix-env -u is fully broken so on nixos at least, it is better to advise people to use /etc/nixos/configuration.nix to install things.

Describe the issue

When one selects a package in the package search, two installations methods are provided:

  1. nix-env -iA nixos.foo for nixos
  2. nix-env -iA nixpkgs.foo for non nixos

The nixos tab should be something along the lines of "add environment.systemPackages = [ pkgs.foo ] to /etc/nixos/configuration.nix"
It may or may not mention using nix-env, but only as a second possibilty.

Page links

https://search.nixos.org/packages?channel=20.09&show=hello&from=0&size=50&sort=relevance&query=hello

Additional context
cc @flokli @Ekleog

  • I already created a Pull Request
@edolstra
Copy link
Member

No, nix-env is much easier to use than the declarative approach (where we can't even provide exact instructions, since "add environment.systemPackages = [ pkg.foo ]; to confguration.nix" is error-prone and not exact).

What is broken about nix-env -u?

@symphorien
Copy link
Member Author

What makes nix-env broken in my opinion:

nix-env -u is broken

Steps to reproduce

  1. install jdk8
#  nix-env -f "<nixpkgs>" -iA jdk8
installing 'openjdk-8u272-b10'
building '/nix/store/vwd7xj1jlwygr5fwdixsszwjdy8qwci8-user-environment.drv'...
created 102 symlinks in user environment
  1. update !
#  nix-env -u
upgrading 'openjdk-8u272-b10' to 'openjdk-15.0.1-ga-jre'
  1. jdk8 is gone 😱 Now I have jdk15 instead !

nix-env inherits the strangeness of channels

Ever since I have a user-wide <home-manager> channel, neither nix-env -iA nixos.jdk8 nor nix-env -iA nixpkgs.jdk8 works on my system. I must use nix-env -f "<nixpkgs>" -iA jdk8. I hear it is due to the legacy "defexpr", but I don't know for sure.

@edolstra
Copy link
Member

jdk8 is gone 😱 Now I have jdk15 instead !

Isn't that what you would expect to happen? 15.0.1 is a higher version than 8u272...

@flokli
Copy link

flokli commented Jan 28, 2021

The problem here is that the "versioned" part in the attribute name is resolved once during nix-env, and is lost afterwards. If I install jdk8, I'd expect to only get jdk8 minor version updates.

Using jdk8 in the NixOS configuration preserves this.

@fricklerhandwerk
Copy link
Contributor

@symphorien @garbas fixed by NixOS/nixos-search#514

@symphorien
Copy link
Member Author

nice !

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

No branches or pull requests

4 participants