Skip to content

Commit e36fbb5

Browse files
committed
saner
1 parent 1600190 commit e36fbb5

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

Github/Runners/ubuntu-builder.dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ RUN <<EOS
162162
dos2unix --quiet "./install.sh" && chmod +x "./install.sh"
163163
echo "yes" | bash "./install.sh" 2>/dev/null || true
164164
rm -rf "$(realpath .)" ; cd "${CWD}"
165+
#----------------------#
166+
#Nix
167+
hash -r &>/dev/null
168+
if ! command -v nix >/dev/null 2>&1; then
169+
cd "$(mktemp -d)" >/dev/null 2>&1
170+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_nix.sh" -o "./install_nix.sh"
171+
dos2unix --quiet "./install_nix.sh" ; chmod +x "./install_nix.sh"
172+
bash "./install_nix.sh" 2>/dev/null || true ; rm -rf "./install_nix.sh"
173+
fi
174+
#----------------------#
165175
#patchelf
166176
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/patchelf" -o "/usr/bin/patchelf" && chmod +x "/usr/bin/patchelf"
167177
#----------------------#

Linux/install_nix.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
3+
#-------------------------------------------------------#
4+
## <DO NOT RUN STANDALONE, meant for CI Only>
5+
## Meant to Install & Setup Nix
6+
###-----------------------------------------------------###
7+
8+
#-------------------------------------------------------#
9+
##ENV
10+
if [[ -z "${USER+x}" ]] || [[ -z "${USER##*[[:space:]]}" ]]; then
11+
USER="$(whoami | tr -d '[:space:]')"
12+
fi
13+
if [[ -z "${HOME+x}" ]] || [[ -z "${HOME##*[[:space:]]}" ]]; then
14+
HOME="$(getent passwd "${USER}" | awk -F':' 'NF >= 6 {print $6}' | tr -d '[:space:]')"
15+
fi
16+
TEMP_DIR="$(mktemp -d)"
17+
trap 'rm -rf "$TEMP_DIR"' EXIT
18+
#-------------------------------------------------------#
19+
20+
#-------------------------------------------------------#
21+
##Install
22+
cd "${TEMP_DIR}"
23+
sudo rm -rf "/etc/bash.bashrc.backup-before-nix" "/etc/nix" "/nix" "/etc/nix/nix.conf" "${HOME}/.config/nix/nix.conf" "${HOME}/.nix-profile" "${HOME}/.nix-defexpr" "${HOME}/.nix-channels" "${HOME}/.local/state/nix" "${HOME}/.cache/nix" 2>/dev/null
24+
if [[ "$(uname -m | tr -d '[:space:]')" == "riscv64" ]]; then
25+
#Install Officially
26+
curl -qfsSL "https://nixos.org/nix/install" | bash -s -- --no-daemon
27+
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
28+
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
29+
#Enable Experimental Features
30+
sudo mkdir -p "/etc/nix"
31+
echo "experimental-features = nix-command flakes" | sudo tee -a "/etc/nix/nix.conf"
32+
mkdir -p "${HOME}/.config"
33+
ln -fsv "/etc/nix/nix.conf" "${HOME}/.config/nix/nix.conf"
34+
else
35+
##https://github.com/DeterminateSystems/nix-installer
36+
"/nix/nix-installer" uninstall --no-confirm 2>/dev/null
37+
#curl -qfsSL "https://install.determinate.systems/nix" | bash -s -- install linux --init none --no-confirm
38+
curl -qfsSL "https://install.determinate.systems/nix" | bash -s -- install linux --init none --extra-conf "filter-syscalls = false" --no-confirm
39+
source "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
40+
#Fix perms: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Operation not permitted
41+
#sudo chown --recursive "${USER}" "/nix"
42+
sudo chown --recursive "${USER}" "/nix"
43+
echo "root ALL=(ALL:ALL) ALL" | sudo tee -a "/etc/sudoers"
44+
fi
45+
##Test
46+
hash -r &>/dev/null
47+
if ! command -v nix &> /dev/null; then
48+
echo -e "\n[-] nix NOT Found\n"
49+
exit 1
50+
else
51+
#Add Env vars
52+
export NIXPKGS_ALLOW_BROKEN="1"
53+
export NIXPKGS_ALLOW_UNFREE="1"
54+
export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM="1"
55+
#Update Channels
56+
nix --version && nix-channel --list && nix-channel --update
57+
#Seed Local Data
58+
nix derivation show "nixpkgs#hello" --impure --refresh --quiet
59+
#Build Bash (triggers bootstrap)
60+
nix-build '<nixpkgs>' --impure --attr "pkgsStatic.bash" --cores "$(($(nproc)+1))" --max-jobs "$(($(nproc)+1))" --log-format bar-with-logs
61+
#Exit
62+
sudo ldconfig 2>/dev/null || true
63+
fi
64+
#-------------------------------------------------------#

0 commit comments

Comments
 (0)