如何在每种情况下在 Nix 中允许“不自由”的软件包?:{NixOS、Nix、Nix with Flakes、Nix with Flakes 和 Home Manager}

问题描述 投票:0回答:1

在 Mac OS 上将 MyNixOS(适用于 Nix 的优秀 Flake 配置应用程序)与 Nix Flakes 一起使用时,我尝试全局或按包启用允许“不自由”包。

在执行以下 Flake 更新和 Darwin 重建命令后尝试安装任何不免费的软件包时:

cd ~/.nix/mynixos-nix-darwin-loader;
nix flake update;
darwin-rebuild switch --show-trace --flake .#name_of_my_config'

我收到以下帮助消息,这不是很有帮助,因为它没有考虑 Flake 场景:

       error: Package ‘ec2-api-tools-1.7.5.1’ in /nix/store/${hash}-source/pkgs/tools/virtualization/e
c2-api-tools/default.nix:36 has an unfree license (‘amazonsl’), 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) [
             "ec2-api-tools"
           ];
         }

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

使用 MyNixOS 下载以下 Flake 文件,并且

/nix/store/${hash}-source/homeConfigurations/my_flake_name.nix

{ inputs, ... }@flakeContext:
let
  homeModule = { config, lib, pkgs, ... }: {
    config = {
      home = {
        packages = [
          ec2-api-tools
          # ... more packages
        ];
        stateVersion = "23.11";
      };
      nixpkgs = {
        config = {
          allowUnfree = true;
          # allowUnfreePredicate = (_: true);
          allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
            "ec2-api-tools"
          ];
        };
      };

这会产生

allowUnfreePredicate
设置的配置路径:
homeModule.config.nixpkgs.config.allowUnfreePredicate
。这看起来正确吗?

此配置似乎没有什么区别,安装不免费的软件包总是会导致相同的错误。

到底需要做什么才能在这些不同的场景中允许不自由的软件包?

  • 尼克斯操作系统
  • 尼克斯
  • 尼克斯与薄片
  • Nix 与 Flakes 和 Home Manager

(请编辑列表或让我知道如果它没有意义)

以下网页的建议似乎不适用,或者我不知道如何应用它:

nix nix-flake home-manager
1个回答
0
投票

nixpkgs.config
中设置
homeModule
在这里没有意义;由于您似乎将
nix-darwin
与 HM 作为系统模块一起使用,因此您必须在系统级别配置
nixpkgs
,而不是在 HM 模块内。

© www.soinside.com 2019 - 2024. All rights reserved.