From a7f8252d5005fac834ed66fbb17442646a854776 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Fri, 12 Apr 2019 14:45:54 +0200 Subject: [PATCH] Add --pure to nix-shell calls --- ci/Jenkinsfile.nix.linux | 2 +- ci/Jenkinsfile.nix.macos | 2 +- ci/docker/nix/Dockerfile | 2 +- ci/utils.groovy | 5 ++++- nix/shell.sh | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ci/Jenkinsfile.nix.linux b/ci/Jenkinsfile.nix.linux index 0de7344e1a..e361ee73be 100644 --- a/ci/Jenkinsfile.nix.linux +++ b/ci/Jenkinsfile.nix.linux @@ -39,7 +39,7 @@ pipeline { steps { sh """ nix build -v --no-link && - nix-shell --run echo + nix-shell --pure --run echo """ } } diff --git a/ci/Jenkinsfile.nix.macos b/ci/Jenkinsfile.nix.macos index 24e2e26e83..dab1680c82 100644 --- a/ci/Jenkinsfile.nix.macos +++ b/ci/Jenkinsfile.nix.macos @@ -40,7 +40,7 @@ pipeline { sh """ . ~/.nix-profile/etc/profile.d/nix.sh && \ nix build -v --no-link && \ - nix-shell --run echo + nix-shell --pure --run echo """ } } diff --git a/ci/docker/nix/Dockerfile b/ci/docker/nix/Dockerfile index 75a68f4918..dc21ba3af3 100644 --- a/ci/docker/nix/Dockerfile +++ b/ci/docker/nix/Dockerfile @@ -88,7 +88,7 @@ RUN export USER=jenkins \ && /tmp/nix-install.sh \ && . ~/.nix-profile/etc/profile.d/nix.sh \ && nix-build --no-out-link https://github.com/status-im/status-react/tarball/${GIT_COMMIT} \ - && nix-shell --run 'echo' https://github.com/status-im/status-react/tarball/${GIT_COMMIT} + && nix-shell --pure --run 'echo' https://github.com/status-im/status-react/tarball/${GIT_COMMIT} # hack to avoid calling login ENV USER=jenkins diff --git a/ci/utils.groovy b/ci/utils.groovy index ecc82d86ae..225f63d475 100644 --- a/ci/utils.groovy +++ b/ci/utils.groovy @@ -16,12 +16,15 @@ def getToolVersion(name) { } def nix_sh(cmd) { + def isPure = env.TARGET_PLATFORM == 'linux' + def pureFlag = isPure ? '--pure' : '' + sh """ set +x . ~/.nix-profile/etc/profile.d/nix.sh set -x nix-shell --argstr target-os \'${env.TARGET_PLATFORM}\' \\ - --run \'${cmd}\' \\ + ${pureFlag} --run \'${cmd}\' \\ \'${env.WORKSPACE}/shell.nix\' """ } diff --git a/nix/shell.sh b/nix/shell.sh index cd9833863a..e0cbb110f8 100755 --- a/nix/shell.sh +++ b/nix/shell.sh @@ -22,10 +22,12 @@ if ! command -v "nix" >/dev/null 2>&1; then fi if command -v "nix" >/dev/null 2>&1; then - echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS:=all}'...${NC}"; + echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS:=all}'...${NC}" if [[ $@ == "ENTER_NIX_SHELL" ]]; then exec nix-shell --show-trace --argstr target-os ${TARGET_OS} else - exec nix-shell --show-trace --argstr target-os ${TARGET_OS} --run "$@" + is_pure='' + [ "${TARGET_OS}" == 'linux' ] && is_pure='--pure' + exec nix-shell ${is_pure} --show-trace --argstr target-os ${TARGET_OS} --run "$@" fi fi