SteamOS 3.5.7+ Nix Configuration

Greetings!
As of the recent updates to the Steam Deck’s stable channel (running STeamOS 3.5.5+) there is now a /nix directory.
I’ve gone ahead and chowned it to deck:deck so the installer could access it.
After running the single-user installer everything seems fine except for when I want to install unfree applications- does anyone know where the single-user nix installer would put the configuration.nix file? Everything seems to either be in my home folder or /nix but I can’t seem to find it.

1 Like

Here’s an example of me trying to install unrar on the Deck. Be gentle with me, as I’m new to nixpkgs.

(deck@gabegearlcd .config)$ nix-env --install unrar
installing 'unrar-6.2.12'
error:
       … in the condition of the assert statement

         at /nix/store/nlm3wz58fjzcbf7d9csf2czxmrvsk65k-nixpkgs/nixpkgs/lib/customisation.nix:263:17:

          262|     in commonAttrs // {
          263|       drvPath = assert condition; drv.drvPath;
             |                 ^
          264|       outPath = assert condition; drv.outPath;

       … while evaluating the attribute 'handled'

         at /nix/store/nlm3wz58fjzcbf7d9csf2czxmrvsk65k-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:485:7:

          484|       # or, alternatively, just output a warning message.
          485|       handled =
             |       ^
          486|         {

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Package ‘unrar-6.2.12’ in /nix/store/nlm3wz58fjzcbf7d9csf2czxmrvsk65k-nixpkgs/nixpkgs/pkgs/tools/archivers/unrar/default.nix:54 has an unfree license (‘unfreeRedistributable’), refusing to evaluate.

       a) To temporarily allow unfree packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNFREE=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnfree = true; }
       in configuration.nix to override this.

       Alternatively you can configure a predicate to allow specific packages:
         { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
             "unrar-6.2.12"
           ];
         }

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnfree = true; }
       to ~/.config/nixpkgs/config.nix.

Hi! Nix and NixOS are different things (layers), and configuration.nix refers to the latter (so does nixos-rebuild).

To use unfree packages you need to import nixpkgs with the config.allowUnfree = true argument, e.g. in an expression: import <nixpkgs> { config.allowUnfree = true; }, or in the CLI: nix-shell --arg config '{ allowUnfree = true; }' -p unrar. When you use Nix without the pure evaluation mode (the default when you use flakes), nixpkgs can also implicitly populate these arguments from your environment variables (e.g. NIXPKGS_ALLOW_UNFREE=1 nix-shell -p unrar) or from ~/.config/nixpkgs/config.nix. Note that nix-env and nix-build (also nix shell -f ... and nix build -f ...) accept --arg too

Note that in the pure evaluation mode Nix won’t be able to “cheat” and see these paths and variables (for good reasons), so you’ll want to pass them explicitly

P.S. If you’re interested in using NixOS on a SteamDeck you can check out the NixOS Jovian project (I’ve personally no idea what state it’s in).
P.P.S. You might want to avoid “installing” packages with nix-env and look into ephemeral nix-shells or into managing a more persistent environment with home-manager

1 Like

Hmm it seems I still haven’t learned enough about this. Thank you for the info, I’ll look into shells more.