pkgs: add flake-warn to print out when flakes are out of date
This commit is contained in:
parent
c94fc6a16f
commit
bcfb4cb124
@ -227,6 +227,7 @@
|
||||
isUnstable = true;
|
||||
};
|
||||
femtolisp = pkgs.callPackage ./pkgs/femtolisp.nix { };
|
||||
flake-warn = pkgs.callPackage ./pkgs/flake-warn.nix { inherit pkgs; };
|
||||
kurinto = pkgs.callPackage ./pkgs/kurinto.nix { };
|
||||
mcchunkie = pkgs.callPackage ./pkgs/mcchunkie.nix { inherit pkgs; };
|
||||
yaegi = pkgs.callPackage ./pkgs/yaegi.nix { inherit pkgs; };
|
||||
|
25
pkgs/flake-warn.nix
Normal file
25
pkgs/flake-warn.nix
Normal file
@ -0,0 +1,25 @@
|
||||
{ stdenv, lib, substituteAll, jq, nix, coreutils, ... }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "flake-warn";
|
||||
version = "1.0.0";
|
||||
|
||||
buildCommand = ''
|
||||
install -Dm755 $script $out/bin/${pname}
|
||||
'';
|
||||
|
||||
script = substituteAll {
|
||||
src = ./flake-warn.sh;
|
||||
isExecutable = true;
|
||||
inherit jq nix coreutils;
|
||||
inherit (stdenv) shell;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "script to warn when flake inputs are out of date";
|
||||
homepage = "https://github.com/qbit/xin";
|
||||
license = lib.licenses.isc;
|
||||
maintainer = with lib.maintainers; [ qbit ];
|
||||
mainProgram = "flake-warn";
|
||||
};
|
||||
}
|
14
pkgs/flake-warn.sh
Normal file
14
pkgs/flake-warn.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!@shell@ -e
|
||||
|
||||
BOLD=$(tput bold)
|
||||
NORMAL=$(tput sgr0)
|
||||
|
||||
FLAKE_EPOCH=$(@nix@/bin/nix flake metadata --json | @jq@/bin/jq .lastModified)
|
||||
NOW_EPOCH=$(@coreutils@/bin/date +"%s")
|
||||
|
||||
EPOCH_DIFF=$(($NOW_EPOCH - $FLAKE_EPOCH))
|
||||
|
||||
if [ $EPOCH_DIFF -gt 60480 ]; then
|
||||
echo "${BOLD}WARNING: inputs haven't been updated in $(($EPOCH_DIFF / 86400)) days!${NORMAL}"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user