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";
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());
Nix::new(SYSTEM.to_owned(), remote, 1800, None)
}
@ -612,12 +615,7 @@ mod tests {
#[test]
fn safe_command_custom_gc() {
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
let nix = Nix::new(
SYSTEM.to_owned(),
remote,
1800,
Some("4g".to_owned()),
);
let nix = Nix::new(SYSTEM.to_owned(), remote, 1800, Some("4g".to_owned()));
let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command::<&OsStr>(&env_noop(), build_path().as_path(), &[], &[]),
@ -824,10 +822,7 @@ mod tests {
assert_run(
ret,
Expect::Fail,
vec![
"access to path",
"is forbidden in restricted mode",
],
vec!["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
nix = import <nix/config.nix>;
builder = builtins.storePath <ofborg-test-bash>;
in {
success = derivation {
name = "success";
system = builtins.currentSystem;
builder = builtins.storePath nix.shell;
args = [
"-c"
"echo hi; printf '1\n2\n3\n4\n'; echo ${toString builtins.currentTime} > $out" ];
inherit builder;
args = ["-c" "echo hi; printf '1\n2\n3\n4\n'; echo ${toString builtins.currentTime} > $out" ];
};
failed = derivation {
name = "failed";
system = builtins.currentSystem;
builder = builtins.storePath nix.shell;
args = [
"-c"
"echo hi; echo ${toString builtins.currentTime}" ];
inherit builder;
args = ["-c" "echo hi; echo ${toString builtins.currentTime}" ];
};
sandbox-violation = derivation {
name = "sandbox-violation";
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
nix = import <nix/config.nix>;
in {
builder = builtins.storePath <ofborg-test-bash>;
in
{
success = derivation {
name = "success";
system = builtins.currentSystem;
builder = builtins.storePath nix.shell;
args = [
"-c"
"echo hi; echo ${toString builtins.currentTime} > $out" ];
inherit builder;
args = ["-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
};
failed = derivation {
name = "failed";
system = builtins.currentSystem;
builder = builtins.storePath nix.shell;
args = [
"-c"
"echo hi; echo ${toString builtins.currentTime}" ];
inherit builder;
args = ["-c" "echo hi; echo ${toString builtins.currentTime}" ];
};
sandbox-violation = derivation {
name = "sandbox-violation";
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
'' false; path);
nix = import <nix/config.nix>;
builder = builtins.storePath <ofborg-test-bash>;
in
{ nixpkgs ? fetchGit /fake }:
@ -12,37 +12,29 @@ rec {
success = derivation {
name = "success";
system = builtins.currentSystem;
builder = builtins.storePath nix.shell;
args = [
"-c"
"echo hi; echo ${toString builtins.currentTime} > $out" ];
inherit builder;
args = ["-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
};
failed = derivation {
name = "failed";
system = builtins.currentSystem;
builder = builtins.storePath nix.shell;
args = [
"-c"
"echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
inherit builder;
args = ["-c" "echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
};
passes-instantiation = derivation {
name = "passes-instantiation";
system = builtins.currentSystem;
builder = builtins.storePath nix.shell;
args = [
"-c"
"echo this ones cool" ];
inherit builder;
args = ["-c" "echo this ones cool" ];
};
nixpkgs-restricted-mode = derivation {
name = "nixpkgs-restricted-mode-fetchgit";
system = builtins.currentSystem;
builder = nix.shell;
args = [
"-c"
"echo hi; echo ${toString nixpkgs} > $out" ];
inherit builder;
args = ["-c" "echo hi; echo ${toString nixpkgs} > $out" ];
};
fails-instantiation = assert builtins.trace ''

View file

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