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
|
, fetchurl
|
||||||
, lndir
|
, lndir
|
||||||
, userAttrs
|
, userAttrs
|
||||||
|
, crateSpecificOverrides
|
||||||
|
, pkgs
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -130,14 +132,16 @@ let
|
||||||
jq
|
jq
|
||||||
rsync
|
rsync
|
||||||
] ++ nativeBuildInputs
|
] ++ nativeBuildInputs
|
||||||
++ lib.optionals (mode == "clippy") [clippy];
|
++ lib.optionals (mode == "clippy") [clippy]
|
||||||
|
++ neededCrateSpecificOverrides.nativeBuildInputs;
|
||||||
|
|
||||||
buildInputs = lib.optionals stdenv.isDarwin [
|
buildInputs = lib.optionals stdenv.isDarwin [
|
||||||
darwin.Security
|
darwin.Security
|
||||||
darwin.apple_sdk.frameworks.CoreServices
|
darwin.apple_sdk.frameworks.CoreServices
|
||||||
darwin.cf-private
|
darwin.cf-private
|
||||||
darwin.libiconv
|
darwin.libiconv
|
||||||
] ++ buildInputs;
|
] ++ buildInputs
|
||||||
|
++ neededCrateSpecificOverrides.buildInputs;
|
||||||
|
|
||||||
inherit builtDependencies;
|
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.
|
# Crates.io dependencies required to compile user's crate.
|
||||||
#
|
#
|
||||||
# As an output, for each dependency, this derivation produces a subdirectory
|
# 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
|
let
|
||||||
allowFun = attrs0: attrName: default:
|
allowFun = attrs0: attrName: default:
|
||||||
if builtins.hasAttr attrName attrs0 then
|
if builtins.hasAttr attrName attrs0 then
|
||||||
|
@ -311,6 +311,8 @@ let
|
||||||
# Example:
|
# Example:
|
||||||
# [ { name = "wabt", version = "2.0.6", sha256 = "..." } ]
|
# [ { name = "wabt", version = "2.0.6", sha256 = "..." } ]
|
||||||
cratesIoDependencies = libb.mkVersions buildPlanConfig.cargolock;
|
cratesIoDependencies = libb.mkVersions buildPlanConfig.cargolock;
|
||||||
|
|
||||||
|
crateSpecificOverrides = import ./crate_specific.nix { inherit pkgs; };
|
||||||
};
|
};
|
||||||
|
|
||||||
# config used when planning the builds
|
# 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
|
, writeText
|
||||||
, zstd
|
, zstd
|
||||||
, clippy
|
, clippy
|
||||||
|
, pkgs
|
||||||
}@defaultBuildAttrs:
|
}@defaultBuildAttrs:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -22,7 +23,7 @@ let
|
||||||
{ inherit lib writeText remarshal runCommandLocal formats; };
|
{ inherit lib writeText remarshal runCommandLocal formats; };
|
||||||
|
|
||||||
mkConfig = arg:
|
mkConfig = arg:
|
||||||
import ./config.nix { inherit lib arg libb builtinz; };
|
import ./config.nix { inherit lib arg libb builtinz pkgs; };
|
||||||
|
|
||||||
buildPackage = arg:
|
buildPackage = arg:
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in a new issue