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

hmetis package #42745

Closed
wants to merge 17 commits into from
Closed

hmetis package #42745

wants to merge 17 commits into from

Conversation

fragamus
Copy link
Contributor

Motivation for this change

add hmetis package: hypergraph partitioning software needed for optimization problems

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • [ x] 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)
  • Fits CONTRIBUTING.md.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

Also, the sources include a postscript manual and a user library libhmetis.a. The library would make sense to be installed in $out/lib.

And if you feel adventurous, you could try converting the manual to a man page, info page, and/or pdf. Then install that to $out/share/{man,info,doc}/hmetis :)

{ stdenv, fetchurl, patchelf }:

stdenv.mkDerivation rec {
name = "hmetis-${version}-i686";
Copy link
Member

Choose a reason for hiding this comment

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

The arch shouldn't be part of the name

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

name = "hmetis-${version}-i686";
version = "1.5";

buildInputs = [ patchelf ];
Copy link
Member

Choose a reason for hiding this comment

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

patchelf is included by default

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

url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/hmetis/hmetis-${version}-linux.tar.gz";
sha256 = "e835a098c046e9c26cecb8addfea4d18ff25214e49585ffd87038e72819be7e1";
};
src = [ hmetissrc ];
Copy link
Member

Choose a reason for hiding this comment

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

Use src = fetchurl { ... directly

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

};
src = [ hmetissrc ];

doCheck = true;
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't do anything

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

patchelf --set-rpath ${stdenv.glibc}/lib $out/bin/khmetis
cp shmetis $out/bin/
patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux.so.2 $out/bin/shmetis
patchelf --set-rpath ${stdenv.glibc}/lib $out/bin/shmetis
Copy link
Member

Choose a reason for hiding this comment

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

I'd think it would be more correct to put the patchelfing in patchPhase, then do only the moving (moving would be a bit faster than copying) to $out in installPhase. Also, you can use a for loop to not have to repeat yourself, and patchelf can take more flags at once:

for bin in hmetis khmetis shmetis; do
  patchelf --set-interpreter ... \
    --set-rpath ...
done

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

@infinisil
Copy link
Member

Here, use this diff to also compile the manual and install the static library (removes some trailing whitespace as well):

diff --git a/pkgs/applications/science/math/hmetis/default.nix b/pkgs/applications/science/math/hmetis/default.nix
index 76c98920240..9eab9ca3999 100644
--- a/pkgs/applications/science/math/hmetis/default.nix
+++ b/pkgs/applications/science/math/hmetis/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, ghostscript }:
 
 stdenv.mkDerivation rec {
   name = "hmetis-${version}";
@@ -9,10 +9,12 @@ stdenv.mkDerivation rec {
     sha256 = "e835a098c046e9c26cecb8addfea4d18ff25214e49585ffd87038e72819be7e1";
   };
 
+  nativeBuildInputs = [ ghostscript ];
+
   binaryFiles = "hmetis khmetis shmetis";
 
   patchPhase = ''
-    for binaryfile in $binaryFiles; do 
+    for binaryfile in $binaryFiles; do
       patchelf \
         --set-interpreter ${stdenv.glibc}/lib/ld-linux.so.2 \
         --set-rpath ${stdenv.glibc}/lib \
@@ -20,16 +22,20 @@ stdenv.mkDerivation rec {
     done
   '';
 
+  buildPhase = ''
+    gs -sOutputFile=manual.pdf -sDEVICE=pdfwrite -SNOPAUSE -dBATCH manual.ps
+  '';
+
   installPhase = ''
-    mkdir -p $out/bin
-    for binaryfile in $binaryFiles; do 
-      mv $binaryfile $out/bin
-    done
+    mkdir -p $out/bin $out/share/doc/hmetis $out/lib
+    mv $binaryFiles $out/bin
+    mv manual.pdf $out/share/doc/hmetis
+    mv libhmetis.a $out/lib
   '';
 
   meta = with stdenv.lib; {
     description = "hMETIS is a set of programs for partitioning hypergraphs";
-    homepage = http://glaros.dtc.umn.edu/gkhome/metis/hmetis/overview;  
+    homepage = http://glaros.dtc.umn.edu/gkhome/metis/hmetis/overview;
     license = licenses.unfree;
     platforms = [ "i686-linux" "x86_64-linux" ];
   };

Then the only thing I see left to do is squash all commits into one.

@infinisil
Copy link
Member

Now just squash all commits into one and name it "hmetis: init at 1.5"

@infinisil
Copy link
Member

It's important to know how to squash commits, please look up how to do that and continue this PR here instead of opening a new one (#42843). You can ask me if you have trouble with git.

@fragamus
Copy link
Contributor Author

fragamus commented Jul 1, 2018

I had such trouble that I deleted my fork and recreated it. I am not sure what to do to comply with your request, but the new fork by the same name now has one commit with everything.

@infinisil
Copy link
Member

Eh alright, feel free to ask next time if you struggle with git though ;). You should close this PR then.

@infinisil
Copy link
Member

Also, the one merging it could've done the squash for you.

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