mirror of
https://github.com/nix-community/naersk
synced 2024-11-10 06:04:17 +00:00
Fix support for .cargo/config
Before https://github.com/nix-community/naersk/pull/300, our `builtinz.toTOML` used to return a string representing the serialized document which was later redirected into a file: https://github.com/nix-community/naersk/pull/300/files#diff-b6b537316f2d29c8faf178a110366796811d1bc72f694262c7d2efad79aa984bL238 Over that merge request, this was changed to return a path, to make it consistent with how nixpkgs' formatters work - but I haven't noticed one place that still _read_ the file instead of returning a path (which was fine before, since the code did `echo ... > ...`, but is not a correct thing to do for `cp`). Closes https://github.com/nix-community/naersk/issues/305.
This commit is contained in:
parent
275010712c
commit
78789c30d6
7 changed files with 46 additions and 1 deletions
|
@ -31,7 +31,7 @@ let
|
|||
libb.findGitDependencies { inherit (config) cargolock gitAllRefs gitSubmodules; };
|
||||
cargoconfig =
|
||||
if builtinz.pathExists (toString config.root + "/.cargo/config")
|
||||
then builtins.readFile (config.root + "/.cargo/config")
|
||||
then (config.root + "/.cargo/config")
|
||||
else null;
|
||||
build = args: import ./build.nix (
|
||||
{
|
||||
|
|
20
test/fast/cargo-config/default.nix
Normal file
20
test/fast/cargo-config/default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ sources, pkgs, ... }:
|
||||
|
||||
let
|
||||
fenix = import sources.fenix { };
|
||||
|
||||
# Support for custom environmental variables was introduced in Cargo 1.56 and
|
||||
# our tests use nixpkgs-21.05 which contains an older version of Cargo, making
|
||||
# this test fail otherwise.
|
||||
toolchain = fenix.latest;
|
||||
|
||||
naersk = pkgs.callPackage ../../../default.nix {
|
||||
cargo = toolchain.cargo;
|
||||
rustc = toolchain.rustc;
|
||||
};
|
||||
|
||||
in
|
||||
naersk.buildPackage {
|
||||
src = ./fixtures;
|
||||
doCheck = true;
|
||||
}
|
2
test/fast/cargo-config/fixtures/.cargo/config
Normal file
2
test/fast/cargo-config/fixtures/.cargo/config
Normal file
|
@ -0,0 +1,2 @@
|
|||
[env]
|
||||
ENV_HELLO_WORLD="Hello, World!"
|
7
test/fast/cargo-config/fixtures/Cargo.lock
generated
Normal file
7
test/fast/cargo-config/fixtures/Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cargo-config"
|
||||
version = "0.1.0"
|
4
test/fast/cargo-config/fixtures/Cargo.toml
Normal file
4
test/fast/cargo-config/fixtures/Cargo.toml
Normal file
|
@ -0,0 +1,4 @@
|
|||
[package]
|
||||
name = "cargo-config"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
11
test/fast/cargo-config/fixtures/src/main.rs
Normal file
11
test/fast/cargo-config/fixtures/src/main.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
fn main() {
|
||||
println!("{}", env!("ENV_HELLO_WORLD"));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test() {
|
||||
assert_eq!("Hello, World!", env!("ENV_HELLO_WORLD"));
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
args: {
|
||||
cargo-config = import ./cargo-config args;
|
||||
cargo-wildcard = import ./cargo-wildcard args;
|
||||
default-run = import ./default-run args;
|
||||
dummyfication = import ./dummyfication args;
|
||||
|
|
Loading…
Reference in a new issue