From 0a9ba892a2e6fe8cbcbbc597dfb036248e380500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sat, 30 Nov 2019 19:34:08 +0100 Subject: [PATCH] feat: add niveum-scripts --- configs/default.nix | 17 ----------------- niveum-deploy | 6 ++++++ niveum-status | 20 ++++++++++++++++++++ update-channels => niveum-update | 0 4 files changed, 26 insertions(+), 17 deletions(-) create mode 100755 niveum-deploy create mode 100755 niveum-status rename update-channels => niveum-update (100%) diff --git a/configs/default.nix b/configs/default.nix index ee488d1..aa954d1 100644 --- a/configs/default.nix +++ b/configs/default.nix @@ -157,23 +157,6 @@ in environment.systemPackages = [ pkgs.pavucontrol pkgs.pamixer ]; } - { - environment.systemPackages = - let niveumPath = "${config.users.users.me.home}/prog/git/niveum"; - in [ - (pkgs.writers.writeDashBin "niveum-deploy" '' - [ $# -eq 1 ] || echo >&2 "Usage: niveum-deploy SYSTEM" - - eval $(${pkgs.nix}/bin/nix-build --no-out-link "${niveumPath}/deploy.nix" -A "$1") - '') - (pkgs.writers.writeDashBin "niveum-update" '' - ${pkgs.nix-prefetch-git}/bin/nix-prefetch-git \ - --url https://github.com/NixOS/nixpkgs-channels \ - --rev refs/heads/nixos-${config.system.stateVersion} \ - > "${niveumPath}/nixpkgs.json" - '') - ]; - } { environment.interactiveShellInit = "export PATH=$PATH:$HOME/.cargo/bin"; environment.shellAliases = diff --git a/niveum-deploy b/niveum-deploy new file mode 100755 index 0000000..a1810c7 --- /dev/null +++ b/niveum-deploy @@ -0,0 +1,6 @@ +#!/bin/sh +niveum_dir="$HOME/prog/git/niveum" + +[ $# -eq 1 ] || echo >&2 "Usage: niveum-deploy SYSTEM" + +eval "$(nix-build --no-out-link "$niveum_dir/deploy.nix" -A "$1")" diff --git a/niveum-status b/niveum-status new file mode 100755 index 0000000..1f5fc9a --- /dev/null +++ b/niveum-status @@ -0,0 +1,20 @@ +#!/bin/sh +version_file=/etc/niveum/version +niveum_dir="$HOME/prog/git/niveum" + +machine_status () { + hostname="$1" + + if commit_id="$(ssh "$hostname" cat $version_file 2>/dev/null)"; then + machine_status="$(git -C "$niveum_dir" log -1 --oneline "$commit_id")" + else + machine_status=offline + fi + + printf "\033[1m%11s\033[0m %s\n" "$hostname" "$machine_status" +} + +for system in "$niveum_dir"/systems/*; do + hostname="$(basename "$system")" + machine_status "$hostname" +done diff --git a/update-channels b/niveum-update similarity index 100% rename from update-channels rename to niveum-update