Skip to content

Commit 5146299

Browse files
committed
Merge branch 'master' into pnpm
2 parents 9b0d88e + e1c608d commit 5146299

File tree

6 files changed

+112
-75
lines changed

6 files changed

+112
-75
lines changed

settings/extensions/nix/commands/ensure_nix_installed

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,30 @@ color_reset="\e[0m";color_reset=""
1717

1818
# saftey/cleanup
1919
# if trap exists
20-
if [ -n "$(command -v "trap")" ]
21-
then
20+
if [ -n "$(command -v "trap")" ]; then
2221
trap 'unset repo; unset branch; unset setup_or_copy; unset mixin_remote_name; return 0' INT TERM
2322
fi
2423

2524
#
26-
# if nix doesnt exist
25+
# if nix command doesnt exist
2726
#
28-
if [ -z "$(command -v "nix")" ]
29-
then
27+
if [ -z "$(command -v "nix")" ]; then
3028
#
3129
# try sourcing some files, then check avail if nix is available
3230
#
33-
if [ -f "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]
34-
then
31+
if [ -f "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]; then
3532
. "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
3633
fi
37-
if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]
38-
then
34+
if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
3935
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
4036
fi
4137
export PATH="$PATH:/nix/var/nix/profiles/default/bin/"
4238

39+
4340
#
44-
# if nix STILL doesnt exist
41+
# if nix store doesn't exist
4542
#
46-
if [ -z "$(command -v "nix")" ]
47-
then
43+
if ! [ -d "/nix/store" ]; then
4844
echo "|------------------------------------------------------|" 1>&2
4945
echo "| |" 1>&2
5046
echo "| I'll try to install nix for you |" 1>&2
@@ -53,19 +49,16 @@ then
5349
echo "|------------------------------------------------------|" 1>&2
5450
echo ""
5551
# check for root
56-
if [ "$(whoami)" = "root" ]
57-
then
52+
if [ "$(whoami)" = "root" ]; then
5853
echo "$light_yellow"
5954
echo "looks like you're logged in as root"
6055
echo "sadly nix can't install on the root user"
6156
echo "please use a regular user, then re-run this script"
6257
echo "$color_reset"
6358
# if users exists
64-
if [ -n "$(command -v "getent")" ] && [ -n "$(command -v "cut")" ]
65-
then
59+
if [ -n "$(command -v "getent")" ] && [ -n "$(command -v "cut")" ]; then
6660
users="$(getent passwd {1000..6000} | cut -d: -f1)"
67-
if [ -n "$users" ] && [ "$users" != "root" ]
68-
then
61+
if [ -n "$users" ] && [ "$users" != "root" ]; then
6962
echo "the available users are:"
7063
echo "$users"
7164
echo
@@ -74,10 +67,9 @@ then
7467
else
7568
echo ""
7669
echo "it looks like this system doesn't have any regular users"
77-
70+
7871
# if useradd exists
79-
if [ -n "$(command -v "useradd")" ]
80-
then
72+
if [ -n "$(command -v "useradd")" ]; then
8173
question="do you want me to make a regular user for you? [y/n]";answer=''
8274
while true; do
8375
echo "$question"; read response
@@ -87,12 +79,11 @@ then
8779
* ) echo "Please answer yes or no.";;
8880
esac
8981
done
90-
82+
9183
if [ "$answer" = 'yes' ]; then
9284
echo "${light_purple}Enter a username:${color_reset}"
9385
read username
94-
if sudo useradd --create-home "$username" --password "password" --groups sudo
95-
then
86+
if sudo useradd --create-home "$username" --password "password" --groups sudo; then
9687
echo ""
9788
echo "user created successfully"
9889
echo "run:"
@@ -107,76 +98,75 @@ then
10798
echo "Okay"
10899
fi
109100
fi
110-
101+
111102
fi
112103
echo ""
113104
echo "login as the non-root user (${cyan}su USERNAME${color_reset})"
114105
echo "then re-run this command"
115106
exit
116107
fi
117108
fi
109+
118110
#
119111
# MacOS
120112
#
121-
if [ "$(uname)" = "Darwin" ]
122-
then
113+
if [ "$(uname)" = "Darwin" ]; then
123114
debugging_info="$debugging_info$newline""I think you have a Mac because "'"$OSTYPE" = "darwin"*'" came back true"
124115
full_version="$(sw_vers -productVersion)"
125-
major_version="$(echo "$full_version" | sed -E 's/([0-9]+)\.[0-9]+\.[0-9]+/\1/g')"
126-
minor_version="$(echo "$full_version" | sed -E 's/[0-9]+\.([0-9]+)\.[0-9]+/\1/g')"
116+
major_version="$(echo "$full_version" | sed -E 's/([0-9]+)\.[0-9]+(\.[0-9]+)?/\1/g')"
117+
minor_version="$(echo "$full_version" | sed -E 's/[0-9]+\.([0-9]+)(\.[0-9]+)?/\1/g')"
127118
#
128119
# Big Sur or Newer
129120
#
130-
if [ "$major_version" = "11" ]; then
131-
sh <(curl -Lk https://releases.nixos.org/nix/nix-2.3.7/install) --darwin-use-unencrypted-nix-store-volume
121+
if [ "$major_version" = "11" ] || \
122+
[ "$major_version" = "12" ] || \
123+
[ "$major_version" = "13" ] || \
124+
[ "$major_version" = "14" ] || \
125+
[ "$major_version" = "15" ]; then
126+
yes | bash <(curl -Lk https://releases.nixos.org/nix/nix-2.9.2/install) --darwin-use-unencrypted-nix-store-volume || sh <(curl -L https://nixos.org/nix/install) --daemon
132127
#
133128
# Older than Big Sur (Catalina, Mojave, High Siera, Siera, etc)
134129
#
135-
elif [ "$major_version" -eq "10" ]; then
130+
elif [ "$major_version" = "10" ]; then
136131
# Catalina
137132
if [ "$minor_version" = "15" ]; then
138-
sh <(curl -Lk https://releases.nixos.org/nix/nix-2.3.7/install) --darwin-use-unencrypted-nix-store-volume
133+
sh <(curl -Lk https://releases.nixos.org/nix/nix-2.9.2/install) --darwin-use-unencrypted-nix-store-volume
139134
# Mojave, High Siera, Siera, and might work on even older versions (Yosemite, Mavericks)
140135
else
141136
# the single-user install seems to have fewer install issues
142-
curl -Lk https://releases.nixos.org/nix/nix-2.3.7/install | sh -s
143-
# curl -Lk https://releases.nixos.org/nix/nix-2.3.7/install | sh -s -- --daemon
137+
curl -Lk https://releases.nixos.org/nix/nix-2.9.2/install | sh -s
138+
# curl -Lk https://releases.nixos.org/nix/nix-2.9.2/install | sh -s -- --daemon
144139
fi
145140
else
146141
echo 'We tried to get you MacOS version by running `sw_vers -productVersion`'
147142
echo '(which returns '"$full_version"')'
148143
echo "Either 1. that value is empty 2. You're on an insanely old version 3. You're on a version way way in the future from when this script was made"
149144
fi
150-
# assuming Linux/POSIX if not on MacOS
151-
else
145+
else # assuming Linux/POSIX if not on MacOS
152146
# if curl doesnt exist, try to make it exist
153-
if [ -z "$(command -v "curl")" ]
154-
then
147+
if [ -z "$(command -v "curl")" ]; then
155148
# if apt-get exists
156-
if [ -n "$(command -v "apt-get")" ]
157-
then
149+
if [ -n "$(command -v "apt-get")" ]; then
158150
sudo apt-get update && sudo apt-get install curl
159151
else
160152
echo "it looks like you don't have curl, please install curl then re-run this script" 1>&2
161-
echo "alternatively, to get nix, manually run the commands inside https://releases.nixos.org/nix/nix-2.3.7/install" 1>&2
153+
echo "alternatively, to get nix, manually run the commands inside https://releases.nixos.org/nix/nix-2.9.2/install" 1>&2
162154
fi
163155
fi
164-
156+
165157
# if now curl exists
166-
if [ -n "$(command -v "curl")" ]
167-
then
158+
if [ -n "$(command -v "curl")" ]; then
168159
# check if systemd exists
169-
if pidof systemd
170-
then
160+
if pidof systemd; then
171161
# the single-user install seems to have fewer install issues
172-
curl -Lk https://releases.nixos.org/nix/nix-2.3.7/install | sh -s
162+
curl -Lk https://releases.nixos.org/nix/nix-2.9.2/install | sh -s
173163
# # multi-user install if systemd exists
174-
# curl -Lk https://releases.nixos.org/nix/nix-2.3.7/install | sh -s -- --daemon
164+
# curl -Lk https://releases.nixos.org/nix/nix-2.9.2/install | sh -s -- --daemon
175165
else
176166
# single-user install if systemd does not exist
177-
curl -Lk https://releases.nixos.org/nix/nix-2.3.7/install | sh -s
167+
curl -Lk https://releases.nixos.org/nix/nix-2.9.2/install | sh -s
178168
fi
179169
fi
180-
fi
170+
fi
181171
fi
182172
fi

settings/extensions/nix/commands/fix_ssl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
#!/usr/bin/env bash
22

3+
# how to create up-to-date cert on MacOS
4+
# if [ "$(uname)" = "Darwin" ]
5+
# then
6+
# # check if file exists
7+
# if ! [ -f "/etc/ssl/certs/ca-certificates.crt" ]
8+
# then
9+
# #
10+
# # create an up-to-date cert with keychain
11+
# #
12+
# sudo mkdir -p /etc/ssl/certs/
13+
# sudo rm -f /etc/ssl/certs/ca-certificates.crt
14+
# sudo security export -t certs -f pemseq -k /System/Library/Keychains/SystemRootCertificates.keychain -o /etc/ssl/certs/ca-certificates.crt
15+
# # force/ensure correct permissions on folders/files
16+
# sudo chown root /etc /etc/ssl /etc/ssl/certs/ /etc/ssl/certs/ca-certificates.crt
17+
# sudo chmod u=rwx,g=rx,o=rx /etc
18+
# sudo chmod u=rwx,g=rx,o=rx /etc/ssl
19+
# sudo chmod u=rwx,g=rx,o=rx /etc/ssl/certs/
20+
# sudo chmod u=rw,g=r,o=r /etc/ssl/certs/ca-certificates.crt
21+
# fi
22+
# fi
23+
324
# if file exists, use it
425
__temp_var__certs_file="$FORNIX_FOLDER/settings/extensions/nix/cacert.pem"
526
if [ -f "$__temp_var__certs_file" ]
@@ -26,3 +47,17 @@ ca_certificate = $SSL_CERT_FILE" >> "$wgetrc_path"
2647
fi
2748
fi
2849
unset __temp_var__certs_file
50+
51+
52+
#
53+
# link cert into nix
54+
#
55+
nix_certificates_file="/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt" # not sure if different for single-user install
56+
# check if file exists
57+
if ! [ -f "$nix_certificates_file" ]
58+
then
59+
echo "Creating nix certificate file: $nix_certificates_file"
60+
sudo mkdir -p "$(dirname "$nix_certificates_file")"
61+
# link into nix profile
62+
sudo ln -s "$NIX_SSL_CERT_FILE" "$nix_certificates_file"
63+
fi

settings/extensions/nix/installer_helper

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,41 @@ then
88
trap 'unset repo; unset branch; unset setup_or_copy; unset mixin_remote_name; return; exit 0' INT TERM
99
fi
1010

11+
12+
#
13+
# make sure xcode tools are installed on MacOS
14+
#
15+
if [ "$(uname)" = "Darwin" ]
16+
then
17+
# if non-interactive, then install without prompting
18+
if [ -z "$PS1" ]; then
19+
xcode-select -p &> /dev/null
20+
if [ $? -ne 0 ]; then
21+
echo "Command Line Tools for Xcode not found. Installing from softwareupdate…"
22+
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools
23+
echo
24+
echo "This is probably going to take 5-30min to install"
25+
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
26+
PROD=$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')
27+
softwareupdate -i "$PROD" --verbose;
28+
else
29+
echo "Command Line Tools for Xcode have been installed."
30+
fi
31+
# use prompt so the user sees a time estimate and progress
32+
else
33+
check=$((xcode-\select --install) 2>&1)
34+
echo $check
35+
str="xcode-select: note: install requested for command line developer tools"
36+
while [[ "$check" == "$str" ]];
37+
do
38+
xcode-select --install
39+
echo "waiting for xcode command line tools to be installed"
40+
sleep 10
41+
done
42+
fi
43+
echo "passed xcode tools installed"
44+
fi
45+
1146
# TODO: add a check/option for a corrupted nix install
1247
1348
if ! [ -d "/nix/store" ]

settings/extensions/nix/nix.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ from = "c00039f697caa02208a01e7712bfe11c484cceca"
438438
#
439439
[[packages]]
440440
load = [ "deno",]
441-
from = "c82b46413401efa740a0b994f52e9903a4f6dcd5"
441+
from = "ce6aa13369b667ac2542593170993504932eb836"
442442

443443
[[packages]]
444444
load = [ "nix",]

settings/extensions/nix/packages/salt.nix

Lines changed: 0 additions & 22 deletions
This file was deleted.

settings/extensions/nix/shell.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ in
130130
main.project
131131
linuxOnly
132132
macOnly
133-
(snowball "https://raw.githubusercontent.com/jeff-hykin/snowball/3df028e5d9e92dbe077ce34f6907da852e61895a/").nixShell
134133
# an "inline" mixin (this is what each mixin looks like)
135134
({
136135
# inside that shell, make sure to use these packages

0 commit comments

Comments
 (0)