aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build.sh59
-rwxr-xr-xscripts/why-depends14
2 files changed, 73 insertions, 0 deletions
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 <benedikt.peetz@b-peetz.de>
+# 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 <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+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
diff --git a/scripts/why-depends b/scripts/why-depends
new file mode 100755
index 00000000..59f8d25b
--- /dev/null
+++ b/scripts/why-depends
@@ -0,0 +1,14 @@
+#! /usr/bin/env sh
+
+package="$1"
+version="$2"
+shift 2
+
+host="$(hostname)"
+
+fd "$package-$version" /nix/store --type directory | while read -r dir; do
+ nix why-depends "$@" ".#nixosConfigurations.$host.config.system.build.toplevel" "$dir"
+done
+
+
+# vim: ft=sh