jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
8.84k stars 209 forks source link

NIXPKGS_ALLOW_UNFREE env var not working #2196

Open eyevanovich opened 4 months ago

eyevanovich commented 4 months ago

What happened?

When trying to pull in a NUR flake that is unfree I am unable to get Devbox to accept NIXPKGS_ALLOW_UNFREE. This is due to the fact that the --impure flag is not being included during nix print-dev-env when using devbox shell.

More context can be found in this discord thread

Steps to reproduce

  1. devbox init
  2. debox add github:goreleaser/nur/ec67c3ebe81bd5614190e3dd4600089859d5b179#goreleaser-pro
  3. NIXPKGS_ALLOW_UNFREE=1 devbox shell

Command

shell

devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
  "packages": [
    "go@1.22.5",
    "tilt@0.33.10",
    "wget@1.21.4",
    "pre-commit@3.7.1",
    "python@3.12.3",
    "gnumake@4.4.1",
    "go-task@3.37.2",
    "_1password@2.28.0",
    "curl@8.7.1",
    "go-migrate@4.17.1",
    "air@1.52.1",
    "gnused@4.9",
    "github:goreleaser/nur/ec67c3ebe81bd5614190e3dd4600089859d5b179#goreleaser-pro"
  ],
  "env": {
    "GOBIN": "$PWD/bin",
    "PATH": "$PWD/bin:$PATH",
    "NIXPKGS_ALLOW_UNFREE": "1"
  },
  "shell": {
    "init_hook": [
      "task --silent env-setup"
    ],
    "scripts": {}
  }
}

Devbox version

0.12.0

Nix version

nix (Nix) 2.21.2

What system does this bug occur on?

macOS (Apple Silicon)

Debug logs

No response

snipebin commented 2 months ago

Similar issue with postgres timescaledb extension:

› NIXPKGS_ALLOW_UNFREE=1 devbox shell      
Info: Ensuring packages are installed.
✓ Computed the Devbox environment.
Error: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/Users/vinnie/projects/devbox/.devbox/gen/flake: Package ‘timescaledb-2.14.2’ in /nix/store/5w3dp0m37794iffsbm9vd9f1xmmhda6i-source/pkgs/servers/sql/postgresql/ext/timescaledb.nix:38 has an unfree license (‘TSL’), refusing to evaluate.: exit code 1

In my case I got around it by using config.allowUnfree = true in the nix flake configuration I'm using following https://github.com/jetify-com/devbox/issues/912#issuecomment-1574274094

postgres/flake.nix

{
  description =
    "A flake that adds the timescaledb extension to Postgresql";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = import nixpkgs { system = system; config.allowUnfree = true; };
      in {
        packages = {
          # Return postgrsql with the timescaledb extension included.
          postgresql = pkgs.postgresql_16.withPackages (p: [ p.timescaledb ]);
        };

        defaultPackage = self.packages.postgresql;
      });
}
fatrex commented 2 months ago

Similar issue with PHP OCI Extension

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
  "packages": [
    "php@7.2",
    "php72Extensions.oci8@latest"
  ],
  "env": {
    "NIXPKGS_ALLOW_UNFREE": "1"
  },
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

Output of devbox shell

Error: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/xxx/projects/xxx/xxx/.devbox/gen/flake: Package ‘oracle-instantclient-19.3.0.0.0’ in /nix/store/6spxbd5p43zgnx9hvsng5pjak11jmzwm-source/pkgs/development/libraries/oracle-instantclient/default.nix:118 has an unfree license (‘unfree’), refusing to evaluate.: exit code 1