-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: upgrade Nix from 2.3.12 to 2.6.1
Due to changes in how Nix handles Git refs we need to specify `refs/tags/` prefix in `package.json` to avoid the following error: ``` fatal: couldn't find remote ref refs/heads/v2.0.3-status-v6 error: program 'git' failed with exit code 128 ``` I also had to rewrite some logic in `nix/scripts/source.sh` in order to take account of single-user and multi-user installations. We default to multi-user for Darwin, but not for any other OS due to discovered issues with `nix-daemon` socket on Arch and open file limits. I also rewrote `nix/scripts/setup.sh` and `/nix/scripts/purge.sh` to support different types of installations. Both single-user and multi-user, as some operating systems have issues with multi-user installations. Resolves: #12832 Depends on: status-im/status-jenkins-lib#37 Related changes: * status-im/infra-ci@84947b9f * status-im/infra-ci@bb98f5f3 * status-im/infra-ci@f75d524d * status-im/infra-ci@d1fc92cd * status-im/infra-ci@87c4091e * status-im/infra-ci@8d6b6b3f * status-im/infra-ci@c4f13285 * status-im/infra-ci@38ac698d Signed-off-by: Jakub Sokołowski <[email protected]>
- Loading branch information
Showing
16 changed files
with
264 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
library 'status-jenkins-lib@v1.3.5' | ||
library 'status-jenkins-lib@v1.4.0' | ||
|
||
pipeline { | ||
agent { label 'linux' } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
library 'status-jenkins-lib@v1.3.3' | ||
library 'status-jenkins-lib@v1.4.0' | ||
|
||
pipeline { | ||
agent { label 'macos' } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
library 'status-jenkins-lib@v1.3.3' | ||
library 'status-jenkins-lib@v1.4.0' | ||
|
||
pipeline { | ||
agent { label 'linux' } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Checking group ownership to identify installation type. | ||
file_group() { | ||
UNAME=$(uname -s) | ||
if [[ "${UNAME}" == "Linux" ]]; then | ||
stat -Lc "%G" "${1}" 2>/dev/null | ||
elif [[ "${UNAME}" == "Darwin" ]]; then | ||
stat -Lf "%Sg" "${1}" 2>/dev/null | ||
fi | ||
} | ||
|
||
os_name() { | ||
source /etc/os-release 2>/dev/null | ||
echo "${NAME}" | ||
} | ||
|
||
is_arch_linux() { | ||
[[ -f /etc/arch-release ]] | ||
} | ||
|
||
nix_install_type() { | ||
NIX_STORE_DIR_GROUP=$(file_group /nix/store) | ||
if [[ "$(os_name)" =~ NixOS ]]; then | ||
echo "nixos" | ||
elif [[ "${NIX_STORE_DIR_GROUP}" == "nixbld" ]]; then | ||
echo "multi" | ||
elif [[ "${NIX_STORE_DIR_GROUP}" == "${USER}" ]]; then | ||
echo "single" | ||
elif [[ "${NIX_STORE_DIR_GROUP}" == "" ]]; then | ||
echo "No Nix installtion detected!" >&2 | ||
echo "none" | ||
else | ||
echo "Unknown Nix installtion type!" >&2 | ||
exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,82 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
# This script removes all Nix files. | ||
|
||
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) | ||
source "${GIT_ROOT}/nix/scripts/lib.sh" | ||
source "${GIT_ROOT}/scripts/colors.sh" | ||
|
||
# Purging /nix on NixOS would be disasterous | ||
if [[ -f "/etc/os-release" ]]; then | ||
OS_NAME=$(awk -F= '/^NAME/{print $2}' /etc/os-release) | ||
if [[ "$OS_NAME" == "NixOS" ]]; then | ||
echo -e "${RED}You should not purge Nix files on NixOS!${RST}" >&2 | ||
exit | ||
nix_purge_multi_user() { | ||
sudo systemctl stop nix-daemon.socket | ||
sudo systemctl stop nix-daemon.service | ||
sudo systemctl disable nix-daemon.socket | ||
sudo systemctl disable nix-daemon.service | ||
sudo systemctl daemon-reload | ||
sudo rm -fr /etc/nix | ||
sudo rm -f /etc/profile.d/nix.sh* | ||
|
||
# Remove nix build users and groups | ||
for NIX_USER in $(awk -F: '/nixbld/{print $1}' /etc/passwd); do | ||
sudo userdel "${NIX_USER}" | ||
done | ||
sudo groupdel nixbld | ||
|
||
# Restore old shell profiles | ||
NIX_PROFILE_FILES=( | ||
/etc/bash.bashrc /etc/bashrc /etc/bash/bashrc | ||
/etc/zsh.zshhrc /etc/zshrc /etc/zsh/zshrc | ||
) | ||
for NIX_FILE in "${NIX_PROFILE_FILES[@]}"; do | ||
if [[ -f "${NIX_FILE}.backup-before-nix" ]]; then | ||
sudo mv -f "${NIX_FILE}.backup-before-nix" "${NIX_FILE}" | ||
fi | ||
done | ||
} | ||
|
||
nix_purge_user_profile() { | ||
sudo rm -rf \ | ||
~/.nix-* \ | ||
~/.cache/nix \ | ||
~/.config/nixpkgs \ | ||
${GIT_ROOT}/.nix-gcroots | ||
} | ||
|
||
nix_purge_root() { | ||
NIX_ROOT="/nix" | ||
if [[ $(uname -s) == "Darwin" ]]; then | ||
# Special case due to read-only root on MacOS Catalina | ||
NIX_ROOT="/opt/nix" | ||
fi | ||
if [[ -z "${NIX_ROOT}" ]]; then | ||
echo -e "${RED}Unable to identify Nix root!${RST}" >&2 | ||
exit 1 | ||
fi | ||
sudo rm -fr "${NIX_ROOT}" | ||
} | ||
|
||
NIX_INSTALL_TYPE=$(nix_install_type) | ||
|
||
if [[ "${1}" == "--force" ]] && [[ "${NIX_INSTALL_TYPE}" != "nixos" ]]; then | ||
echo -e "${YLW}Purge forced, no checks performed!${RST}" >&2 | ||
nix_purge_multi_user | ||
nix_purge_user_profile | ||
nix_purge_root | ||
exit | ||
fi | ||
|
||
NIX_ROOT="/nix" | ||
if [[ $(uname -s) == "Darwin" ]]; then | ||
# Special case due to read-only root on MacOS Catalina | ||
NIX_ROOT="/opt/nix" | ||
# Purging /nix on NixOS would be disasterous | ||
if [[ "${NIX_INSTALL_TYPE}" == "nixos" ]]; then | ||
echo -e "${RED}You should not purge Nix files on NixOS!${RST}" >&2 | ||
exit | ||
elif [[ "${NIX_INSTALL_TYPE}" == "none" ]]; then | ||
echo -e "${YLW}Nothing to remove, Nix not installed.${RST}" >&2 | ||
exit | ||
elif [[ "${NIX_INSTALL_TYPE}" == "multi" ]]; then | ||
echo -e "${YLW}Detected multi-user Nix installation.${RST}" >&2 | ||
nix_purge_multi_user | ||
elif [[ "${NIX_INSTALL_TYPE}" == "single" ]]; then | ||
echo -e "${YLW}Detected single-user Nix installation.${RST}" >&2 | ||
nix_purge_user_profile | ||
fi | ||
nix_purge_root | ||
|
||
sudo rm -rf ${NIX_ROOT}/* ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots | ||
echo -e "${GRN}Purged all Nix files from your system.${RST}" >&2 |
Oops, something went wrong.