From 1c49b81263858c69b932da05ae63a7767b308e74 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 2 May 2022 15:49:04 +0300 Subject: [PATCH 1/3] 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 { From 9f473092f84f9d704810146fec2a919bf96e5bf0 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 2 May 2022 17:20:44 +0300 Subject: [PATCH 2/3] config.allowBroken: define as option --- pkgs/stdenv/generic/check-meta.nix | 2 +- pkgs/top-level/config.nix | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 9903ceec0e36..ba9eae53d35f 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -34,7 +34,7 @@ let hasBlocklistedLicense = assert areLicenseListsValid; attrs: hasLicense attrs && lib.lists.any (l: builtins.elem l blocklist) (lib.lists.toList attrs.meta.license); - allowBroken = config.allowBroken or false + allowBroken = config.allowBroken || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1"; allowUnsupportedSystem = config.allowUnsupportedSystem or false diff --git a/pkgs/top-level/config.nix b/pkgs/top-level/config.nix index cb713ec27730..6bff00f982d6 100644 --- a/pkgs/top-level/config.nix +++ b/pkgs/top-level/config.nix @@ -70,6 +70,17 @@ let ''; }; + allowBroken = mkOption { + type = types.bool; + default = false; + # getEnv part is in check-meta.nix + defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1"''; + description = '' + Whether to allow broken packages. + + See Installing broken packages in the NixOS manual. + ''; + }; }; in { From 9f05fc666188c06d5bcc8c1f352d77244ec6f91d Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 2 May 2022 20:39:43 +0300 Subject: [PATCH 3/3] config.allowUnsupportedSystem: define as option --- pkgs/stdenv/generic/check-meta.nix | 2 +- pkgs/top-level/config.nix | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index ba9eae53d35f..e0ead55d1a78 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -37,7 +37,7 @@ let allowBroken = config.allowBroken || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1"; - allowUnsupportedSystem = config.allowUnsupportedSystem or false + allowUnsupportedSystem = config.allowUnsupportedSystem || builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1"; isUnfree = licenses: lib.lists.any (l: !l.free or true) licenses; diff --git a/pkgs/top-level/config.nix b/pkgs/top-level/config.nix index 6bff00f982d6..7665815d4125 100644 --- a/pkgs/top-level/config.nix +++ b/pkgs/top-level/config.nix @@ -81,6 +81,19 @@ let See Installing broken packages in the NixOS manual. ''; }; + + allowUnsupportedSystem = mkOption { + type = types.bool; + default = false; + # getEnv part is in check-meta.nix + defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1"''; + description = '' + Whether to allow unsupported packages. + + See Installing packages on unsupported systems in the NixOS manual. + ''; + }; + }; in {