Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make-derivation.nix: warn that meta.available is deprecated #227342

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions nixos/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ with import ../lib;
with import ../pkgs/top-level/release-lib.nix { inherit supportedSystems; };

let
nixpkgsFun = args: import ./..
(
{ inherit system; }
# TODO: have OfBorg set inOfBorg correctly, then remove this hack
// lib.optionalAttrs (nixpkgs.revCount == 999999) { config.inOfBorg = true; }
// args);

version = fileContents ../.version;
versionSuffix =
Expand All @@ -21,7 +27,7 @@ let
allTestsForSystem = system:
import ./tests/all-tests.nix {
inherit system;
pkgs = import ./.. { inherit system; };
pkgs = nixpkgsFun { };
callTest = config: {
${system} = hydraJob config.test;
};
Expand All @@ -31,7 +37,7 @@ let
allDrivers =
import ./tests/all-tests.nix {
inherit system;
pkgs = import ./.. { inherit system; };
pkgs = nixpkgsFun { };
callTest = config: {
${system} = hydraJob config.driver;
};
Expand All @@ -41,7 +47,7 @@ let
allTests =
foldAttrs recursiveUpdate {} (map allTestsForSystem supportedSystems);

pkgs = import ./.. { system = "x86_64-linux"; };
pkgs = nixpkgsFun { system = "x86_64-linux"; };


versionModule =
Expand All @@ -54,7 +60,7 @@ let
makeIso =
{ module, type, system, ... }:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -67,7 +73,7 @@ let
makeSdImage =
{ module, system, ... }:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -78,7 +84,7 @@ let
makeSystemTarball =
{ module, maintainers ? ["viric"], system }:

with import ./.. { inherit system; };
with nixpkgsFun { };

let

Expand Down Expand Up @@ -224,7 +230,7 @@ in rec {
# A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
ova = forMatchingSystems [ "x86_64-linux" ] (system:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -238,7 +244,7 @@ in rec {

# KVM image for proxmox in VMA format
proxmoxImage = forMatchingSystems [ "x86_64-linux" ] (system:
with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -250,7 +256,7 @@ in rec {

# LXC tarball for proxmox
proxmoxLXC = forMatchingSystems [ "x86_64-linux" ] (system:
with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -263,7 +269,7 @@ in rec {
# A disk image that can be imported to Amazon EC2 and registered as an AMI
amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -277,7 +283,7 @@ in rec {
);
amazonImageZfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -295,7 +301,7 @@ in rec {
# automatic sizing without blocking the channel.
amazonImageAutomaticSize = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -312,7 +318,7 @@ in rec {
# An image that can be imported into lxd and used for container creation
lxdImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand All @@ -328,7 +334,7 @@ in rec {
# Metadata for the lxd image
lxdMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:

with import ./.. { inherit system; };
with nixpkgsFun { };

hydraJob ((import lib/eval-config.nix {
inherit system;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/libdrm/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ stdenv, lib, fetchurl, pkg-config, meson, ninja, docutils
, libpthreadstubs, libpciaccess
, withValgrind ? valgrind-light.meta.available, valgrind-light
, withValgrind ? lib.meta.availableOn stdenv.hostPlatform valgrind-light, valgrind-light
}:

stdenv.mkDerivation rec {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ let
}"
else
"key 'meta.${k}' is unrecognized; expected one of: \n [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]";
checkMeta = meta: lib.optionals config.checkMeta (lib.remove null (lib.mapAttrsToList checkMetaAttr meta));
checkMeta = meta: lib.optionals config.checkMeta (lib.remove null (lib.mapAttrsToList checkMetaAttr (builtins.removeAttrs meta [ "available" ])));

checkOutputsToInstall = attrs: let
expectedOutputs = attrs.meta.outputsToInstall or [];
Expand Down
31 changes: 27 additions & 4 deletions pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,33 @@ else let
} // {
# Expose the result of the checks for everyone to see.
inherit (validity) unfree broken unsupported insecure;
available = validity.valid != "no"
&& (if config.checkMetaRecursively or false
then lib.all (d: d.meta.available or true) references
else true);
available =
let
message = lib.strings.replaceStrings ["\n"] [" "] ''
pkg.meta.available is deprecated; please do not use it
from within nixpkgs. It depends on impure environment
variables (NIXPKGS_ALLOW_*) and config.allow* settings
which users expect should influence only the success or
failure of a build rather than which dependencies are
included. Please consider using `lib.meta.availableOn
stdenv.hostPlatform pkg` instead
'';
valid = validity.valid != "no"
&& (if config.checkMetaRecursively or false
then lib.all (d: d.meta.available or true) references
else true);
# gross hack, remove when ofborg is fixed
inOfBorg =
(config.inOfBorg or false) ||
lib.strings.hasSuffix ".gc-of-borg-stats.json"
(builtins.getEnv "NIX_SHOW_STATS_PATH");
in
# TODO: have Hydra and OfBorg `import check-meta.nix` and
# apply it to `pkg`, rather than embedding this value in
# pkg.meta.
if inOfBorg || (config.inHydra or false) || !(config.checkMeta or true)
then valid
else lib.warn message valid;
};

checkedEnv =
Expand Down
2 changes: 1 addition & 1 deletion pkgs/tools/filesystems/ceph/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
assert cryptopp != null || (nss != null && nspr != null);

let
shouldUsePkg = pkg: if pkg != null && pkg.meta.available then pkg else null;
shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;

optYasm = shouldUsePkg yasm;
optExpat = shouldUsePkg expat;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/tools/misc/atuin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ rustPlatform.buildRustPackage rec {
--zsh <($out/bin/atuin gen-completions -s zsh)
'';

nativeCheckInputs = lib.optionals xvfb-run.meta.available [
nativeCheckInputs = lib.optionals (lib.meta.availableOn stdenv.buildPlatform xvfb-run) [
xvfb-run
];

checkPhase = lib.optionalString xvfb-run.meta.available ''
checkPhase = lib.optionalString (lib.meta.availableOn stdenv.buildPlatform xvfb-run) ''
runHook preCheck
xvfb-run cargo test
runHook postCheck
Expand Down
6 changes: 6 additions & 0 deletions pkgs/top-level/impure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ assert args ? system -> !(args ? localSystem);

import ./. (builtins.removeAttrs args [ "system" ] // {
inherit config overlays localSystem;
} // {
# TODO: have OfBorg set inOfBorg correctly, then remove this hack
config = config // (if config.revCount or 0 == 999999 then {
inOfBorg = true;
} else { });
})