lib: use makeScopeWithSplicing' instead of makeScope (#634)

This commit is contained in:
Ivan Petkov 2024-06-03 02:48:19 +00:00 committed by GitHub
parent ae1453ffd0
commit 9787dc25b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 9 deletions

View File

@ -1,5 +1,13 @@
{ pkgs ? import <nixpkgs> { } }:
import ./lib {
inherit (pkgs) lib newScope;
inherit (pkgs) lib makeScopeWithSplicing';
otherSplices = {
selfBuildBuild = pkgs.pkgsBuildBuild;
selfBuildHost = pkgs.pkgsBuildHost;
selfBuildTarget = pkgs.pkgsBuildTarget;
selfHostHost = pkgs.pkgsHostHost;
selfHostTarget = pkgs.pkgsHostTarget;
selfTargetTarget = pkgs.pkgsTargetTarget;
};
}

View File

@ -75,6 +75,7 @@
# overridden above.
nativeBuildInputs = [
pkg-config
stdenv.cc
] ++ lib.optionals stdenv.buildPlatform.isDarwin [
libiconv
];

View File

@ -10,10 +10,9 @@
outputs = { nixpkgs, ... }:
let
mkLib = pkgs: import ./lib {
inherit (pkgs) lib newScope;
mkLib = pkgs: import ./default.nix {
inherit pkgs;
};
nodes = (builtins.fromJSON (builtins.readFile ./test/flake.lock)).nodes;
inputFromLock = name:
let

View File

@ -1,5 +1,6 @@
{ lib
, newScope
, makeScopeWithSplicing'
, otherSplices
}:
let
@ -7,8 +8,12 @@ let
current = lib.concatStringsSep "." (lib.lists.sublist 0 2 (lib.splitVersion lib.version));
isUnsupported = lib.versionOlder current minSupported;
msg = "crane requires at least nixpkgs-${minSupported}, supplied nixpkgs-${current}";
mySplice = f: makeScopeWithSplicing' {
inherit otherSplices f;
};
in
lib.warnIf isUnsupported msg (lib.makeScope newScope (self:
lib.warnIf isUnsupported msg (mySplice (self:
let
inherit (self) callPackage;

View File

@ -1,12 +1,12 @@
{ lib
, cargo
, jq
, pkgsBuildBuild
}:
let
inherit (pkgsBuildBuild)
cargo
fetchgit
jq
stdenv;
craneUtils = pkgsBuildBuild.callPackage ../pkgs/crane-utils { };
@ -42,7 +42,7 @@ stdenv.mkDerivation {
dontBuild = true;
dontFixup = true;
nativeBuildInputs = [
depsBuildBuild = [
cargo
craneUtils
jq