mirror of
https://codeberg.org/icewind/mill-scale.git
synced 2026-06-03 18:04:09 +02:00
allow overwriting cargo toml/lock location
This commit is contained in:
parent
a50219c7ee
commit
8a5baa8225
2 changed files with 30 additions and 9 deletions
|
|
@ -2,16 +2,17 @@
|
|||
lib,
|
||||
src,
|
||||
config,
|
||||
cargoLock,
|
||||
}: let
|
||||
inherit (builtins) readFile pathExists attrNames hasAttr;
|
||||
inherit (lib) map intersectLists foldl splitString getAttrFromPath;
|
||||
|
||||
cargoLockDeps =
|
||||
if pathExists (src + /Cargo.lock)
|
||||
if pathExists cargoLock
|
||||
then let
|
||||
cargoLock = fromTOML (readFile (src + /Cargo.lock));
|
||||
cargoLockToml = fromTOML (readFile cargoLock);
|
||||
in
|
||||
map (package: package.name) cargoLock.package
|
||||
map (package: package.name) cargoLockToml.package
|
||||
else [];
|
||||
availableAutoDeps = import ./deps.nix;
|
||||
detectedDeps = intersectLists cargoLockDeps (attrNames availableAutoDeps);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) elem readFile pathExists match any concatLists;
|
||||
inherit (lib) getExe map mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types optionalString genAttrs hasInfix makeBinPath makeSearchPathOutput;
|
||||
inherit (lib) getExe map mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types optionalString genAttrs hasInfix makeSearchPathOutput;
|
||||
inherit (lib.fileset) fileFilter toSource unions;
|
||||
inherit (flakelight.types) fileset function optFunctionTo;
|
||||
makePkgConfigPath = makeSearchPathOutput "dev" "lib/pkgconfig";
|
||||
|
|
@ -20,15 +20,22 @@
|
|||
fileset = unions (config.extraPaths ++ [config.fileset]);
|
||||
};
|
||||
|
||||
cargoToml = fromTOML (readFile (src + /Cargo.toml));
|
||||
cargoMeta = (import ./cargo-meta.nix {inherit lib;}) cargoToml;
|
||||
cargoToml = fromTOML (readFile config.cargoToml);
|
||||
cargoMeta =
|
||||
(import ./cargo-meta.nix {
|
||||
inherit lib;
|
||||
})
|
||||
cargoToml;
|
||||
inherit (cargoMeta) tomlPackage hasMsrv hasWorkspace hasNonDefaultFeatures hasDefaultFeatures msrv;
|
||||
|
||||
maybeWorkspace = optionalString hasWorkspace "--workspace";
|
||||
hasExamples = pathExists (src + /examples);
|
||||
hasDefaultPackage = pathExists (src + /nix/package.nix);
|
||||
|
||||
autoDeps = import ./autodeps {inherit lib src config;};
|
||||
autoDeps = import ./autodeps {
|
||||
inherit (config) cargoLock;
|
||||
inherit lib src config;
|
||||
};
|
||||
buildDeps = pkgs: rec {
|
||||
buildInputs = (autoDeps pkgs).buildInputs ++ (config.buildInputs pkgs);
|
||||
nativeBuildInputs = (autoDeps pkgs).nativeBuildInputs ++ (config.nativeBuildInputs pkgs);
|
||||
|
|
@ -56,6 +63,14 @@ in
|
|||
warnIf (! builtins ? readFileType) "Unsupported Nix version in use."
|
||||
{
|
||||
options = {
|
||||
cargoToml = mkOption {
|
||||
type = with types; path;
|
||||
default = src + /Cargo.toml;
|
||||
};
|
||||
cargoLock = mkOption {
|
||||
type = with types; path;
|
||||
default = src + /Cargo.lock;
|
||||
};
|
||||
extraFiles = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [];
|
||||
|
|
@ -144,7 +159,7 @@ in
|
|||
};
|
||||
|
||||
config = mkMerge [
|
||||
(mkIf (pathExists (src + /Cargo.toml)) {
|
||||
(mkIf (pathExists config.cargoToml) {
|
||||
withOverlays = [
|
||||
(import inputs.rust-overlay)
|
||||
(final: {
|
||||
|
|
@ -156,6 +171,7 @@ in
|
|||
} @ prev: rec {
|
||||
commonCraneArgs =
|
||||
{
|
||||
inherit (config) cargoToml cargoLock;
|
||||
src = filteredSrc;
|
||||
strictDeps = true;
|
||||
doCheck = false;
|
||||
|
|
@ -181,7 +197,11 @@ in
|
|||
pname = "${crateName}-msrv";
|
||||
};
|
||||
|
||||
crateName = (craneLib.crateNameFromCargoToml {inherit src;}).pname;
|
||||
crateName =
|
||||
(craneLib.crateNameFromCargoToml {
|
||||
inherit (config) cargoToml;
|
||||
inherit src;
|
||||
}).pname;
|
||||
craneLib = (inputs.crane.mkLib final).overrideToolchain (p: p.rustToolchain);
|
||||
craneLibForTargets = targets: (inputs.crane.mkLib final).overrideToolchain (p: p.rustToolchain.override {inherit targets;});
|
||||
craneLibMsrv = (inputs.crane.mkLib final).overrideToolchain (p: p.msrvRustToolchain);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue