flake.nix 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. {
  2. inputs = rec {
  3. nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
  4. flake-utils.url = "github:numtide/flake-utils";
  5. mvn2nix = {
  6. url = "github:fzakaria/mvn2nix";
  7. inputs.nixpkgs.follows = "nixpkgs";
  8. inputs.utils.follows = "flake-utils";
  9. };
  10. };
  11. outputs = { nixpkgs, mvn2nix, flake-utils, ... }:
  12. flake-utils.lib.eachDefaultSystem (system:
  13. let
  14. pkgs = (import nixpkgs {
  15. overlays = [ mvn2nix.overlay ];
  16. inherit system;
  17. });
  18. in rec {
  19. packages = rec {
  20. wee = pkgs.maven.buildMavenPackage rec {
  21. pname = "wee";
  22. version = "0.0.1";
  23. name = "${pname}-${version}";
  24. src = pkgs.nix-gitignore.gitignoreSource [ "*.nix" ] ./.;
  25. mvnHash = "sha256-PUUlNgRvBiZZVH3zxTmQW92nBo90nm+FSS1Ryw/0rB0=";
  26. nativeBuildInputs = [
  27. pkgs.makeWrapper
  28. ];
  29. installPhase = ''
  30. # create the bin directory
  31. mkdir -p $out/bin
  32. # copy out the JAR
  33. # Maven already setup the classpath to use m2 repository layout
  34. # with the prefix of lib/
  35. install -Dm644 target/${name}.jar $out/${name}.jar
  36. # create a wrapper that will automatically set the classpath
  37. # this should be the paths from the dependency derivation
  38. makeWrapper ${pkgs.jdk11_headless}/bin/java $out/bin/${pname} \
  39. --add-flags "-jar $out/${name}.jar"
  40. '';
  41. };
  42. };
  43. defaultPackage = packages.wee;
  44. });
  45. }