2022-03-30 09:31:56 +00:00
{ lib
, stdenvNoCC
, fetchzip
, copyDesktopItems
, jdk11
, makeDesktopItem
, makeWrapper
, unzip
2022-04-27 09:35:20 +00:00
, xdg-utils
2024-07-27 06:49:29 +00:00
, writeScript
2022-03-30 09:31:56 +00:00
} :
2024-07-27 06:49:29 +00:00
stdenvNoCC . mkDerivation ( finalAttrs : {
2022-03-30 09:31:56 +00:00
pname = " i r p f " ;
2024-09-19 14:19:46 +00:00
version = " 2 0 2 4 - 1 . 4 " ;
2022-03-30 09:31:56 +00:00
2023-03-24 00:07:29 +00:00
# https://www.gov.br/receitafederal/pt-br/centrais-de-conteudo/download/pgd/dirpf
# Para outros sistemas operacionais -> Multi
2022-03-30 09:31:56 +00:00
src = let
2024-07-27 06:49:29 +00:00
year = lib . head ( lib . splitVersion finalAttrs . version ) ;
2022-03-30 09:31:56 +00:00
in fetchzip {
2024-07-27 06:49:29 +00:00
url = " h t t p s : / / d o w n l o a d i r p f . r e c e i t a . f a z e n d a . g o v . b r / i r p f / ${ year } / i r p f / a r q u i v o s / I R P F ${ finalAttrs . version } . z i p " ;
2024-09-19 14:19:46 +00:00
hash = " s h a 2 5 6 - 2 2 3 P Z y G l L S K 5 G z R 1 4 3 I l G z h m J l X m v t B d s c C 2 r o P i Q h c = " ;
2022-03-30 09:31:56 +00:00
} ;
2024-07-27 06:49:29 +00:00
passthru . updateScript = writeScript " u p d a t e - i r p f " ''
#!/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 = " $ ( c u r l - s h t t p s : / / w w w . g o v . b r / r e c e i t a f e d e r a l / p t - b r / c e n t r a i s - d e - c o n t e u d o / d o w n l o a d / p g d / d i r p f | p u p ' . r f b _ c o n t a i n e r . r f b _ o s i t e m : p a r e n t - o f ( . f a - f i l e - a r c h i v e ) a t t r { h r e f } ' | g r e p - o P " IRPF \ K ( \ d + ) - [ \ d . ] + \ d " | s o r t - r | h e a d - 1 ) "
update-source-version irpf " $ v e r s i o n "
'' ;
2022-03-30 09:31:56 +00:00
nativeBuildInputs = [ unzip makeWrapper copyDesktopItems ] ;
desktopItems = [
2024-01-02 11:29:13 +00:00
( makeDesktopItem {
2024-07-27 06:49:29 +00:00
name = finalAttrs . pname ;
exec = finalAttrs . pname ;
2022-03-30 09:31:56 +00:00
icon = " r f b 6 4 " ;
desktopName = " I m p o s t o d e R e n d a P e s s o a F í s i c a " ;
comment = " P r o g r a m a O f i c i a l d a R e c e i t a p a r a e l a b o r a ç ã o d o I R P F " ;
categories = [ " O f f i c e " ] ;
} )
] ;
installPhase = ''
runHook preInstall
2024-07-27 06:49:29 +00:00
BASEDIR = " $ o u t / s h a r e / ${ finalAttrs . pname } "
2022-03-30 09:31:56 +00:00
mkdir - p " $ B A S E D I R "
2024-01-02 11:29:13 +00:00
cp - - no-preserve = mode - r help lib lib-modulos " $ B A S E D I R "
2022-03-30 09:31:56 +00:00
2024-01-02 11:29:13 +00:00
install - Dm644 irpf . jar Leia-me . htm offline . png online . png pgd-updater . jar " $ B A S E D I R "
2022-03-30 09:31:56 +00:00
2022-08-21 13:32:41 +00:00
# make xdg-open overrideable at runtime
2024-07-27 06:49:29 +00:00
makeWrapper $ { jdk11 } /bin/java $ out/bin / $ { finalAttrs . pname } \
2022-03-30 09:31:56 +00:00
- - add-flags " - D a w t . u s e S y s t e m A A F o n t S e t t i n g s = o n " \
- - add-flags " - D s w i n g . a a t e x t = t r u e " \
2024-07-27 06:49:29 +00:00
- - add-flags " - j a r $ B A S E D I R / ${ finalAttrs . pname } . j a r " \
2022-08-21 13:32:41 +00:00
- - suffix PATH : $ { lib . makeBinPath [ xdg-utils ] } \
2022-03-30 09:31:56 +00:00
- - set _JAVA_AWT_WM_NONREPARENTING 1 \
- - set AWT_TOOLKIT MToolkit
mkdir - p $ out/share/pixmaps
unzip - j lib/ppgd-icones-4.0.jar icones/rfb64.png - d $ out/share/pixmaps
runHook postInstall
'' ;
meta = with lib ; {
2022-04-27 09:35:20 +00:00
description = " B r a z i l l i a n g o v e r n m e n t a p p l i c a t i o n f o r r e p o r t i n g i n c o m e t a x " ;
longDescription = ''
Brazillian government application for reporting income tax .
IRFP - Imposto de Renda Pessoa F í sica - Receita Federal do Brasil .
'' ;
2022-03-30 09:31:56 +00:00
homepage = " h t t p s : / / w w w . g o v . b r / r e c e i t a f e d e r a l / p t - b r " ;
license = licenses . unfree ;
platforms = platforms . all ;
2022-06-16 17:23:12 +00:00
sourceProvenance = with sourceTypes ; [ binaryBytecode ] ;
2024-05-15 15:35:15 +00:00
maintainers = with maintainers ; [ atila bryanasdev000 ] ;
2024-02-29 20:09:43 +00:00
mainProgram = " i r p f " ;
2022-03-30 09:31:56 +00:00
} ;
2024-07-27 06:49:29 +00:00
} )