From 191b13a95500ae8a023ac816e7ff0319b3796a9c Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 30 Nov 2025 16:16:59 +0100 Subject: scripts/why-depends: Init --- scripts/build.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 scripts/build.sh (limited to 'scripts/build.sh') diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..f3661978 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env sh + +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see . + +host="${1-$(hostname)}" +[ "$#" -gt 0 ] && shift 1 + +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 + rm "$file" || { + : "Ignore not existing files" + } + else + echo "ERROR: '$file' is not a symlink. Not removing it." 1>&2 + exit 1 + fi +} + +build_system() { + _val="$(nix build ".#nixosConfigurations.$host.config.system.build.toplevel" --print-out-paths --no-link --option max-jobs 1 "$@")" + exit_val="$?" + + if [ "$exit_val" -ne 0 ]; then + echo "ERROR: Failed to build you system config for host: '$host'" 1>&2 + printf 1 + else + printf "%s" "$_val" + fi +} + +system="$(build_system "$@")" +[ "$system" = "1" ] && exit 1 + +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" + +nvd diff /run/current-system "$SYSTEM_OUT" + +# vim: ft=sh -- cgit 1.4.1