flake build eureka and gateway

This commit is contained in:
2005 2024-05-27 18:34:24 +02:00
parent 977a943504
commit 3534dee0f4
4 changed files with 67 additions and 56 deletions

View file

@ -2,18 +2,17 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1716293225, "lastModified": 1716509168,
"narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=", "narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=",
"owner": "nixos", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916", "rev": "bfb7a882678e518398ce9a31a881538679f6f092",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "id": "nixpkgs",
"ref": "nixos-unstable", "ref": "nixos-unstable",
"repo": "nixpkgs", "type": "indirect"
"type": "github"
} }
}, },
"root": { "root": {

View file

@ -1,61 +1,73 @@
{ {
description = "Learning Pulse"; description = "CI, devshell and package definition for learningpulse";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; nixpkgs.url = "nixpkgs/nixos-unstable";
}; };
outputs = { self, nixpkgs, ... }:
outputs =
{ self
, nixpkgs
, maven
, makeWrapper
, stdenv
, ...
}:
let let
overlays = [
(final: prev: rec { # TODO add more systems
jdk = prev."jdk22"; system = "x86_64-linux";
maven = prev.maven.override { inherit jdk; }; 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 in
rec {
packages.${system} =
{ {
packages = { learningpulse-gateway = pkgs.maven.buildMavenPackage rec {
learningpulse-discovery = stdenv.mkDerivation rec {
pname = "gateway"; pname = "gateway";
version = "1.0"; version = "0.0.1";
src = ./.; src = ./.;
buildInputs = [ maven ]; # todo get automatically
mvnHash = "sha256-YCK1Qujgx73cZdEx2mRip+y+66px5TxL247fBIMyoy4=";
buildPhase = '' nativeBuildInputs = buildPackages;
mvn --offline -Dmaven.repo.local=gateway package;
'';
installPhase = '' installPhase = ''
install -Dm644 target/${pname}-${version}.jar $out/share/java 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"
''; '';
}; };
devShells = forEachSupportedSystem ({ pkgs }: { learningpulse-eureka = pkgs.maven.buildMavenPackage rec {
default = pkgs.mkShell { pname = "eureka";
packages = with pkgs; [ version = "0.0.1";
jdk
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 maven
jdk22
jre8
]; ];
}; };
});
};
}; };
} }

View file

@ -6,7 +6,6 @@
<groupId>com.learningpulse</groupId> <groupId>com.learningpulse</groupId>
<artifactId>server</artifactId> <artifactId>server</artifactId>
<version>0.0.1</version> <version>0.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<artifactId>gateway</artifactId> <artifactId>gateway</artifactId>
<version>0.0.1</version> <version>0.0.1</version>

1
result Symbolic link
View file

@ -0,0 +1 @@
/nix/store/v6lrgj18jgvwli3irsdabgj5nc712gfc-gateway-0.0.1