ソースを参照

Turn into Nix flake

Joeri Exelmans 2 年 前
コミット
6846c0dc6c
3 ファイル変更4007 行追加0 行削除
  1. 110 0
      flake.lock
  2. 53 0
      flake.nix
  3. 3844 0
      mvn2nix-lock.json

+ 110 - 0
flake.lock

@@ -0,0 +1,110 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1681202837,
+        "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "cfacdce06f30d2b68473a46042957675eebb3401",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "mvn2nix": {
+      "inputs": {
+        "nixpkgs": "nixpkgs",
+        "utils": "utils"
+      },
+      "locked": {
+        "lastModified": 1629170129,
+        "narHash": "sha256-v/HvYqzkPaGin1ujo+Fi59wXC9vWxW3lYVSwElORRi8=",
+        "owner": "fzakaria",
+        "repo": "mvn2nix",
+        "rev": "ea21cfe97069feee55fa307ca9b125616c1fa84f",
+        "type": "github"
+      },
+      "original": {
+        "owner": "fzakaria",
+        "repo": "mvn2nix",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1625176478,
+        "narHash": "sha256-s1RTYNKw7ySyqrZjns9Cq+Nnjpp75ePgL06pgcbIpoA=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "21b696caf392ad6fa513caf3327d0aa0430ffb72",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-21.05",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs_2": {
+      "locked": {
+        "lastModified": 1682109806,
+        "narHash": "sha256-d9g7RKNShMLboTWwukM+RObDWWpHKaqTYXB48clBWXI=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "2362848adf8def2866fabbffc50462e929d7fffb",
+        "type": "github"
+      },
+      "original": {
+        "id": "nixpkgs",
+        "type": "indirect"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "mvn2nix": "mvn2nix",
+        "nixpkgs": "nixpkgs_2"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
+    "utils": {
+      "locked": {
+        "lastModified": 1623875721,
+        "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}

+ 53 - 0
flake.nix

@@ -0,0 +1,53 @@
+{
+  inputs = {
+    mvn2nix.url = "github:fzakaria/mvn2nix";
+    flake-utils.url = "github:numtide/flake-utils";
+  };
+
+  outputs = { nixpkgs, mvn2nix, flake-utils, ... }:
+    flake-utils.lib.eachDefaultSystem (system:
+      let
+        pkgs = (import nixpkgs {
+          overlays = [ mvn2nix.overlay ];
+          inherit system;
+        });
+
+        mavenRepository = pkgs.buildMavenRepositoryFromLockFile {
+          file = ./mvn2nix-lock.json;
+        };
+      in rec {
+        packages = rec {
+          wee = pkgs.stdenv.mkDerivation rec {
+            pname = "wee";
+            version = "0.0.1-SNAPSHOT";
+            name = "${pname}-${version}";
+            src = pkgs.nix-gitignore.gitignoreSource [ "*.nix" ] ./.;
+            nativeBuildInputs = [
+              pkgs.makeWrapper
+            ];
+            buildPhase = ''
+              echo "Building with maven repository ${mavenRepository}"
+              ${pkgs.maven}/bin/mvn package --offline -Dmaven.repo.local=${mavenRepository}
+            '';
+            installPhase = ''
+              # create the bin directory
+              mkdir -p $out/bin
+
+              # create a symbolic link for the lib directory
+              ln -s ${mavenRepository} $out/lib
+
+              # copy out the JAR
+              # Maven already setup the classpath to use m2 repository layout
+              # with the prefix of lib/
+              cp target/${name}.jar $out/
+
+              # create a wrapper that will automatically set the classpath
+              # this should be the paths from the dependency derivation
+              makeWrapper ${pkgs.jdk11_headless}/bin/java $out/bin/${pname} \
+                    --add-flags "-jar $out/${name}.jar"
+            '';
+          };
+        };
+        defaultPackage = packages.wee;
+      });
+}

ファイルの差分が大きいため隠しています
+ 3844 - 0
mvn2nix-lock.json