aboutsummaryrefslogtreecommitdiff
path: root/install.sh
blob: 1e1baf356f2b030b9df71d2964dd4c71276aec1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash

echo "Inserting files..."
mkdir -p ~/.config
sudo cp -r hypr foot nvim tmux waybar wofi yazi home-manager starship.toml ~/.config
sudo cp -r Wallpapers ~/Pictures

sudo cp -r nixos /etc
sudo nixos-generate-config

CHANNEL_FILE="nixos/nix-channel.txt"
if [[ ! -f "$CHANNEL_FILE" ]]; then
    echo "Error: Channel file not found at $CHANNEL_FILE"
    exit 1
fi
current_channels=$(sudo nix-channel --list)

# Read and process each channel from file
while IFS= read -r line || [[ -n "$line" ]]; do
    # Skip empty lines and comments
    [[ -z "$line" ]] || [[ "$line" =~ ^[[:space:]]*# ]] && continue
    
    # Parse channel name and URL (format: "name url")
    channel_name=$(echo "$line" | awk '{print $1}')
    channel_url=$(echo "$line" | awk '{print $2}')
    
    # Check if channel already exists
    if echo "$current_channels" | grep -q "^$channel_name "; then
        echo "✓ Channel '$channel_name' already exists"
    else
        echo "Adding channel '$channel_name' from $channel_url"
        sudo nix-channel --add "$channel_url" "$channel_name"
    fi
done < "$CHANNEL_FILE"

# Update channels after adding new ones
echo "Updating channels..."
sudo nix-channel --update

echo "Switching..."
sudo nixos-rebuild switch
home-manager switch