Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

irpf: init at 2022-1.0 #163352

Merged
merged 1 commit into from
Mar 14, 2022
Merged

irpf: init at 2022-1.0 #163352

merged 1 commit into from
Mar 14, 2022

Conversation

AtilaSaraiva
Copy link
Contributor

Description of changes

I wrote this derivation to be able to use the software to write and submit income tax reports officially in my country, Brazil. I hope it can help my nix maniacs compatriots.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@hqurve hqurve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is the site guarded? (I am unable to access it)

in
stdenvNoCC.mkDerivation rec {
pname = "irpf";
version = "2.22.1.0";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version = "2.22.1.0";
version = "2022-1.0";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the review!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What website? the one for the pkgbuild or the homepage for the software?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://downloadirpf.receita.fazenda.gov.br/irpf/2022/irpf/arquivos/IRPF2022-1.0.zip

When i initially commented, I was getting a server not found error, so I assumed maybe they only allow downloads if its from brazil.

But now its working, (either my internet or the site was temporarily down)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh ok, this website is not the most stable for sure.

{ lib, stdenvNoCC, jdk11, makeWrapper, hicolor-icon-theme, fetchzip, fetchgit }:

let
year = "2022";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
year = "2022";

Comment on lines 15 to 17
src = fetchzip rec {
url = "https://downloadirpf.receita.fazenda.gov.br/irpf/${year}/irpf/arquivos/IRPF${year}-1.0.zip";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
src = fetchzip rec {
url = "https://downloadirpf.receita.fazenda.gov.br/irpf/${year}/irpf/arquivos/IRPF${year}-1.0.zip";
src = let
year = lib.head (lib.splitVersion version);
in fetchzip {
url = "https://downloadirpf.receita.fazenda.gov.br/irpf/${year}/irpf/arquivos/IRPF${version}.zip";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I didn't even know this was possible. Thx!

Comment on lines 31 to 33
cp -rf help "$BASEDIR/"
cp -rf lib "$BASEDIR/"
cp -rf lib-modulos "$BASEDIR/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cp -rf help "$BASEDIR/"
cp -rf lib "$BASEDIR/"
cp -rf lib-modulos "$BASEDIR/"
cp -rf help lib lib-modulos "$BASEDIR"

Also, would you mind adding a comment as to why the f flag is used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I just copied from the arch linux pkgbuild, but it seems indeed unecessary.

Comment on lines 36 to 39
install -Dm644 Leia-me.htm "$BASEDIR/"
install -Dm644 offline.png "$BASEDIR/"
install -Dm644 online.png "$BASEDIR/"
install -Dm644 pgd-updater.jar "$BASEDIR/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
install -Dm644 Leia-me.htm "$BASEDIR/"
install -Dm644 offline.png "$BASEDIR/"
install -Dm644 online.png "$BASEDIR/"
install -Dm644 pgd-updater.jar "$BASEDIR/"
install -Dm644 Leia-me.htm offline.png online.png pgd-updater "$BASEDIR"

(btw, i dont think trailing /'s matter here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx!

{ lib, stdenvNoCC, jdk11, makeWrapper, hicolor-icon-theme, fetchzip, fetchgit }:

let
pkgbuild = fetchgit rec {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pkgbuild = fetchgit rec {
pkgbuild = fetchgit {

in
stdenvNoCC.mkDerivation rec {
pname = "irpf";
version = "2022.1.0";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version = "2022.1.0";
version = "2022-1.0";

src = let
year = lib.head (lib.splitVersion version);
in fetchzip {
url = "https://downloadirpf.receita.fazenda.gov.br/irpf/${year}/irpf/arquivos/IRPF${year}-1.0.zip";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url = "https://downloadirpf.receita.fazenda.gov.br/irpf/${year}/irpf/arquivos/IRPF${year}-1.0.zip";
url = "https://downloadirpf.receita.fazenda.gov.br/irpf/${year}/irpf/arquivos/IRPF${version}.zip";

Comment on lines 38 to 40
--add-flags "-Dawt.useSystemAAFontSettings=on \
-Dswing.aatext=true \
-jar $BASEDIR/${pname}.jar" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--add-flags "-Dawt.useSystemAAFontSettings=on \
-Dswing.aatext=true \
-jar $BASEDIR/${pname}.jar" \
--add-flags "-Dawt.useSystemAAFontSettings=on" \
--add-flags "-Dswing.aatext=true" \
--add-flags "-jar $BASEDIR/${pname}.jar" \

I find this makes it more clear that these flags are not directly being added to makeWrapper

'';

meta = with lib; {
descriptions = "Programa Oficial da Receita para elaboração do IRPF";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
descriptions = "Programa Oficial da Receita para elaboração do IRPF";
description = "Programa Oficial da Receita para elaboração do IRPF";

ofborg detected this

--add-flags "-Dawt.useSystemAAFontSettings=on \
-Dswing.aatext=true \
-jar $BASEDIR/${pname}.jar" \
--prefix _JAVA_AWT_WM_NONREPARENTING=1 AWT_TOOLKIT=MToolkit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--prefix _JAVA_AWT_WM_NONREPARENTING=1 AWT_TOOLKIT=MToolkit
--set _JAVA_AWT_WM_NONREPARENTING 1 \
--set AWT_TOOLKIT MToolkit

see arguments here https://github.com/NixOS/nixpkgs/blob/c8b5c9526415905e90e3a64586ebecc55a2827dd/pkgs/build-support/setup-hooks/make-wrapper.sh.

Comment on lines 25 to 38
mkdir -p "$out/share/icons/hicolor/128x128/apps"
mkdir -p "$out/share/applications"
mkdir -p "$out/share/licenses/${pname}"
mkdir -p "$out/share/${pname}"
mkdir "$out/bin"
BASEDIR="$out/share/${pname}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p "$out/share/icons/hicolor/128x128/apps"
mkdir -p "$out/share/applications"
mkdir -p "$out/share/licenses/${pname}"
mkdir -p "$out/share/${pname}"
mkdir "$out/bin"
BASEDIR="$out/share/${pname}"
BASEDIR="$out/share/${pname}"
mkdir -p "$BASEDIR"

I think placing the mkdirs where needed is neater (also install -D makes directories when target directory is specified)


install -Dm755 irpf.jar "$BASEDIR/${pname}.jar"
install -Dm644 Leia-me.htm offline.png online.png pgd-updater.jar "$BASEDIR"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p $out/bin

Copy link
Contributor

@hqurve hqurve Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah indeed this isnt required makeWrapper does this. (my bad)

mkdir -p "$(dirname "$wrapper")"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, I actually discovered it by accident.

BASEDIR="$out/share/${pname}"

cp -r help lib lib-modulos "$BASEDIR"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines 43 to 45
install -Dm644 ${pkgbuild}/irpf.png $out/share/icons/hicolor/128x128/apps/
install -Dm644 ${pkgbuild}/irpf.desktop $out/share/applications/
install -Dm644 ${pkgbuild}/Copyright $out/share/licenses/${pname}/
Copy link
Contributor

@hqurve hqurve Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
install -Dm644 ${pkgbuild}/irpf.png $out/share/icons/hicolor/128x128/apps/
install -Dm644 ${pkgbuild}/irpf.desktop $out/share/applications/
install -Dm644 ${pkgbuild}/Copyright $out/share/licenses/${pname}/
install -Dtm644 $out/share/icons/hicolor/128x128/apps ${pkgbuild}/irpf.png
install -Dtm644 $out/share/applications ${pkgbuild}/irpf.desktop
install -Dtm644 $out/share/licenses/${pname} ${pkgbuild}/Copyright

This auto creates the directories

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this and it didn't work, but I implemented something that will.

@AtilaSaraiva
Copy link
Contributor Author

Thanks for the suggestions! I think I fixed it all. I was actually struggling on how to make the install phase smaller and u gave it to me, thx!

@AtilaSaraiva AtilaSaraiva reopened this Mar 8, 2022
@AtilaSaraiva
Copy link
Contributor Author

AtilaSaraiva commented Mar 8, 2022

Oh miss clicked the close button

{ lib, stdenvNoCC, jdk11, makeWrapper, hicolor-icon-theme, fetchzip, fetchgit }:

let
pkgbuild = fetchgit {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of life of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the review again Anderson, I was waiting for someone to ask as this has to do with the reproducibility of this derivation. There are three files I'm getting from the aur pkgbuild: copyright file, the desktop file and the desktop icon. I could forgo the first two since they are text files, as I could either hardcode them or use the proper tools like makeDesktopItem. However, the desktop icon should be hosted in a website whereas it can be fetched using the same url for at least 10 years. Having this in mind, fetching the icon from the government website seems prone to failure, as they can, and most likely will, change urls.

I thought about creating a personal github only for those three files but it seems unecessary whereas there is already a git repo (although from aur git) with those. I'm looking for a better solution, but this is what I've got so far.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish they just shipped the icon together with the program, but no.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can extract the icon from the application itself. For example the one on the splash screen

Screenshot from 2022-03-08 21-49-42

I've tried looking around in the main jar file, however I can only find low quality

logo_srf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be it, how did u get it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sincerely don't, but I can take a look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here. It is embedded in the website, any idea of how to get it?
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I looked a bit more and I found a file irpf.jar/IRPF-Licenses.txt the header of it reads

Termo Público de Cessão de Direito de Uso:
A Secretaria da Receita Federal do Brasil informa que o Programa
Aplicativo para Preenchimento da Declaração de Ajuste Anual do
Imposto de Renda de Pessoa Física do exercício de 2019, ano-calendário de 2018 (IRPF2019),
desenvolvido pelo SERPRO para a RFB, é objeto de propriedade intelectual da União
e tem seu uso licenciado para o contribuinte, para ser utilizado exclusivamente
para os fins a que se destina. Seu uso indiscriminado para finalidade
diversa sujeita o responsável às penas da lei.

.... I dont speak Portuguese ... but when I ran it through google translate, it was more or less the same except some clear contextual translation errors also.... the year is different.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you prefer to use a hard-coded one, its cool and how you have it already works well.

Also, the idea is get everything from one source (as far as possible), so reading an excerpt from a website (which is bad enough) is a no go.

Im also questioning if the copyright file is needed as its embedded in their jar file also ... what purpose does it serve?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U are being of such help that I cannot thank you enough. This small text is the same thing. I just thought that including thing would be necessary as far as licensing goes, but I guess that specifying that it is unfree might be enough, maybe I should just remove it.

mkdir -p $out/share/pixmaps
unzip -j lib/ppgd-icones-4.0.jar icones/rfb64.png -d $out/share/pixmaps

install -Dm644 ${desktopItem}/share/applications/irpf.desktop $out/share/applications/irpf.desktop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done haha.

Copy link
Contributor

@hqurve hqurve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find its good but im not a committer :p

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/459

pkgs/applications/finance/irpf/default.nix Outdated Show resolved Hide resolved
Comment on lines 14 to 23
nativeBuildInputs = [ makeWrapper copyDesktopItems ];
buildInputs = [ unzip ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nativeBuildInputs = [ makeWrapper copyDesktopItems ];
buildInputs = [ unzip ];
nativeBuildInputs = [ makeWrapper copyDesktopItems unzip ];

@AndersonTorres
Copy link
Member

@AtilaSaraiva PING

@AtilaSaraiva
Copy link
Contributor Author

Oh, sorry, gonna do.

@AtilaSaraiva
Copy link
Contributor Author

Done, and also made a rebase to solve the conflict with the master branch.

@hqurve
Copy link
Contributor

hqurve commented Mar 13, 2022

You forgot to move unzip to nativeBuildInputs

@AtilaSaraiva
Copy link
Contributor Author

Oh, u're right, I managed to fix it rn.

@AndersonTorres AndersonTorres changed the title irpf: init at 2022.1.0 irpf: init at 2022-1.0 Mar 13, 2022
@AndersonTorres
Copy link
Member

Last modification: edit the commit message

Use irpf: init at 2022-1.0

Instead of irpf: init at 2022.1.0

@AtilaSaraiva
Copy link
Contributor Author

Done, thx for the patience 🥇

@AndersonTorres AndersonTorres merged commit bb2820b into NixOS:master Mar 14, 2022
@AtilaSaraiva AtilaSaraiva deleted the irpf branch March 14, 2022 18:58
@github-actions
Copy link
Contributor

Backport failed for release-21.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin release-21.11
git worktree add -d .worktree/backport-163352-to-release-21.11 origin/release-21.11
cd .worktree/backport-163352-to-release-21.11
git checkout -b backport-163352-to-release-21.11
ancref=$(git merge-base aee602ac0ee907c7b7d0a15c815b29d098a0bbd7 899f1131d406ee4881b8e3962b14f06e2219cb87)
git cherry-pick -x $ancref..899f1131d406ee4881b8e3962b14f06e2219cb87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants