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 ]; \
}"
nix-env -i nixos.google-chrome
?