bins: add xin-status for single shot status over ssh

This commit is contained in:
Aaron Bieber 2022-10-26 16:16:34 -06:00
parent 7067e9b9a5
commit c379b6237f
No known key found for this signature in database
2 changed files with 25 additions and 1 deletions

View File

@ -5,6 +5,8 @@ let
ix = pkgs.writeScriptBin "ix" (import ./ix.nix { inherit (pkgs) perl; });
checkRestart = pkgs.writeScriptBin "check-restart"
(import ./check-restart.nix { inherit (pkgs) perl; });
xinStatus = pkgs.writeScriptBin "xin-status"
(import ./xin-status.nix { inherit (pkgs) perl perlPackages; });
sfetch = pkgs.writeScriptBin "sfetch" (import ./sfetch.nix {
inherit gosignify;
@ -12,7 +14,13 @@ let
});
in {
environment.systemPackages = with pkgs; [ ix sfetch xclip checkRestart ];
environment.systemPackages = with pkgs; [
ix
sfetch
xclip
checkRestart
xinStatus
];
environment.etc = {
"signify/openbsd-72-base.pub".text =
builtins.readFile ./pubs/openbsd-72-base.pub;

16
bins/xin-status.nix Normal file
View File

@ -0,0 +1,16 @@
{ perl, perlPackages, ... }:
''
#!${perl}/bin/perl
use strict;
use warnings;
use Data::Dumper;
use lib "${perlPackages.JSON}/${perl.libPrefix}/${perl.version}/";
use JSON qw{ decode_json encode_json };
my $info = decode_json(`nixos-version --json`);
$info->{needs_restart} = system('check-restart >/dev/null') == 0 ? JSON::false : JSON::true;
print encode_json $info;
''