remove <nix/config.nix> usages

This was removed in nixUnstable.
This commit is contained in:
Daiderd Jordan 2020-11-07 17:25:49 +01:00
parent 8c91336e65
commit 6449f71ef8
No known key found for this signature in database
GPG key ID: D02435D05B810C96
7 changed files with 49 additions and 58 deletions

View file

@ -390,6 +390,9 @@ mod tests {
const SYSTEM: &str = "x86_64-darwin"; const SYSTEM: &str = "x86_64-darwin";
fn nix() -> Nix { fn nix() -> Nix {
let path = env::var("PATH").unwrap();
let test_path = format!("{}/test-nix/bin:{}", env!("CARGO_MANIFEST_DIR"), path);
env::set_var("PATH", test_path);
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned()); let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
Nix::new(SYSTEM.to_owned(), remote, 1800, None) Nix::new(SYSTEM.to_owned(), remote, 1800, None)
} }
@ -612,12 +615,7 @@ mod tests {
#[test] #[test]
fn safe_command_custom_gc() { fn safe_command_custom_gc() {
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned()); let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
let nix = Nix::new( let nix = Nix::new(SYSTEM.to_owned(), remote, 1800, Some("4g".to_owned()));
SYSTEM.to_owned(),
remote,
1800,
Some("4g".to_owned()),
);
let ret: Result<fs::File, fs::File> = nix.run( let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command::<&OsStr>(&env_noop(), build_path().as_path(), &[], &[]), nix.safe_command::<&OsStr>(&env_noop(), build_path().as_path(), &[], &[]),
@ -824,10 +822,7 @@ mod tests {
assert_run( assert_run(
ret, ret,
Expect::Fail, Expect::Fail,
vec![ vec!["access to path", "is forbidden in restricted mode"],
"access to path",
"is forbidden in restricted mode",
],
); );
} }

4
ofborg/test-nix/bin/nix-build Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
export PATH=${PATH#*:}
exec nix-build "$@" -I "ofborg-test-bash=$(command -v bash)"

View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
export PATH=${PATH#*:}
exec nix-instantiate "$@" -I "ofborg-test-bash=$(command -v bash)"

View file

@ -1,27 +1,25 @@
let let
nix = import <nix/config.nix>; builder = builtins.storePath <ofborg-test-bash>;
in { in {
success = derivation { success = derivation {
name = "success"; name = "success";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; printf '1\n2\n3\n4\n'; echo ${toString builtins.currentTime} > $out" ];
"-c"
"echo hi; printf '1\n2\n3\n4\n'; echo ${toString builtins.currentTime} > $out" ];
}; };
failed = derivation { failed = derivation {
name = "failed"; name = "failed";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString builtins.currentTime}" ];
"-c"
"echo hi; echo ${toString builtins.currentTime}" ];
}; };
sandbox-violation = derivation { sandbox-violation = derivation {
name = "sandbox-violation"; name = "sandbox-violation";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = ./../../src; inherit builder;
args = ["-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
src = ./../../src;
}; };
} }

View file

@ -1,27 +1,27 @@
let let
nix = import <nix/config.nix>; builder = builtins.storePath <ofborg-test-bash>;
in { in
{
success = derivation { success = derivation {
name = "success"; name = "success";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
"-c"
"echo hi; echo ${toString builtins.currentTime} > $out" ];
}; };
failed = derivation { failed = derivation {
name = "failed"; name = "failed";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString builtins.currentTime}" ];
"-c"
"echo hi; echo ${toString builtins.currentTime}" ];
}; };
sandbox-violation = derivation { sandbox-violation = derivation {
name = "sandbox-violation"; name = "sandbox-violation";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = ./../../src; src = ./../../src;
inherit builder;
args = ["-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
}; };
} }

View file

@ -3,7 +3,7 @@ let
error: access to path '/fake' is forbidden in restricted mode error: access to path '/fake' is forbidden in restricted mode
'' false; path); '' false; path);
nix = import <nix/config.nix>; builder = builtins.storePath <ofborg-test-bash>;
in in
{ nixpkgs ? fetchGit /fake }: { nixpkgs ? fetchGit /fake }:
@ -12,37 +12,29 @@ rec {
success = derivation { success = derivation {
name = "success"; name = "success";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
"-c"
"echo hi; echo ${toString builtins.currentTime} > $out" ];
}; };
failed = derivation { failed = derivation {
name = "failed"; name = "failed";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
"-c"
"echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
}; };
passes-instantiation = derivation { passes-instantiation = derivation {
name = "passes-instantiation"; name = "passes-instantiation";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo this ones cool" ];
"-c"
"echo this ones cool" ];
}; };
nixpkgs-restricted-mode = derivation { nixpkgs-restricted-mode = derivation {
name = "nixpkgs-restricted-mode-fetchgit"; name = "nixpkgs-restricted-mode-fetchgit";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString nixpkgs} > $out" ];
"-c"
"echo hi; echo ${toString nixpkgs} > $out" ];
}; };
fails-instantiation = assert builtins.trace '' fails-instantiation = assert builtins.trace ''

View file

@ -1,21 +1,19 @@
let let
nix = import <nix/config.nix>; builder = builtins.storePath <ofborg-test-bash>;
in rec { in
rec {
success = derivation { success = derivation {
name = "success"; name = "success";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
"-c"
"echo hi; echo ${toString builtins.currentTime} > $out" ];
}; };
failed = derivation { failed = derivation {
name = "failed"; name = "failed";
system = builtins.currentSystem; system = builtins.currentSystem;
builder = builtins.storePath nix.shell; inherit builder;
args = [ args = ["-c" "echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
"-c"
"echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
}; };
} }