-
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.5.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. Resolves: #12832 Issue: NixOS/nix#5291 Signed-off-by: Jakub Sokołowski <[email protected]>
- Loading branch information
Showing
16 changed files
with
204 additions
and
136 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
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
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,29 @@ | ||
#!/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 | ||
} | ||
|
||
nix_install_type() { | ||
source /etc/os-release 2>/dev/null | ||
NIX_STORE_DIR_GROUP=$(file_group /nix/store) | ||
if [[ "${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,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script removes all Nix files. | ||
set -e | ||
|
||
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 | ||
fi | ||
fi | ||
|
||
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 | ||
|
||
NIX_INSTALL_TYPE=$(nix_install_type) | ||
# Purging /nix on NixOS would be disasterous | ||
if [[ "${NIX_INSTALL_TYPE}" == "nixops" ]]; 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 | ||
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 | ||
# Restore old shell profiles | ||
sudo rm -f /etc/profile.d/nix.sh* | ||
for NIX_FILE in /etc/bash.bashrc /etc/bashrc /etc/zshrc; do | ||
sudo mv -f ${NIX_FILE}.backup-before-nix ${NIX_FILE} | ||
done | ||
elif [[ "${NIX_INSTALL_TYPE}" == "single" ]]; then | ||
echo -e "${YLW}Detected single-user Nix installation.${RST}" >&2 | ||
fi | ||
sudo rm -rf ${NIX_ROOT} \ | ||
/etc/nix ~/.config/nixpkgs \ | ||
~/.nix-profile ~/.nix-defexpr \ | ||
~/.nix-channels ~/.cache/nix \ | ||
~/.status .nix-gcroots | ||
|
||
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 |
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
Oops, something went wrong.