Merge pull request #220 from commiterate/support_attrset_string_key
Support attribute sets with string keys
This commit is contained in:
commit
803322102e
3 changed files with 33 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ let
|
|||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
./src
|
||||
./test/rust
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -32,10 +33,16 @@ let
|
|||
|
||||
nativeCheckInputs = [
|
||||
clippy
|
||||
nix
|
||||
];
|
||||
|
||||
preCheck = ''
|
||||
${lib.getExe pkgs.cargo} clippy
|
||||
|
||||
# Stop the Nix command from trying to create /nix/var/nix/profiles.
|
||||
#
|
||||
# https://nix.dev/manual/nix/2.24/command-ref/new-cli/nix3-profile#profiles
|
||||
export NIX_STATE_DIR=$TMPDIR
|
||||
'';
|
||||
}
|
||||
) { };
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ fn try_nix_eval(flake: &str, attr: &str, nix_options: &NixOptions) -> Result<boo
|
|||
.arg(format!("{flake}#{FLAKE_ATTR}"))
|
||||
.arg("--json")
|
||||
.arg("--apply")
|
||||
.arg(format!("a: a ? \"{attr}\""));
|
||||
.arg(format!("_: _ ? {attr}"));
|
||||
|
||||
log::debug!("Running nix command: {cmd:?}");
|
||||
|
||||
|
|
@ -197,3 +197,19 @@ fn nix_cmd(nix_options: &NixOptions) -> process::Command {
|
|||
});
|
||||
cmd
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_try_nix_eval() {
|
||||
let flake = "./test/rust/register";
|
||||
let nix_options = &NixOptions::new(vec![]);
|
||||
|
||||
assert!(try_nix_eval(flake, "identifier-key", nix_options).unwrap());
|
||||
assert!(try_nix_eval(flake, "\"string.literal/key\"", nix_options).unwrap());
|
||||
assert!(!try_nix_eval(flake, "_identifier-key", nix_options).unwrap());
|
||||
assert!(!try_nix_eval(flake, "\"_string.literal/key\"", nix_options).unwrap());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
test/rust/register/flake.nix
Normal file
9
test/rust/register/flake.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
inputs = { };
|
||||
outputs = inputs: {
|
||||
systemConfigs = {
|
||||
identifier-key = "value";
|
||||
"string.literal/key" = "value";
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue