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 --- .envrc | 2 ++ build.sh | 59 ----------------------------------------------------- scripts/build.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/why-depends | 14 +++++++++++++ 4 files changed, 75 insertions(+), 59 deletions(-) delete mode 100755 build.sh create mode 100755 scripts/build.sh create mode 100755 scripts/why-depends diff --git a/.envrc b/.envrc index 294de504..f1c78da8 100644 --- a/.envrc +++ b/.envrc @@ -11,3 +11,5 @@ # If not, see . use flake + +PATH_add ./scripts diff --git a/build.sh b/build.sh deleted file mode 100755 index f3661978..00000000 --- a/build.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/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 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 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 -- cgit 1.4.1