From fbfa29a8676b07203801c83e184c0bb0652a2827 Mon Sep 17 00:00:00 2001
From: 4o1x5 <4o1x5@4o1x5.dev>
Date: Fri, 24 May 2024 09:37:55 +0200
Subject: [PATCH 1/3] tryna build with java
---
flake.nix | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/flake.nix b/flake.nix
index 538215b..87c1ca3 100644
--- a/flake.nix
+++ b/flake.nix
@@ -10,32 +10,47 @@
, nixpkgs
, maven
, makeWrapper
+ , ...
}:
let
- javaVersion = 22;
overlays = [
(final: prev: rec {
- jdk = prev."jdk${toString javaVersion}";
- gradle = prev.gradle.override { java = jdk; };
+ jdk = prev."jdk22";
maven = prev.maven.override { inherit jdk; };
})
];
- supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
+
+ supportedSystems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ ];
+
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit overlays system; };
});
in
{
- hydraJobs = {
- gateway = maven.buildMavenPackage rec {
- pname = "learningpulse-gateway";
- version = "1.2.1";
- #
- # hello i wrote something here to test pulling
+ packages = {
+
+ learningpulse-discovery = with lib; maven.buildMavenPackage {
+ pname = "learningpulse-discovery";
+ version = "1.1.1";
+
+ src = ./eurika;
+ # todo get hash from package
+ mvnHash = lib.fakeSha256;
+ nativeBuildInputs = [ makeWrapper ];
+
+ installPhase = ''
+ mkdir -p $out/bin $out/share/jd-cli
+ install -Dm644 jd-cli/target/jd-cli.jar $out/share/jd-cli
+
+ makeWrapper ${nixpkgs.pkgs.jre8}/bin/java $out/bin/jd-cli \
+ --add-flags "-jar $out/share/jd-cli/jd-cli.jar"
+ '';
};
};
-
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
--
2.44.1
From 9b23cd16c277b1b425966b4c71926c788084f3ce Mon Sep 17 00:00:00 2001
From: 4o1x5 <4o1x5@4o1x5.dev>
Date: Sat, 25 May 2024 16:33:17 +0200
Subject: [PATCH 2/3] switched to mkderivation
---
flake.nix | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/flake.nix b/flake.nix
index 87c1ca3..3e8f8db 100644
--- a/flake.nix
+++ b/flake.nix
@@ -10,6 +10,7 @@
, nixpkgs
, maven
, makeWrapper
+ , stdenv
, ...
}:
let
@@ -32,32 +33,29 @@
in
{
packages = {
+ learningpulse-discovery = stdenv.mkDerivation rec {
+ pname = "gateway";
+ version = "1.0";
- learningpulse-discovery = with lib; maven.buildMavenPackage {
- pname = "learningpulse-discovery";
- version = "1.1.1";
+ src = ./.;
+ buildInputs = [ maven ];
- src = ./eurika;
- # todo get hash from package
- mvnHash = lib.fakeSha256;
- nativeBuildInputs = [ makeWrapper ];
+ buildPhase = ''
+ mvn --offline -Dmaven.repo.local=gateway package;
+ '';
installPhase = ''
- mkdir -p $out/bin $out/share/jd-cli
- install -Dm644 jd-cli/target/jd-cli.jar $out/share/jd-cli
-
- makeWrapper ${nixpkgs.pkgs.jre8}/bin/java $out/bin/jd-cli \
- --add-flags "-jar $out/share/jd-cli/jd-cli.jar"
+ install -Dm644 target/${pname}-${version}.jar $out/share/java
'';
};
+ devShells = forEachSupportedSystem ({ pkgs }: {
+ default = pkgs.mkShell {
+ packages = with pkgs; [
+ jdk
+ maven
+ ];
+ };
+ });
};
- devShells = forEachSupportedSystem ({ pkgs }: {
- default = pkgs.mkShell {
- packages = with pkgs; [
- jdk
- maven
- ];
- };
- });
};
}
--
2.44.1
From 3534dee0f47ce5637fb62de8932ddd6db32f6c04 Mon Sep 17 00:00:00 2001
From: 4o1x5 <4o1x5@4o1x5.dev>
Date: Mon, 27 May 2024 18:34:24 +0200
Subject: [PATCH 3/3] flake build eureka and gateway
---
flake.lock | 13 +++---
flake.nix | 108 +++++++++++++++++++++++++++---------------------
gateway/pom.xml | 1 -
result | 1 +
4 files changed, 67 insertions(+), 56 deletions(-)
create mode 120000 result
diff --git a/flake.lock b/flake.lock
index e6e6355..8af82e3 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,18 +2,17 @@
"nodes": {
"nixpkgs": {
"locked": {
- "lastModified": 1716293225,
- "narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=",
- "owner": "nixos",
+ "lastModified": 1716509168,
+ "narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=",
+ "owner": "NixOS",
"repo": "nixpkgs",
- "rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916",
+ "rev": "bfb7a882678e518398ce9a31a881538679f6f092",
"type": "github"
},
"original": {
- "owner": "nixos",
+ "id": "nixpkgs",
"ref": "nixos-unstable",
- "repo": "nixpkgs",
- "type": "github"
+ "type": "indirect"
}
},
"root": {
diff --git a/flake.nix b/flake.nix
index 3e8f8db..8aa25c1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,61 +1,73 @@
{
- description = "Learning Pulse";
-
+ description = "CI, devshell and package definition for learningpulse";
inputs = {
- nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
+ nixpkgs.url = "nixpkgs/nixos-unstable";
};
-
- outputs =
- { self
- , nixpkgs
- , maven
- , makeWrapper
- , stdenv
- , ...
- }:
+ outputs = { self, nixpkgs, ... }:
let
- overlays = [
- (final: prev: rec {
- jdk = prev."jdk22";
- maven = prev.maven.override { inherit jdk; };
- })
+
+ # TODO add more systems
+ system = "x86_64-linux";
+ pkgs = import nixpkgs { inherit system; };
+
+ buildPackages = with pkgs; [
+ jdk22
+ makeWrapper
];
-
- supportedSystems = [
- "x86_64-linux"
- "aarch64-linux"
- ];
-
- forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
- pkgs = import nixpkgs { inherit overlays system; };
- });
-
in
- {
- packages = {
- learningpulse-discovery = stdenv.mkDerivation rec {
- pname = "gateway";
- version = "1.0";
+ rec {
+ packages.${system} =
+ {
+ learningpulse-gateway = pkgs.maven.buildMavenPackage rec {
+ pname = "gateway";
+ version = "0.0.1";
- src = ./.;
- buildInputs = [ maven ];
+ src = ./.;
+ # todo get automatically
+ mvnHash = "sha256-YCK1Qujgx73cZdEx2mRip+y+66px5TxL247fBIMyoy4=";
- buildPhase = ''
- mvn --offline -Dmaven.repo.local=gateway package;
- '';
+ nativeBuildInputs = buildPackages;
- installPhase = ''
- install -Dm644 target/${pname}-${version}.jar $out/share/java
- '';
- };
- devShells = forEachSupportedSystem ({ pkgs }: {
- default = pkgs.mkShell {
- packages = with pkgs; [
- jdk
- maven
- ];
+ installPhase = ''
+ mkdir -p $out/bin $out/share/${pname}
+ install -Dm644 ${pname}/target/${pname}-${version}.jar $out/share/${pname}-${version}
+
+ makeWrapper ${pkgs.jre8}/bin/java $out/bin/${pname}- \
+ --add-flags "-jar $out/share/${pname}/${pname}-${version}.jar"
+ '';
};
- });
+ learningpulse-eureka = pkgs.maven.buildMavenPackage rec {
+ pname = "eureka";
+ version = "0.0.1";
+
+ src = ./.;
+ # todo get automatically
+ mvnHash = "sha256-YCK1Qujgx73cZdEx2mRip+y+66px5TxL247fBIMyoy4=";
+
+ nativeBuildInputs = buildPackages;
+
+ installPhase = ''
+ mkdir -p $out/bin $out/share/${pname}
+ install -Dm644 ${pname}/target/${pname}-${version}.jar $out/share/${pname}-${version}
+
+ makeWrapper ${pkgs.jre8}/bin/java $out/bin/${pname}- \
+ --add-flags "-jar $out/share/${pname}/${pname}-${version}.jar"
+ '';
+ };
+
+ };
+ hydraJobs = {
+ inherit (self)
+ packages;
+ };
+
+ devShells."${system}".default = pkgs.mkShell {
+ buildInputs = with pkgs; [
+ maven
+ jdk22
+ jre8
+ ];
};
};
+
}
diff --git a/gateway/pom.xml b/gateway/pom.xml
index 018a68c..3ee47aa 100644
--- a/gateway/pom.xml
+++ b/gateway/pom.xml
@@ -6,7 +6,6 @@
com.learningpulse
server
0.0.1
-
gateway
0.0.1
diff --git a/result b/result
new file mode 120000
index 0000000..6be4ed6
--- /dev/null
+++ b/result
@@ -0,0 +1 @@
+/nix/store/v6lrgj18jgvwli3irsdabgj5nc712gfc-gateway-0.0.1
\ No newline at end of file
--
2.44.1