the-nix-way / dev-templates

Dev environments for numerous languages based on Nix flakes [maintainer=@lucperkins]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I add an unfree dependency to `buildInputs`?

x10an14 opened this issue · comments

Like jetbrains.idea-ultimate ref option b) below:

error: Package ‘idea-ultimate-2022.1.3’ in /nix/store/vxkgqbm8k5l9b6kp66dzcrb2w7qgdbgg-source/pkgs/applications/editors/jetbrains/default.nix:123 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) [
             "idea-ultimate"
           ];
         }

       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)
direnv: nix-direnv: renewed cache
direnv: export ~XDG_DATA_DIRS

I'm going to close this issue, as adding unfree dependencies needs to be enabled in Nix itself rather than in a flake: https://nixos.wiki/wiki/FAQ/How_can_I_install_a_proprietary_or_unfree_package%3F

I had forgotten about this. I think I assumed IntelliJ was almost to consider a "must" for Java development, and therefore found it weird that the Java/kotlin(? don't remember) templates didn't include unfreePredicate set for said packages.

I'm happy leaving it closed now that I've learned and understand more about how nixpkgs and flakes works.

I suspect IntelliJ probably is a must for Java development but I'm not so sure that people use IntelliJ on a per-project basis. I could be wrong!