mirror of
https://github.com/nix-community/naersk
synced 2024-11-10 06:04:17 +00:00
Add crate-specific overrides
This commit is contained in:
parent
c503759029
commit
4d0b369475
4 changed files with 39 additions and 4 deletions
28
build.nix
28
build.nix
|
@ -68,6 +68,8 @@
|
|||
, fetchurl
|
||||
, lndir
|
||||
, userAttrs
|
||||
, crateSpecificOverrides
|
||||
, pkgs
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -130,14 +132,16 @@ let
|
|||
jq
|
||||
rsync
|
||||
] ++ nativeBuildInputs
|
||||
++ lib.optionals (mode == "clippy") [clippy];
|
||||
++ lib.optionals (mode == "clippy") [clippy]
|
||||
++ neededCrateSpecificOverrides.nativeBuildInputs;
|
||||
|
||||
buildInputs = lib.optionals stdenv.isDarwin [
|
||||
darwin.Security
|
||||
darwin.apple_sdk.frameworks.CoreServices
|
||||
darwin.cf-private
|
||||
darwin.libiconv
|
||||
] ++ buildInputs;
|
||||
] ++ buildInputs
|
||||
++ neededCrateSpecificOverrides.buildInputs;
|
||||
|
||||
inherit builtDependencies;
|
||||
|
||||
|
@ -374,6 +378,26 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
neededCrateSpecificOverrides =
|
||||
let
|
||||
overridesList = builtins.map
|
||||
( crateInfo:
|
||||
if builtins.hasAttr crateInfo.name crateSpecificOverrides then
|
||||
crateSpecificOverrides.${crateInfo.name} { inherit crateInfo; }
|
||||
else {}
|
||||
)
|
||||
cratesIoDependencies;
|
||||
in builtins.foldl'
|
||||
(acc: elem:
|
||||
{
|
||||
buildInputs = acc.buildInputs ++ elem.buildInputs or [];
|
||||
nativeBuildInputs = acc.nativeBuildInputs ++ elem.nativeBuildInputs or [];
|
||||
}
|
||||
)
|
||||
{ buildInputs = []; nativeBuildInputs = []; }
|
||||
overridesList;
|
||||
|
||||
|
||||
# Crates.io dependencies required to compile user's crate.
|
||||
#
|
||||
# As an output, for each dependency, this derivation produces a subdirectory
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, libb, builtinz, arg }:
|
||||
{ lib, libb, builtinz, arg, pkgs }:
|
||||
let
|
||||
allowFun = attrs0: attrName: default:
|
||||
if builtins.hasAttr attrName attrs0 then
|
||||
|
@ -311,6 +311,8 @@ let
|
|||
# Example:
|
||||
# [ { name = "wabt", version = "2.0.6", sha256 = "..." } ]
|
||||
cratesIoDependencies = libb.mkVersions buildPlanConfig.cargolock;
|
||||
|
||||
crateSpecificOverrides = import ./crate_specific.nix { inherit pkgs; };
|
||||
};
|
||||
|
||||
# config used when planning the builds
|
||||
|
|
8
crate_specific.nix
Normal file
8
crate_specific.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{ pkgs }:
|
||||
|
||||
{
|
||||
openssl-sys = { ... }: {
|
||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||
buildInputs = with pkgs; [ openssl ];
|
||||
};
|
||||
}
|
|
@ -13,6 +13,7 @@
|
|||
, writeText
|
||||
, zstd
|
||||
, clippy
|
||||
, pkgs
|
||||
}@defaultBuildAttrs:
|
||||
|
||||
let
|
||||
|
@ -22,7 +23,7 @@ let
|
|||
{ inherit lib writeText remarshal runCommandLocal formats; };
|
||||
|
||||
mkConfig = arg:
|
||||
import ./config.nix { inherit lib arg libb builtinz; };
|
||||
import ./config.nix { inherit lib arg libb builtinz pkgs; };
|
||||
|
||||
buildPackage = arg:
|
||||
let
|
||||
|
|
Loading…
Reference in a new issue