|
7 | 7 |
|
8 | 8 | outputs = { self, nixpkgs, flake-utils }: |
9 | 9 | let |
| 10 | + systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; |
| 11 | + forEachSystem = f: builtins.listToAttrs (map (system: { |
| 12 | + name = system; |
| 13 | + value = f system; |
| 14 | + }) systems); |
10 | 15 | in { |
11 | 16 | devShells = forEachSystem (system: |
12 | 17 | let |
|
20 | 25 | echo "Welcome to WalletLedgerExport" |
21 | 26 | ''; |
22 | 27 | }; |
23 | | - }); |
| 28 | + } |
| 29 | + ); |
| 30 | + packages = forEachSystem (system: { |
| 31 | + wallet-ledger-export = |
| 32 | + let |
| 33 | + pkgs = import nixpkgs { |
| 34 | + inherit system; |
| 35 | + }; |
| 36 | + mainProgram = "wallet-ledger-export"; |
| 37 | + gradle = pkgs.gradle_8; |
| 38 | + jre = pkgs.jdk21_headless; # JRE to run the example with |
| 39 | + self2 = pkgs.stdenv.mkDerivation (_finalAttrs: { |
| 40 | + pname = "wallet-ledger-export"; |
| 41 | + version = "0.0.2-SNAPSHOT"; |
| 42 | + meta = { |
| 43 | + inherit mainProgram; |
| 44 | + }; |
| 45 | + |
| 46 | + src = self; # project root is source |
| 47 | + |
| 48 | + nativeBuildInputs = [gradle pkgs.makeWrapper]; |
| 49 | + |
| 50 | + mitmCache = gradle.fetchDeps { |
| 51 | + pkg = self2; |
| 52 | + # update or regenerate this by running: |
| 53 | + # $(nix build .#wallet-ledger-export.mitmCache.updateScript --print-out-paths) |
| 54 | + data = ./nix-deps.json; |
| 55 | + }; |
| 56 | + |
| 57 | + gradleBuildTask = "ledger-export-tool:installDist"; |
| 58 | + |
| 59 | + gradleFlags = [ "--info --stacktrace" ]; |
| 60 | + |
| 61 | + # will run the gradleCheckTask (defaults to "test") |
| 62 | + doCheck = false; |
| 63 | + |
| 64 | + installPhase = '' |
| 65 | + mkdir -p $out/{bin,share/${mainProgram}/lib} |
| 66 | + cp ledger-export-tool/build/install/LedgerExport/lib/*.jar $out/share/${mainProgram}/lib |
| 67 | + # Compute CLASSPATH: all .jar files in $out/share/${mainProgram}/lib |
| 68 | + export MYPATH=$(find $out/share/${mainProgram}/lib -name "*.jar" -printf ':%p' | sed 's|^:||') # Colon-separated, no leading : |
| 69 | +
|
| 70 | + makeWrapper ${jre}/bin/java $out/bin/${mainProgram} \ |
| 71 | + --add-flags "-cp $MYPATH org.consensusj.ledgerexport.tool.WalletAccountingExport" \ |
| 72 | + ''; |
| 73 | + }); |
| 74 | + in |
| 75 | + self2; |
| 76 | + }); |
24 | 77 | }; |
25 | 78 | } |
0 commit comments