From 1c49b81263858c69b932da05ae63a7767b308e74 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 2 May 2022 15:49:04 +0300 Subject: [PATCH] config.allowUnfree: define as option --- nixos/modules/hardware/all-firmware.nix | 2 +- pkgs/stdenv/generic/check-meta.nix | 2 +- pkgs/top-level/config.nix | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/nixos/modules/hardware/all-firmware.nix b/nixos/modules/hardware/all-firmware.nix index 176056d0a917..da2bc8ffef4b 100644 --- a/nixos/modules/hardware/all-firmware.nix +++ b/nixos/modules/hardware/all-firmware.nix @@ -72,7 +72,7 @@ in { }) (mkIf cfg.enableAllFirmware { assertions = [{ - assertion = !cfg.enableAllFirmware || (config.nixpkgs.config.allowUnfree or false); + assertion = !cfg.enableAllFirmware || config.nixpkgs.config.allowUnfree; message = '' the list of hardware.enableAllFirmware contains non-redistributable licensed firmware files. This requires nixpkgs.config.allowUnfree to be true. diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 8ad5fa6b89bd..9903ceec0e36 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -13,7 +13,7 @@ let # for why this defaults to false, but I (@copumpkin) want to default it to true soon. shouldCheckMeta = config.checkMeta or false; - allowUnfree = config.allowUnfree or false + allowUnfree = config.allowUnfree || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1"; allowlist = config.allowlistedLicenses or config.whitelistedLicenses or []; diff --git a/pkgs/top-level/config.nix b/pkgs/top-level/config.nix index 1ee44a47af9f..cb713ec27730 100644 --- a/pkgs/top-level/config.nix +++ b/pkgs/top-level/config.nix @@ -58,6 +58,18 @@ let ''; }; + allowUnfree = mkOption { + type = types.bool; + default = false; + # getEnv part is in check-meta.nix + defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1"''; + description = '' + Whether to allow unfree packages. + + See Installing unfree packages in the NixOS manual. + ''; + }; + }; in {