about summary refs log tree commit diff stats
path: root/build.sh
blob: 357acf584c9afed1259024d69d568e57c87800d3 (plain) (blame)
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
#!/usr/bin/env sh

host="${1-tiamat}"
root="$(git rev-parse --show-toplevel)"

SYSTEM_OUT="$root/result-system"
HOME_OUT="$root/result-home-soispha"

check() {
    file="$1"
    if [ -s "$file" ]; then
        rm "$file"
    elif ! [ -e "$file" ]; then
        : "Ignore not existing files"
    else
        echo "ERROR: '$file' is not a symlink. Not removing it." 1>&2
        exit 1
    fi
}

system="$(nix build ".#nixosConfigurations.$host.config.system.build.toplevel" --print-out-paths --no-link)"
check "$SYSTEM_OUT"
ln --symbolic "$system" "$SYSTEM_OUT"

home="$(grep ExecStart= "$SYSTEM_OUT/etc/systemd/system/home-manager-soispha.service" | awk '{print $2}')"
check "$HOME_OUT"
ln --symbolic "$home" "$HOME_OUT"

# vim: ft=sh