Add buildWithCargo as a thin wrapper around mkDerivation

This commit is contained in:
Ivan Petkov 2021-12-26 16:18:22 -08:00
parent 83632355d2
commit e1b7cea23c
No known key found for this signature in database
GPG Key ID: BB6F9EFC065832B6
4 changed files with 32 additions and 3 deletions

View File

@ -19,8 +19,12 @@
inherit system; inherit system;
}; };
myPkgs = myPkgsFor pkgs;
# To override do: lib.overrideScope' (self: super: { ... });
lib = import ./lib { lib = import ./lib {
inherit (pkgs) lib newScope; inherit (pkgs) lib newScope;
inherit myPkgs;
}; };
checks = pkgs.callPackages ./checks { }; checks = pkgs.callPackages ./checks { };
@ -28,7 +32,7 @@
{ {
inherit checks lib; inherit checks lib;
packages = myPkgsFor pkgs; packages = myPkgs;
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
inputsFrom = builtins.attrValues checks; inputsFrom = builtins.attrValues checks;

21
lib/buildWithCargo.nix Normal file
View File

@ -0,0 +1,21 @@
{ cargo
, configureCargoVendoredDepsHook
, lib
, stdenv
}:
args@{ nativeBuildInputs ? [ ], ... }:
stdenv.mkDerivation (args // {
nativeBuildInputs = nativeBuildInputs ++ [
cargo
configureCargoVendoredDepsHook
];
buildPhase = ''
cargo check --release
'';
installPhase = ''
touch $out
'';
})

View File

@ -1,4 +1,5 @@
{ lib { lib
, myPkgs
, newScope , newScope
}: }:
@ -6,9 +7,10 @@ lib.makeScope newScope (self:
let let
callPackage = self.newScope { }; callPackage = self.newScope { };
in in
{ myPkgs // {
inherit callPackage; inherit callPackage;
buildWithCargo = callPackage ./buildWithCargo.nix { };
downloadCargoPackage = callPackage ./downloadCargoPackage.nix { }; downloadCargoPackage = callPackage ./downloadCargoPackage.nix { };
urlForCargoPackage = callPackage ./urlForCargoPackage.nix { }; urlForCargoPackage = callPackage ./urlForCargoPackage.nix { };
vendorCargoDeps = callPackage ./vendorCargoDeps.nix { }; vendorCargoDeps = callPackage ./vendorCargoDeps.nix { };

View File

@ -14,5 +14,7 @@ EOF
} }
if [ -n "${cargoVendorDir-}" ]; then if [ -n "${cargoVendorDir-}" ]; then
postPatchHooks+=(configureCargoVendoredDepsHook) preConfigureHooks+=(configureCargoVendoredDepsHook)
else
echo "cargoVendorDir not set"
fi fi