xin/bins/xin-status.nix

28 lines
689 B
Nix
Raw Normal View History

2023-09-12 08:44:05 -06:00
{ perl
, perlPackages
, ...
2023-07-11 09:12:50 -06:00
}: ''
#!${perl}/bin/perl
use strict;
use warnings;
use MIME::Base64;
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;
my $sys_diff = `nix store diff-closures /run/booted-system /run/current-system`;
$sys_diff =~ s/\e\[[0-9;]*m(?:\e\[K)?//g;
$info->{system_diff} = encode_base64($sys_diff);
$info->{uname_a} = `uname -a`;
2024-04-22 05:52:39 -06:00
$info->{uptime} = `uptime`;
chomp $info->{uname_a};
2024-04-22 05:52:39 -06:00
chomp $info->{uptime};
print encode_json $info;
''