diff options
Diffstat (limited to 'lib/nix-thin-edge-builder/writeCargoToml.nix')
-rw-r--r-- | lib/nix-thin-edge-builder/writeCargoToml.nix | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/lib/nix-thin-edge-builder/writeCargoToml.nix b/lib/nix-thin-edge-builder/writeCargoToml.nix index 34a276af..91dc2288 100644 --- a/lib/nix-thin-edge-builder/writeCargoToml.nix +++ b/lib/nix-thin-edge-builder/writeCargoToml.nix @@ -1,43 +1,60 @@ -{ craneLib, components }: +{ craneLib, components, pkgs }: let edition = "2021"; + applyOverrides = replacements: pkg: pkgs.runCommand "apply-${pkg.name}" { } '' + cp -R ${pkg.src}/* . + rm Cargo.toml + cat ${pkg.src}/Cargo.toml ${pkgs.lib.concatMapStrings (r: '' | sed 's|${r.localPath}|"${r.src}"|' '') replacements} > Cargo.toml + cp -R ./ $out + ''; + apiOnlyPatchCrates = [ + { localPath = "\".*/tedge_api\""; src = ../../crates/core/tedge_api; } + ]; + allPatchCrates = apiOnlyPatchCrates ++ [ + { localPath = "\".*/tedge_lib\""; src = localCrates.tedge_lib.path; } + { localPath = "\".*/tedge_core\""; src = localCrates.tedge_core.path; } + ]; + localCrates = { + tedge_api = { path = ../../crates/core/tedge_api; }; + tedge_core = { path = applyOverrides apiOnlyPatchCrates { name = "tedge_core"; src = ../../crates/core/tedge_core; }; }; + tedge_lib = { path = applyOverrides apiOnlyPatchCrates { name = "tedge_lib"; src = ../../crates/core/tedge_lib; }; }; + tedge-cli = { + default-features = false; + path = applyOverrides allPatchCrates { name = "tedge-cli"; src = ../../tedge; }; + }; + }; defaultDependencies = { - clap = { version = "3"; features = ["derive" "cargo" "suggestions"]; }; + clap = { version = "3"; features = [ "derive" "cargo" "suggestions" ]; }; toml = "0.5.8"; - tokio = { version = "1"; features = ["fs" "macros" "rt-multi-thread" "signal"]; }; - miette = { version = "4.7"; features = ["fancy"]; }; + tokio = { version = "1"; features = [ "fs" "macros" "rt-multi-thread" "signal" ]; }; + miette = { version = "4.7"; features = [ "fancy" ]; }; cfg-if = "1"; tracing = "0.1"; - tracing-subscriber = { version = "0.3.11"; features = ["env-filter"]; }; + tracing-subscriber = { version = "0.3.11"; features = [ "env-filter" ]; }; tracing-chrome = "0.6"; tracing-tracy = "0.9"; cfg_table = "1.0.0"; nu-ansi-term = "0.45.1"; - pretty = { version = "0.11.3"; features = ["termcolor"]; }; + pretty = { version = "0.11.3"; features = [ "termcolor" ]; }; termcolor = "1.1.3"; termimad = "0.20.1"; term_size = "0.3.2"; owo-colors = "3.4.0"; textwrap = "0.15.0"; - - tedge_api = { path = "../crates/core/tedge_api"; }; - tedge_core = { path = "../crates/core/tedge_core"; }; - tedge_lib = { path = "../crates/core/tedge_lib"; }; - - env_logger = { version = "0.9"; optional = true; }; - }; + } // localCrates; componentDependencies = let mkDep = component: { name = component.name; value = { - path = component.src; + path = applyOverrides allPatchCrates component; }; }; - in builtins.listToAttrs (builtins.map mkDep components); + in + builtins.listToAttrs (builtins.map mkDep components); in craneLib.writeTOML "Cargo.toml" { |