6

How can I install google chrome in nixos? I have tried

nix-env -i google-chrome
nix-env -i google-chrome-stable
...

Which does not seem to work. I also tried using the unstable branch

nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel --update

and then

nix-env -i unstable.google-chrome-stable
nix-env -i unstable.google-chrome
...

However it looks like the package should exist somewhere. https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/browsers/google-chrome

Does anybody know what I am missing here?

4
  • What do you mean by "Which does not seem to work?" Commented Mar 13, 2018 at 1:56
  • The packages are not found
    – Arwed Mett
    Commented Mar 13, 2018 at 17:11
  • Have you tried nix-env -i nixos.google-chrome? Commented Mar 13, 2018 at 18:57
  • just tried it. it also does not work
    – Arwed Mett
    Commented Mar 14, 2018 at 10:57

2 Answers 2

4

This NixOS FAQ question helped me:

How can I install a proprietary or unfree package?

You won't be able to install or search for an unfree package as a user, unless you explicitly enable it in ~/.config/nixpkgs/config.nix (the file and folder may need to be created):

{   # [...]   allowUnfree =
true; } 

When using NixOS, it is possible to enable unfree packages system-wide, then set in your /etc/nixos/configuration.nix:

{   # [...]   nixpkgs.config.allowUnfree = true; } 

Note that this alone will not allow you to search for or install packages with nix-env.

For temporary allowing unfree packages you can set the environment variable NIXPKGS_ALLOW_UNFREE, e.g.

NIXPKGS_ALLOW_UNFREE=1 nix-env 

Note that we are not able to test or build unfree software on Hydra due to policy. Most unfree licenses prohibit us from either executing or distributing the software.

From the console with nix-env:

$ NIXPKGS_ALLOW_UNFREE=1 nix-env -qa | grep google-chrome
google-chrome-63.0.3239.132
google-chrome-beta-64.0.3282.71
google-chrome-dev-65.0.3311.3

"Chapter 6. Global configuration" of the NixPkgs manual goes even deeper into the details (especially section 6.3. Installing unfree packages).

I found the rehno-lindeque/NixSetup.md gist exremely helpful with tons of extra resources and comments.


edit: Ditched nix-env a while back, and I use nix-shell instead; I only put installables in /etc/nixos/configuration.nix that need extra config, such as vim. This way I'm not dependent on channels as much (hope to learn flakes at one point..:).

So when I need a tool (e.g., peek, google-chrome, treesheets, etc.), this is what I go for:

$ NIXPKGS_COMMIT="dc849ffbcd93c2a23e99dcc94efb0962594b8b5f"
$ NIXPKGS_TARBALL="https://github.com/NixOS/nixpkgs/tarball/${NIXPKGS_COMMIT}"
$ PKGS="(callPackage (fetchTarball ${NIXPKGS_TARBALL}) {})"

$ NIXPKGS_ALLOW_UNFREE=1 nix-shell -v -p "${PKGS}.google-chrome"

$ nohup google-chrome-stable & > ~/.nohup.out # or /dev/null
$ disown

(See this great answer on nohup vs disown.)


edit-2: A Nix shell can also be improvised on the terminal:

NIXPKGS_ALLOW_UNFREE=1                                  \
nix-shell -v -E                                         \
"let                                                    \
   pkgs = import (fetchTarball ${NIXPKGS_TARBALL}) {};  \
 in                                                     \
   pkgs.mkShell {                                       \
     buildInputs = with pkgs; [ google-chrome elixir ]; \
   }"
0

Basically, you need to check channel name first:

$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable

Once you know the channel name, in this case nixpkgs, then you can proceed to installation:

$ nix-env -iA nixpkgs.google-chrome
installing ‘google-chrome-64.0.3282.186’
..................

Alternatively, you can search fully qualified name before perform the installation:

$ nix-env -qaP google-chrome                                                                                                                               
nixpkgs.google-chrome  google-chrome-64.0.3282.186

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .