Skip to content

Commit

Permalink
feat(nix): add some scripts and reorganise them a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayeu committed Feb 17, 2023
1 parent 6bac9be commit 6695bc1
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
42 changes: 42 additions & 0 deletions bin.symlink/delete-nix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# This script WILL delete your data indiscriminatly without prompting you.
# It's not a bug, that's the whole point.

echo "🔄 Restore the original bashrc & zshrc"
sudo rename -fx /etc/*.backup-before-nix

echo "🧹 Remove the fstab entry for /nix"
sudo sed -i.bak -e '/nix apfs/d' -e '/^$/d' /etc/fstab

echo "🧹 Remove the synthetic entry for nix"
sed -i.bak '/nix/d' /etc/synthetic.conf

echo "🧹 Stop and remove the nix daemon service"
launchctl unload /Library/LaunchDaemon/org.nixos.nix-daemon.plist
rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
launchctl unload /Library/LaunchDaemons/org.nixos.activate-system.plist
rm /Library/LaunchDaemons/org.nixos.activate-system.plist
sudo launchctl bootout system/org.nixos.darwin-store
rm /Library/LaunchDaemons/org.nixos.darwin-store.plist

echo "🧹 Remove the files created by nix"
rm -rf \
/etc/nix /var/root/.nix-profile \
/var/root/.nix-defexpr \
/var/root/.nix-channels \
~/.nix-profile \
~/.nix-defexpr \
~/.nix-channels

echo "🛑 Remove the groups created by nix"
dscl . delete /Groups/nixbld
for i in $(seq 1 32); do sudo dscl . -delete /Users/_nixbld$i; done

echo "🧹 Remove the nix store volume"
umount /nix
diskutil apfs deleteVolume /nix
diskutil apfs deleteVolume "Nix Store"
rm -rf /nix/

echo "🐈 Now reboot your computer KTHXBYE"
35 changes: 35 additions & 0 deletions bin.symlink/install-nix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

cd ~/ && git clone https://github.com/Mayeu/dots .dots

#echo "📦 Installing nix"
sh <(curl -L https://nixos.org/nix/install)

echo "⤴️ Loading nix"
source /etc/static/bashrc

echo "🚇 Adding my channels"
nix-channel --add https://channels.nixos.org/nixpkgs-22.11-darwin nixpkgs
nix-channel --add https://channels.nixos.org/nixpkgs-unstable unstable
nix-channel --update

# cat <<EOF | sudo tee -a /etc/nix/nix.conf
# substituters = https://cache.nixos.org/ ${{ secrets.S3_URL }}
# trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= mdots:h40b7TWhz9PqO04aqOAiAEEdulJ2Q9oJ3MxXQCgQVvs=
# post-build-hook = /etc/nix/upload-to-cache.sh
# EOF

echo "😈 Install nix-darwin"
tmp=$(mktemp -d)

cd "$tmp"

export NIX_CONF="binary-caches=s3://mdots?endpoint=https://s3.fr-par.scw.cloud/"

nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer --extra-substituters 's3://mdots?endpoint=https://s3.fr-par.scw.cloud/'

echo "🔨 Building my system"
# Don't think the source is needed here
source /etc/static/bashrc
darwin-rebuild switch
6 changes: 2 additions & 4 deletions bin.symlink/mac-bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ brew install --cask \

#ocenaudio \

echo "👁 Disagle gcloud cli reporting"
gcloud config set disable_usage_reporting false
#echo "👁 Disagle gcloud cli reporting"
#gcloud config set disable_usage_reporting false

echo "🍺 Install cli apps"
brew install \
Expand Down Expand Up @@ -149,8 +149,6 @@ echo "🐳 Give some root right to the hyperkit docker driver"
sudo chown root:wheel /usr/local/opt/docker-machine-driver-hyperkit/bin/docker-machine-driver-hyperkit
sudo chmod u+s /usr/local/opt/docker-machine-driver-hyperkit/bin/docker-machine-driver-hyperkit

cd ~/ && git clone https://github.com/Mayeu/dots .dots

# Make sure dvp is my login keyboard
echo "⌨️ Update my login keyboard"
sudo cp ~/Library/Preferences/com.apple.HIToolbox.plist /Library/Preferences/
Expand Down
6 changes: 6 additions & 0 deletions bin.symlink/nix-after-macos-upgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set -e
sudo mv /etc/bashrc /etc/bashrc.orig
sudo mv /etc/zshrc /etc/zshrc.orig
sudo mv /etc/zprofile /etc/zprofile.orig
sudo /nix/var/nix/profiles/system/activate
exit # Start a new shell to reload the environment.
2 changes: 1 addition & 1 deletion nixpkgs.symlink/darwin-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ in
nix = {
#package = pkgs.nixUnstable;
#package = pkgs.nixFlakes;
package = unstable.nix; # Necessary to get >=2.5, with Flake support.
#package = unstable.nix; # Necessary to get >=2.5, with Flake support.

settings = {
substituters = ["s3://mdots?endpoint=https://s3.fr-par.scw.cloud/&region=fr-par"];
Expand Down

0 comments on commit 6695bc1

Please sign in to comment.