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