Kieran's opinionated (and probably slightly dumb) nix config

docs: add install script

dunkirk.sh cadf5b33 6383cf18

verified
+57
INSTALL_GUIDE.md
···
+
# So, you want to use my dots?
+
+
Hey there! This guide supplements the README with additional details about using the installation scripts. I've tried to make installation as painless as possible. (mainly because i hate typing in commands manually with no autocomplete; yeah ik im not a "true" linux nerd but whatever lol)
+
+
## The Automated Way (Recommended)
+
+
### Step 1: Get connected
+
+
First, make sure you've got internet! (this is already covered in [`README.md`](/README.md) so not duplicating here) Also don't forget to double check with `ping 1.1.1.1`
+
+
### Step 2: Run the install script
+
+
```bash
+
curl -L https://raw.githubusercontent.com/taciturnaxolotl/dots/main/nixos/install.sh -o install.sh
+
chmod +x install.sh
+
./install.sh
+
```
+
+
This magic script will:
+
- Make sure you're online
+
- Enable git (required for the rest of this charade)
+
- Partition your disks with disko
+
- Clone my dots to the right place
+
- Let you add your SSH key if you've got one
+
- Install the flake
+
- Send you off to reboot land
+
+
### Step 3: First login after reboot
+
+
After the system reboots, login with user `kierank` and password `lolzthisaintsecure!`
+
+
(Please change this password immediately!)
+
+
### Step 4: Run the post-install script
+
+
```bash
+
curl -L https://raw.githubusercontent.com/taciturnaxolotl/dots/main/nixos/post-install.sh -o post-install.sh
+
chmod +x post-install.sh
+
./post-install.sh
+
```
+
+
This script will walk you through:
+
- Changing your password (if you haven't already)
+
- Moving config files to your home directory
+
- Setting up the fingerprint reader (optional)
+
- Configuring git (optional)
+
- Rebuilding the system with your hostname
+
+
## Available System Configurations
+
+
Currently, this repo has the following system configurations:
+
+
- `moonlark` - My Framework laptop setup (default config)
+
+
You'll be asked which one you want during the installation.
+
+
Good luck, and may the nix gods be with you! 🙏
+25
LICENSE.md
···
+
The MIT License (MIT)
+
=====================
+
+
Copyright © `2025` `Kieran Klukas`
+
+
Permission is hereby granted, free of charge, to any person
+
obtaining a copy of this software and associated documentation
+
files (the “Software”), to deal in the Software without
+
restriction, including without limitation the rights to use,
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
+
copies of the Software, and to permit persons to whom the
+
Software is furnished to do so, subject to the following
+
conditions:
+
+
The above copyright notice and this permission notice shall be
+
included in all copies or substantial portions of the Software.
+
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+
OTHER DEALINGS IN THE SOFTWARE.
+27 -1
README.md
···
> ~~I have absolutely no idea how to install this~~ I kinda understand now?
>
-
> ⚠️ These installation instructions are being actively worked on as I test installation on a friend's computer
+
> These instructions have been validated by installing on my friend's machine ([`Nat2-Dev/dots`](https://github.com/Nat2-Dev/dots))
+
+
You have two options for installation: either the full guide as follows or the install script below and instructions in [INSTALL_GUIDE.md](/INSTALL_GUIDE.md)
+
+
```bash
+
curl -L https://raw.githubusercontent.com/taciturnaxolotl/dots/main/nixos/install.sh -o install.sh
+
chmod +x install.sh
+
./install.sh
+
```
+
+
### The manual way
Install NixOS via the [official guide](https://nixos.org/download.html)
···
- [gtk with home manager](https://hoverbear.org/blog/declarative-gnome-configuration-in-nixos/)
- [setting up the proper portals](https://github.com/NixOS/nixpkgs/issues/274554)
- [tuigreet setup](https://github.com/sjcobb2022/nixos-config/blob/29077cee1fc82c5296908f0594e28276dacbe0b0/hosts/common/optional/greetd.nix)
+
+
## 📜 License
+
+
The code is licensed under `MIT`! That means MIT allows for free use, modification, and distribution of the software, requiring only that the original copyright notice and disclaimer are included in copies. All artwork and images are copyright reserved but may be used with proper attribution to the authors.
+
+
<p align="center">
+
<img src="https://raw.githubusercontent.com/taciturnaxolotl/carriage/master/.github/images/line-break.svg" />
+
</p>
+
+
<p align="center">
+
<i><code>&copy 2025-present <a href="https://github.com/taciturnaxolotl">Kieran Klukas</a></code></i>
+
</p>
+
+
<p align="center">
+
<a href="https://github.com/taciturnaxolotl/dots/blob/master/LICENSE.md"><img src="https://img.shields.io/static/v1.svg?style=for-the-badge&label=License&message=MIT&logoColor=d9e0ee&colorA=363a4f&colorB=b7bdf8"/></a>
+
</p>
+140
install.sh
···
+
#!/usr/bin/env bash
+
+
# NixOS Installation Script
+
# This script automates the post-network setup installation process
+
+
set -e # Exit on any error
+
+
echo "==== NixOS Installation Automation ===="
+
echo "This script will automate the installation process after network setup."
+
echo "Make sure you have already set up network connectivity before running this script."
+
+
# Verify network connectivity
+
echo -n "Checking network connectivity... "
+
if ping -c 1 1.1.1.1 &> /dev/null; then
+
echo "Success!"
+
else
+
echo "Failed!"
+
echo "Error: No internet connection detected. Please set up your network first."
+
echo "You can use the following commands to connect to WiFi:"
+
echo " sudo systemctl start wpa_supplicant"
+
echo " wpa_cli"
+
echo " > add_network 0"
+
echo " > set_network 0 ssid \"your SSID\""
+
echo " > set_network 0 psk \"your password\""
+
echo " > enable network 0"
+
echo " > exit"
+
exit 1
+
fi
+
+
# Get sudo privileges and maintain them
+
echo "Acquiring root permissions..."
+
sudo -v
+
# Keep sudo privileges active
+
while true; do sudo -v; sleep 60; done &
+
KEEP_SUDO_PID=$!
+
+
# Function to clean up the background sudo process on exit
+
cleanup() {
+
kill $KEEP_SUDO_PID 2>/dev/null
+
}
+
trap cleanup EXIT
+
+
# Check if git is already enabled in the configuration
+
echo "Checking git configuration..."
+
if grep -q "programs.git.enable = true" /etc/nixos/configuration.nix; then
+
echo "Git is already enabled in configuration.nix"
+
else
+
echo "Enabling git..."
+
sudo sed -i 's/^{$/{\n programs.git.enable = true;/' /etc/nixos/configuration.nix
+
sudo nixos-rebuild switch
+
fi
+
+
# Download and run the disk configuration
+
echo "Downloading and running disk configuration..."
+
curl -L https://github.com/taciturnaxolotl/dots/raw/main/moonlark/disk-config.nix -o /tmp/disk-config.nix
+
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode destroy,format,mount /tmp/disk-config.nix
+
+
# Generate NixOS configuration
+
echo "Generating NixOS configuration..."
+
sudo nixos-generate-config --root /mnt
+
cd /mnt/etc/nixos
+
+
# Check if repository already exists
+
echo "Setting up configuration..."
+
if [ -d ".git" ]; then
+
echo "Configuration already exists, pulling latest changes..."
+
sudo git pull
+
else
+
# Clone the repository to the NixOS configuration directory
+
echo "Cloning nixos repository..."
+
sudo rm -f *
+
sudo git clone https://github.com/taciturnaxolotl/dots.git .
+
fi
+
+
# Prompt user for SSH key setup
+
echo ""
+
echo "SSH Key Setup"
+
read -p "Do you want to add an SSH private key? (y/n): " add_ssh_key
+
if [[ "$add_ssh_key" =~ ^[Yy]$ ]]; then
+
echo "How would you like to add your SSH key?"
+
echo "1) From a local file"
+
echo "2) From a URL"
+
read -p "Enter your choice (1/2): " ssh_key_method
+
+
sudo mkdir -p /mnt/etc/ssh/
+
+
if [[ "$ssh_key_method" == "1" ]]; then
+
echo "Please enter the path to your SSH private key:"
+
read ssh_key_path
+
+
if [ -f "$ssh_key_path" ]; then
+
sudo cp "$ssh_key_path" /mnt/etc/ssh/id_rsa
+
sudo chmod 600 /mnt/etc/ssh/id_rsa
+
echo "SSH key added from local file!"
+
else
+
echo "Warning: SSH key file not found. Proceeding without SSH key."
+
fi
+
elif [[ "$ssh_key_method" == "2" ]]; then
+
echo "Please enter the URL to download your SSH private key:"
+
read ssh_key_url
+
+
echo "Downloading SSH key from URL..."
+
if curl -s "$ssh_key_url" -o /tmp/downloaded_ssh_key; then
+
sudo mv /tmp/downloaded_ssh_key /mnt/etc/ssh/id_rsa
+
sudo chmod 600 /mnt/etc/ssh/id_rsa
+
echo "SSH key successfully downloaded and added!"
+
else
+
echo "Warning: Failed to download SSH key from URL. Proceeding without SSH key."
+
fi
+
else
+
echo "Invalid choice. Proceeding without SSH key."
+
fi
+
else
+
echo "Proceeding without SSH key."
+
fi
+
+
# Prompt for hostname configuration
+
echo ""
+
echo "Hostname Configuration"
+
echo "Available configurations in this repo:"
+
echo "1) moonlark (default)"
+
read -p "Which configuration would you like to use? (Press Enter for moonlark): " hostname_choice
+
hostname=${hostname_choice:-moonlark}
+
+
# Install the flake
+
echo "Installing the flake for configuration: $hostname"
+
sudo nixos-install --flake .#${hostname} --no-root-passwd
+
+
echo "Installation complete! The system will now reboot."
+
echo ""
+
echo "After reboot, you'll need to complete these post-installation tasks:"
+
echo "1. Change your password"
+
echo "2. Move config to local directory: mkdir ~/etc; sudo mv /etc/nixos ~/etc"
+
echo "3. Link to /etc/nixos: sudo ln -s ~/etc/nixos /etc"
+
echo "4. Change permissions: sudo chown -R \$(id -un):users ~/etc/nixos"
+
echo "5. Setup fingerprint reader (optional): sudo fprintd-enroll -f right-index-finger \$(whoami)"
+
+
read -p "Press Enter to unmount and reboot..."
+
sudo umount -R /mnt
+
sudo reboot
+85
post-install.sh
···
+
#!/usr/bin/env bash
+
+
# NixOS Post-Installation Script
+
# This script automates the post-installation tasks after the first reboot
+
+
set -e # Exit on any error
+
+
echo "==== NixOS Post-Installation Setup ===="
+
echo "This script will automate the post-installation tasks."
+
+
# Function to print current step
+
print_step() {
+
echo -e "\n\033[1;34m==== $1 ====\033[0m"
+
}
+
+
# Change password if needed
+
print_step "Password Management"
+
read -p "Do you want to change your password? (y/n): " change_password
+
if [[ "$change_password" =~ ^[Yy]$ ]]; then
+
passwd
+
echo "Password changed successfully!"
+
fi
+
+
# Move config to local directory and fix permissions
+
print_step "Setting up configuration files"
+
if [ -L "/etc/nixos" ]; then
+
echo "Configuration is already properly set up."
+
else
+
echo "Moving configuration to home directory..."
+
mkdir -p ~/etc
+
sudo mv /etc/nixos ~/etc/
+
sudo ln -s ~/etc/nixos /etc/
+
echo "Fixing permissions..."
+
sudo chown -R $(id -un):users ~/etc/nixos
+
sudo chown -R $(id -un) ~/etc/nixos/.*
+
echo "Configuration files moved and linked successfully!"
+
fi
+
+
# Setup fingerprint reader (optional)
+
print_step "Fingerprint Reader Setup"
+
read -p "Do you want to set up the fingerprint reader? (y/n): " setup_fingerprint
+
if [[ "$setup_fingerprint" =~ ^[Yy]$ ]]; then
+
echo "Setting up fingerprint reader..."
+
echo "You may need to swipe your finger across the fingerprint sensor instead of simply laying it there."
+
sudo fprintd-enroll -f right-index-finger $(whoami)
+
echo "Verifying fingerprint..."
+
sudo fprintd-verify $(whoami)
+
else
+
echo "Skipping fingerprint reader setup."
+
fi
+
+
# Git configuration
+
print_step "Git Configuration"
+
read -p "Do you want to configure Git? (y/n): " setup_git
+
if [[ "$setup_git" =~ ^[Yy]$ ]]; then
+
read -p "Enter your Git taciturnaxolotl: " git_user
+
read -p "Enter your Git email: " git_email
+
+
git config --global user.name "$git_user"
+
git config --global user.email "$git_email"
+
+
echo "Git configuration complete!"
+
fi
+
+
# Rebuild system
+
print_step "Rebuilding system"
+
read -p "Do you want to rebuild the system to apply all changes? (y/n): " rebuild_system
+
if [[ "$rebuild_system" =~ ^[Yy]$ ]]; then
+
echo "Rebuilding system..."
+
cd ~/etc/nixos
+
+
# Get the hostname to use for the rebuild
+
hostname=$(hostname)
+
echo "Current hostname: $hostname"
+
+
sudo nixos-rebuild switch --flake .#${hostname}
+
echo "System rebuilt successfully!"
+
else
+
echo "Skipping system rebuild."
+
fi
+
+
print_step "Post-installation complete!"
+
echo "Your NixOS setup is now complete! You may need to restart some applications or services for all changes to take effect."
+
echo "To rebuild your system in the future, run: cd ~/etc/nixos && sudo nixos-rebuild switch --flake .#$(hostname)"
+
echo "Enjoy your new NixOS installation!"