mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 14:35:30 +03:00
fix(rust): update crane, fix build issues (#284)
This commit is contained in:
parent
877b83654f
commit
c6c039fcc6
@ -25,11 +25,11 @@
|
||||
"crane": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1654444508,
|
||||
"narHash": "sha256-4OBvQ4V7jyt7afs6iKUvRzJ1u/9eYnKzVQbeQdiamuY=",
|
||||
"lastModified": 1661875961,
|
||||
"narHash": "sha256-f1h/2c6Teeu1ofAHWzrS8TwBPcnN+EEu+z1sRVmMQTk=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "db5482bf225acc3160899124a1df5a617cfa27b5",
|
||||
"rev": "d9f394e4e20e97c2a60c3ad82c2b6ef99be19e24",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -100,12 +100,12 @@
|
||||
"lib/mkCargoDerivation.nix"
|
||||
"lib/mkDummySrc.nix"
|
||||
"lib/writeTOML.nix"
|
||||
"pkgs/cargoHelperFunctions.sh"
|
||||
"pkgs/configureCargoCommonVarsHook.sh"
|
||||
"pkgs/configureCargoVendoredDepsHook.sh"
|
||||
"pkgs/installFromCargoBuildLogHook.sh"
|
||||
"pkgs/inheritCargoArtifactsHook.sh"
|
||||
"pkgs/installCargoArtifactsHook.sh"
|
||||
"pkgs/remapSourcePathPrefixHook.sh"
|
||||
"LICENSE"
|
||||
];
|
||||
};
|
||||
|
@ -136,9 +136,9 @@ in let
|
||||
}: rec {
|
||||
otherHooks =
|
||||
genHooks [
|
||||
"cargoHelperFunctions"
|
||||
"configureCargoCommonVarsHook"
|
||||
"configureCargoVendoredDepsHook"
|
||||
"remapSourcePathPrefixHook"
|
||||
]
|
||||
{};
|
||||
installHooks =
|
||||
@ -174,12 +174,21 @@ in let
|
||||
inherit writeTOML cleanCargoToml findCargoFiles;
|
||||
};
|
||||
|
||||
mkCargoDerivation = importLibFile "mkCargoDerivation" ({
|
||||
mkCargoDerivation = importLibFile "mkCargoDerivation" {
|
||||
cargo = cargoHostTarget;
|
||||
inherit (pkgs) stdenv lib;
|
||||
}
|
||||
// installHooks
|
||||
// otherHooks);
|
||||
inherit
|
||||
(installHooks)
|
||||
inheritCargoArtifactsHook
|
||||
installCargoArtifactsHook
|
||||
;
|
||||
inherit
|
||||
(otherHooks)
|
||||
configureCargoCommonVarsHook
|
||||
configureCargoVendoredDepsHook
|
||||
;
|
||||
cargoHelperFunctionsHook = otherHooks.cargoHelperFunctions;
|
||||
};
|
||||
buildDepsOnly = importLibFile "buildDepsOnly" {
|
||||
inherit
|
||||
mkCargoDerivation
|
||||
@ -197,7 +206,7 @@ in let
|
||||
;
|
||||
};
|
||||
buildPackage = importLibFile "buildPackage" {
|
||||
inherit (pkgs) lib;
|
||||
inherit (pkgs) removeReferencesTo lib;
|
||||
inherit (installLogHook) installFromCargoBuildLogHook;
|
||||
inherit cargoBuild;
|
||||
};
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
buildPackage = pname: version: let
|
||||
src = utils.getRootSource pname version;
|
||||
vendorDir = vendoring.vendoredDependencies;
|
||||
replacePaths =
|
||||
utils.replaceRelativePathsWithAbsolute
|
||||
subsystemAttrs.relPathReplacements.${pname}.${version};
|
||||
@ -48,7 +47,7 @@
|
||||
cargoVendorDir = "../nix-vendor";
|
||||
|
||||
postUnpack = ''
|
||||
ln -s ${vendorDir} ./nix-vendor
|
||||
${vendoring.copyVendorDir "./nix-vendor"}
|
||||
export CARGO_HOME=$(pwd)/.cargo_home
|
||||
'';
|
||||
|
||||
|
@ -52,15 +52,25 @@
|
||||
# common args we use for both buildDepsOnly and buildPackage
|
||||
common = {
|
||||
inherit pname version;
|
||||
|
||||
src = utils.getRootSource pname version;
|
||||
cargoVendorDir = vendoring.vendoredDependencies;
|
||||
cargoVendorDir = "./nix-vendor";
|
||||
|
||||
# this is needed because remove-references-to doesn't work on non nix-store paths
|
||||
doNotRemoveReferencesToVendorDir = true;
|
||||
|
||||
postUnpack = ''
|
||||
${vendoring.copyVendorDir "./nix-vendor"}
|
||||
export CARGO_HOME=$(pwd)/.cargo_home
|
||||
'';
|
||||
preConfigure = ''
|
||||
${writeGitVendorEntries}
|
||||
${replacePaths}
|
||||
'';
|
||||
|
||||
# Make sure cargo only builds & tests the package we want
|
||||
cargoBuildCommand = "cargo build --release --package ${pname}";
|
||||
cargoTestCommand = "cargo test --release --package ${pname}";
|
||||
};
|
||||
|
||||
# The deps-only derivation will use this as a prefix to the `pname`
|
||||
@ -72,6 +82,8 @@
|
||||
# so that crane's mkDummySrc adds it to the dummy source
|
||||
inherit (utils) cargoLock;
|
||||
pnameSuffix = depsNameSuffix;
|
||||
# Make sure cargo only checks the package we want
|
||||
cargoCheckCommand = "cargo check --release --package ${pname}";
|
||||
};
|
||||
deps =
|
||||
produceDerivation
|
||||
@ -82,9 +94,6 @@
|
||||
common
|
||||
// {
|
||||
cargoArtifacts = deps;
|
||||
# Make sure cargo only builds & tests the package we want
|
||||
cargoBuildCommand = "cargo build --release --package ${pname}";
|
||||
cargoTestCommand = "cargo test --release --package ${pname}";
|
||||
# write our cargo lock
|
||||
# note: we don't do this in buildDepsOnly since
|
||||
# that uses a cargoLock argument instead
|
||||
|
@ -97,4 +97,6 @@ in rec {
|
||||
|
||||
# All dependencies in the Cargo.lock file, vendored
|
||||
vendoredDependencies = vendorDependencies allDependencies;
|
||||
|
||||
copyVendorDir = path: ''cp -r --no-preserve=mode,ownership ${vendoredDependencies} ${path}'';
|
||||
}
|
||||
|
@ -21,14 +21,13 @@ in {
|
||||
translate = {translatorName, ...}: {
|
||||
project,
|
||||
tree,
|
||||
packageName,
|
||||
...
|
||||
} @ args: let
|
||||
}: let
|
||||
# get the root source and project source
|
||||
rootTree = tree;
|
||||
projectTree = rootTree.getNodeFromPath project.relPath;
|
||||
rootSource = rootTree.fullPath;
|
||||
projectSource = dlib.sanitizePath "${rootSource}/${project.relPath}";
|
||||
projectTree = rootTree.getNodeFromPath project.relPath;
|
||||
subsystemInfo = project.subsystemInfo;
|
||||
|
||||
# Get the root toml
|
||||
@ -84,12 +83,6 @@ in {
|
||||
# Get a "main" package toml
|
||||
packageToml = l.elemAt cargoPackages 0;
|
||||
|
||||
# Figure out a package name
|
||||
packageName =
|
||||
if args.packageName == "{automatic}"
|
||||
then packageToml.value.package.name
|
||||
else args.packageName;
|
||||
|
||||
# Parse Cargo.lock and extract dependencies
|
||||
parsedLock = projectTree.files."Cargo.lock".tomlContent;
|
||||
parsedDeps = parsedLock.package;
|
||||
@ -186,7 +179,7 @@ in {
|
||||
};
|
||||
in
|
||||
dlib.simpleTranslate2.translate
|
||||
({...}: rec {
|
||||
({...}: {
|
||||
inherit translatorName;
|
||||
|
||||
# relative path of the project within the source tree.
|
||||
@ -198,7 +191,7 @@ in {
|
||||
# Extract subsystem specific attributes.
|
||||
# The structure of this should be defined in:
|
||||
# ./src/specifications/{subsystem}
|
||||
subsystemAttrs = rec {
|
||||
subsystemAttrs = {
|
||||
relPathReplacements = let
|
||||
# function to find path replacements for one package
|
||||
findReplacements = package: let
|
||||
@ -237,8 +230,7 @@ in {
|
||||
filtered =
|
||||
l.filterAttrs
|
||||
(
|
||||
n: v:
|
||||
(l.removeSuffix "/" (l.removePrefix "./" n)) != v
|
||||
n: v: ! l.pathExists (dlib.sanitizePath "${projectSource}/${v}")
|
||||
)
|
||||
replacements;
|
||||
in
|
||||
@ -314,7 +306,7 @@ in {
|
||||
workspaceCrates =
|
||||
l.map
|
||||
(
|
||||
pkg: rec {
|
||||
pkg: {
|
||||
inherit (pkg.value.package) name version;
|
||||
inherit (pkg) relPath;
|
||||
}
|
||||
@ -382,12 +374,5 @@ in {
|
||||
# - string argument (type = "argument")
|
||||
# - boolean flag (type = "flag")
|
||||
# String arguments contain a default value and examples. Flags do not.
|
||||
extraArgs = {
|
||||
packageName = {
|
||||
description = "name of the package you want to build";
|
||||
default = "{automatic}";
|
||||
examples = ["rand"];
|
||||
type = "argument";
|
||||
};
|
||||
};
|
||||
extraArgs = {};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user