irpf: add update script

This commit is contained in:
loco-choco
2024-06-21 21:59:43 -03:00
committed by Locochoco
parent 4a07c5b9cc
commit 0ce09b94c3
@@ -7,6 +7,7 @@
, makeWrapper
, unzip
, xdg-utils
, writeScript
}:
stdenvNoCC.mkDerivation rec {
@@ -22,6 +23,16 @@ stdenvNoCC.mkDerivation rec {
hash = "sha256-7Eh5XhZKs2DAQC33ICUG+mgjEU7H3jdYZSeiHNJ6I6Q=";
};
passthru.updateScript = writeScript "update-irpf" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl pup common-updater-scripts
set -eu -o pipefail
#parses the html with the install links for the containers that contain the instalation files of type 'file archive, gets the version number of each version, and sorts to get the latest one on the website
version="$(curl -s https://www.gov.br/receitafederal/pt-br/centrais-de-conteudo/download/pgd/dirpf | pup '.rfb_container .rfb_ositem:parent-of(.fa-file-archive) attr{href}' | grep -oP "IRPF\K(\d+)-[\d.]+\d" | sort -r | head -1)"
update-source-version irpf "$version"
'';
nativeBuildInputs = [ unzip makeWrapper copyDesktopItems ];
desktopItems = [