From 6d3c611d71d039d951c58d1ace0a0c2c7f12c77f Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Tue, 5 Oct 2021 08:57:57 -0400 Subject: [PATCH] feat: add buildthis bud command --- bud/buildthis.bash | 9 +++++++++ bud/default.nix | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 bud/buildthis.bash diff --git a/bud/buildthis.bash b/bud/buildthis.bash new file mode 100644 index 0000000..15c322b --- /dev/null +++ b/bud/buildthis.bash @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +attr="$FLAKEROOT#$HOST" +if [ -x /run/wrappers/bin/sudo ]; then + export PATH=/run/wrappers/bin:$PATH + sudo nixos-rebuild --flake "$attr" "${@:2}" +else + nixos-rebuild --flake "$attr" "${@:2}" +fi diff --git a/bud/default.nix b/bud/default.nix index c486636..1289063 100644 --- a/bud/default.nix +++ b/bud/default.nix @@ -6,5 +6,12 @@ help = "Copy the desired template to DEST"; script = ./get.bash; }; + + buildthis = { + writer = budUtils.writeBashWithPaths [ nixUnstable nixos-rebuild git coreutils mercurial ]; + synopsis = "buildthis (switch|boot|test)"; + help = "Shortcut for nixos-rebuild using the current hostname"; + script = ./buildthis.bash; + }; }; }