improve rust template for ensuring package overriable
This commit is contained in:
parent
dc5dfddf74
commit
18bfe1ce9a
6 changed files with 100 additions and 38 deletions
20
templates/rust/nix/cargo-artifacts.nix
Normal file
20
templates/rust/nix/cargo-artifacts.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
lib,
|
||||
basicArgs,
|
||||
buildInputs,
|
||||
nativeBuildInputs,
|
||||
}: let
|
||||
f = {
|
||||
craneLib,
|
||||
lib,
|
||||
...
|
||||
} @ args: let
|
||||
genInputs = lib.genInputsWith args;
|
||||
in
|
||||
craneLib.buildDepsOnly (basicArgs
|
||||
// {
|
||||
buildInputs = genInputs buildInputs;
|
||||
nativeBuildInputs = genInputs nativeBuildInputs;
|
||||
});
|
||||
in
|
||||
with lib; setFunctionArgs f ((functionArgs f) // (genFunctionArgs (buildInputs ++ nativeBuildInputs)))
|
||||
13
templates/rust/nix/lib.nix
Normal file
13
templates/rust/nix/lib.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
flip,
|
||||
pipe,
|
||||
splitString,
|
||||
head,
|
||||
listToAttrs,
|
||||
nameValuePair,
|
||||
getAttrFromPath,
|
||||
...
|
||||
}: {
|
||||
genFunctionArgs = flip pipe [(map (flip pipe [(splitString ".") head (flip nameValuePair false)])) listToAttrs];
|
||||
genInputsWith = pkgs: map (flip pipe [(splitString ".") (flip getAttrFromPath pkgs)]);
|
||||
}
|
||||
30
templates/rust/nix/package.nix
Normal file
30
templates/rust/nix/package.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
lib,
|
||||
basicArgs,
|
||||
buildInputs,
|
||||
nativeBuildInputs,
|
||||
}: let
|
||||
f = {
|
||||
craneLib,
|
||||
lib,
|
||||
cargoArtifacts,
|
||||
...
|
||||
} @ args: let
|
||||
genInputs = lib.genInputsWith args;
|
||||
in
|
||||
craneLib.buildPackage (basicArgs
|
||||
// {
|
||||
inherit
|
||||
(craneLib.crateNameFromCargoToml {
|
||||
cargoToml = "${toString basicArgs.src}/Cargo.toml";
|
||||
})
|
||||
pname
|
||||
version
|
||||
;
|
||||
inherit cargoArtifacts;
|
||||
buildInputs = genInputs buildInputs;
|
||||
nativeBuildInputs = genInputs nativeBuildInputs;
|
||||
doCheck = false;
|
||||
});
|
||||
in
|
||||
with lib; setFunctionArgs f ((functionArgs f) // (genFunctionArgs (buildInputs ++ nativeBuildInputs)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue