diff --git a/bins/default.nix b/bins/default.nix index cbc404d..d5a0d5e 100644 --- a/bins/default.nix +++ b/bins/default.nix @@ -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; diff --git a/bins/xin-status.nix b/bins/xin-status.nix new file mode 100644 index 0000000..bbc054b --- /dev/null +++ b/bins/xin-status.nix @@ -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; +''