Feature Request: Add allowUnfree setting to devbox.json

This issue has been tracked since 2022-12-29.

I currently have this devbox.json:

{
  "packages": [
    "php",
    "php81Extensions.blackfire",
    "php81Packages.composer"
  ],
  "shell": {
    "init_hook": null
  },
  "nixpkgs": {
    "commit": "7a3f450e4af7c015a78d5d182499c8c6170418e5"
  }
}

And when executing devbox shell I get this error:

Error: apply Nix derivation: running command /nix/var/nix/profiles/default/bin/nix-env --profile /Users/calvinbaart/dev/test_php/.devbox/nix/profile/default --install -f /Users/calvinbaart/dev/test_php/.devbox/gen/development.nix: exit status 1 with command output: replacing old 'devbox-development'
installing 'devbox-development'
error: Package ‘php-blackfire-1.84.0’ in /nix/store/wfcarnr78spyfyjyypb946j2ss1awp9l-source/pkgs/development/tools/misc/blackfire/php-probe.nix:200 has an unfree license (‘unfree’), 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: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
        (Flake) command, `--impure` must be passed in order to read this
        environment variable.

       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) [
             "php-blackfire"
           ];
         }

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnfree = true; }
       to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information)

In the error they recommend setting allowUnfree or nixpkgs.config.allowUnfree. So I tried that:

{
  "packages": [
    "php",
    "php81Extensions.blackfire",
    "php81Packages.composer"
  ],
  "shell": {
    "init_hook": null
  },
  "allowUnfree": true,
  "nixpkgs": {
    "commit": "7a3f450e4af7c015a78d5d182499c8c6170418e5",
    "allowUnfree": true,
    "config": {
      "allowUnfree": true
    }
  }
}

But that doesn't work. I also tried setting the environment variable in the init_hook but it's too late at that point. The only way to actually run it for now is NIXPKGS_ALLOW_UNFREE=1 devbox shell which I don't really like or creating a ~/.config/nixpkgs/config.nix file which would be another setup step.

Lagoja wrote this answer on 2023-01-03

@calvinbaart thank you for opening this issue! We've been considering having allowUnfree set to true by default, but I think your suggestion for the config is interesting too. Will discuss with the team for our sprint next week.

calvinbaart wrote this answer on 2023-01-03

Another possibility would be just passing through all the config options to nixpkgs.config. For example:

{
  "packages": [
    "php",
    "php81Extensions.blackfire",
    "php81Packages.composer"
  ],
  "shell": {
    "init_hook": null
  },
  "nixpkgs": {
    "commit": "7a3f450e4af7c015a78d5d182499c8c6170418e5",
    "config": {
      "allowUnfree": true,
      "allowUnfreePredicate": [ "php.blackfire" ],
      "otherOptions" ...
    }
  }
}

This would make it a bit more flexible for other possible config options, but I think that would be a bit more complicated
then just passing through allowUnfree only.

Lagoja wrote this answer on 2023-01-12

Update on this issue: Our upcoming 0.2.1 release will have allowUnfree set to true by default (See PR #428). We're still evaluating adding an object to devbox.json that would allow you to set Nix Config values as well

Lagoja wrote this answer on 2023-01-13

Creating a new issue to cover the nix config issues, and closing this since allowUnfree will be set to false in the upcoming 0.2.1 release. @calvinbaart we can continue discussion on the interface at #462 for upcoming releases

More Details About Repo
Owner Name jetpack-io
Repo Name devbox
Full Name jetpack-io/devbox
Language Go
Created Date 2022-08-18
Updated Date 2023-03-31
Star Count 4960
Watcher Count 19
Fork Count 68
Issue Count 42

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date