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

asciiquarium: init at 1.1 #54224

Merged
merged 1 commit into from Jan 27, 2019
Merged

asciiquarium: init at 1.1 #54224

merged 1 commit into from Jan 27, 2019

Conversation

utdemir
Copy link
Member

@utdemir utdemir commented Jan 17, 2019

Motivation for this change

It's a cool terminal animation.

asciiquarium is a simple perl script which doesn't require anything to build, just putting perl and Term::Animation to the PATH looks enough.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@infinisil
Copy link
Member

Awesome package! Here's some suggested changes:

diff --git a/pkgs/applications/misc/asciiquarium/default.nix b/pkgs/applications/misc/asciiquarium/default.nix
index 52af1ff0234..912f18890b5 100644
--- a/pkgs/applications/misc/asciiquarium/default.nix
+++ b/pkgs/applications/misc/asciiquarium/default.nix
@@ -5,19 +5,18 @@ in stdenv.mkDerivation {
   name = "asciiquarium-${version}";
   src = fetchurl {
     url = "https://robobunny.com/projects/asciiquarium/asciiquarium_${version}.tar.gz";
-    sha256 = "sha256:0qfkr5b7sxzi973nh0h84blz2crvmf28jkkgaj3mxrr56mhwc20v";
+    sha256 = "0qfkr5b7sxzi973nh0h84blz2crvmf28jkkgaj3mxrr56mhwc20v";
   };

-  buildInputs = [ makeWrapper ];
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ perlPackages.perl ];

-  phases = "unpackPhase installPhase";
   installPhase = ''
     mkdir -p $out/bin
     cp asciiquarium $out/bin
     chmod +x $out/bin/asciiquarium
     wrapProgram $out/bin/asciiquarium \
-      --prefix PATH : ${perlPackages.perl}/bin/path \
-      --prefix PERL5LIB : ${perlPackages.makeFullPerlPath [ perlPackages.TermAnimation ] }
+      --set PERL5LIB ${perlPackages.makeFullPerlPath [ perlPackages.TermAnimation ] }
   '';

   meta = with stdenv.lib; {

Short explanations:

  • "sha256:" isn't needed
  • Because makeWrapper is called at build time, it should be in nativeBuildInputs (for cross compilation)
  • In nixpkgs, we usually patch shebangs directly instead of setting PATH, and this even happens automatically if you use standard phases (by not setting phases explicitly) and add perl to buildInputs. The package wouldn't work without this because I had a perl in $PATH already. This fixes it.
  • I --set PERL5LIB because there's no point in prefixing it

@utdemir
Copy link
Member Author

utdemir commented Jan 27, 2019

@infinisil Thank you very much for your suggestions and explanations, I really appreciate it!

Especially the patchShebangs phase. That looks really useful.

@infinisil
Copy link
Member

Awesome, now just squash the commits into one and I can merge this

@utdemir
Copy link
Member Author

utdemir commented Jan 27, 2019

Done, thanks!

@infinisil infinisil merged commit d79ec45 into NixOS:master Jan 27, 2019
@utdemir utdemir deleted the add-asciiquarium branch January 27, 2019 01:48
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

3 participants