2024-02-25 23:31:59 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Automated script to install my dotfiles
|
|
|
|
|
2024-02-29 07:17:06 +05:30
|
|
|
# Clone dotfiles
|
2024-02-26 00:34:02 +05:30
|
|
|
nix-shell -p git --command "git clone https://gitlab.com/librephoenix/nixos-config ~/.dotfiles"
|
2024-02-29 07:17:06 +05:30
|
|
|
|
|
|
|
# Generate hardware config for new system
|
2024-02-26 00:34:02 +05:30
|
|
|
sudo nixos-generate-config --show-hardware-config > ~/.dotfiles/system/hardware-configuration.nix
|
2024-02-29 07:17:06 +05:30
|
|
|
|
|
|
|
# Check if uefi or bios
|
|
|
|
if [ -d /sys/firmware/efi/efivars ]; then
|
|
|
|
sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"uefi\";/" ~/.dotfiles/flake.nix
|
|
|
|
else
|
|
|
|
sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"bios\";/" ~/.dotfiles/flake.nix
|
2024-03-01 08:18:15 +05:30
|
|
|
grubDevice=$(findmnt / | awk -F' ' '{ print $2 }' | sed 's/\[.*\]//g' | tail -n 1 | lsblk -no pkname | tail -n 1 )
|
|
|
|
sed -i "0,/grubDevice.*=.*\".*\";/s//grubDevice = \"\/dev\/$grubDevice\";/" ~/.dotfiles/flake.nix
|
2024-02-29 07:17:06 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
# Patch flake.nix with different username/name and remove email by default
|
2024-02-27 08:05:27 +05:30
|
|
|
sed -i "0,/emmet/s//$(whoami)/" ~/.dotfiles/flake.nix
|
|
|
|
sed -i "0,/Emmet/s//$(getent passwd $(whoami) | cut -d ':' -f 5 | cut -d ',' -f 1)/" ~/.dotfiles/flake.nix
|
|
|
|
sed -i "s/emmet@librephoenix.com//" ~/.dotfiles/flake.nix
|
2024-02-29 07:17:06 +05:30
|
|
|
|
|
|
|
# Open up editor to manually edit flake.nix before install
|
2024-02-26 00:34:02 +05:30
|
|
|
if [ -z "$EDITOR" ]; then
|
|
|
|
EDITOR=nano;
|
|
|
|
fi
|
|
|
|
$EDITOR ~/.dotfiles/flake.nix;
|
2024-02-29 07:17:06 +05:30
|
|
|
|
|
|
|
# Rebuild system
|
2024-02-26 00:34:02 +05:30
|
|
|
sudo nixos-rebuild switch --flake ~/.dotfiles#system;
|
2024-02-29 07:17:06 +05:30
|
|
|
|
|
|
|
# Install and build home-manager configuration
|
2024-02-26 01:20:11 +05:30
|
|
|
nix run home-manager/master --extra-experimental-features nix-command --extra-experimental-features flakes -- switch --flake ~/.dotfiles#user;
|
2024-02-29 07:17:06 +05:30
|
|
|
|
|
|
|
# Permissions for files that should be owned by root
|
2024-02-27 08:09:34 +05:30
|
|
|
sudo ~/.dotfiles/harden.sh ~/.dotfiles;
|