I’m tired of mvn2nix
I figured out how to get things working, but it requires non-trivial modifications to it, and I am not in a mmod to make them. Especially given that building OH from source doesn’t actually make much sense – mvn will “just” download the “built” dependencies anyhow…
This commit is contained in:
42
flake.lock
generated
Normal file
42
flake.lock
generated
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1676283394,
|
||||
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1677022426,
|
||||
"narHash": "sha256-dCFSTknONT7Rz5AYHEXrh4kpgSZjqjuu/lXJhJTiS78=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8260d35eb9212c4803a3c612a9f7e29c3434fde2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
15
flake.nix
15
flake.nix
@@ -2,24 +2,15 @@
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
openhab-distro = {
|
||||
url = "github:openhab/openhab-distro/3.4.2"; # OH-DISTRO-URL
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { flake-utils, nixpkgs, openhab-distro, ... }: flake-utils.lib.eachDefaultSystem (system: {
|
||||
outputs = { flake-utils, nixpkgs, ... }: flake-utils.lib.eachDefaultSystem (system: {
|
||||
packages = rec {
|
||||
jdk-openhab = nixpkgs.legacyPackages.${system}.jdk11;
|
||||
maven-openhab = nixpkgs.legacyPackages.${system}.maven.override { jdk = jdk-openhab; };
|
||||
openhab-repository = nixpkgs.legacyPackages.${system}.callPackage ./openhab-repository.nix {
|
||||
inherit openhab-distro;
|
||||
maven = maven-openhab;
|
||||
};
|
||||
openhab = nixpkgs.legacyPackages.${system}.callPackage ./openhab.nix {
|
||||
inherit openhab-distro openhab-repository jdk-openhab;
|
||||
maven = maven-openhab;
|
||||
inherit jdk-openhab;
|
||||
};
|
||||
openhab-addons = nixpkgs.legacyPackages.${system}.callPackage ./openhab-addons.nix {};
|
||||
default = openhab;
|
||||
};
|
||||
});
|
||||
|
||||
17594
mvn2nix-lock.json
17594
mvn2nix-lock.json
File diff suppressed because it is too large
Load Diff
@@ -1,16 +0,0 @@
|
||||
# Downloads various dependencies for the openhab build.
|
||||
{ lib, stdenv, maven, openhab-distro, fetchurl, linkFarm }:
|
||||
|
||||
let
|
||||
dependencies = (builtins.fromJSON (builtins.readFile ./mvn2nix-lock.json )).dependencies;
|
||||
dependenciesAsDrv = (lib.forEach (lib.attrValues dependencies) (dependency: {
|
||||
drv = fetchurl {
|
||||
url = dependency.url;
|
||||
sha256 = dependency.sha256;
|
||||
};
|
||||
layout = dependency.layout;
|
||||
}));
|
||||
in linkFarm "openhab-repository" (lib.forEach dependenciesAsDrv (dependency: {
|
||||
name = dependency.layout;
|
||||
path = dependency.drv;
|
||||
}))
|
||||
@@ -1 +0,0 @@
|
||||
sha256-po8EjHV8lPUOxkuOnZ5mQOODg+LAhgazfx7wW6Modqc=
|
||||
39
openhab.nix
39
openhab.nix
@@ -1,23 +1,24 @@
|
||||
{
|
||||
gawk,
|
||||
bash,
|
||||
coreutils,
|
||||
fetchurl,
|
||||
gawk,
|
||||
jdk-openhab,
|
||||
makeWrapper,
|
||||
lib,
|
||||
maven,
|
||||
openhab-distro,
|
||||
openhab-repository,
|
||||
makeWrapper,
|
||||
stdenv,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "openhab";
|
||||
version = openhab-distro.shortRev;
|
||||
src = openhab-distro;
|
||||
nativeBuildInputs = [ makeWrapper maven ];
|
||||
version = builtins.readFile ./version;
|
||||
src = fetchurl {
|
||||
url = "https://github.com/openhab/openhab-distro/releases/download/${version}/openhab-${version}.tar.gz";
|
||||
sha256 = builtins.readFile ./sha256;
|
||||
};
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ bash ];
|
||||
outputs = [ "out" "demo" ];
|
||||
outputs = [ "out" ];
|
||||
extraPath = lib.makeBinPath [ jdk-openhab gawk coreutils ];
|
||||
wrappedExecutables = [
|
||||
"start.sh"
|
||||
@@ -35,25 +36,15 @@ stdenv.mkDerivation rec {
|
||||
"runtime/bin/update"
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
echo "Using repository ${openhab-repository}"
|
||||
cp -r ${openhab-repository} ./repository
|
||||
chmod -R +rw ./repository
|
||||
mvn --offline -B -T $NIX_BUILD_CORES -Drelease -Dmaven.repo.local=./repository package
|
||||
|
||||
runHook postBuild
|
||||
unpackPhase = ''
|
||||
runHook preUnpack
|
||||
mkdir -p $out
|
||||
tar -C $out -xf $src
|
||||
runHook postUnpack
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir $out
|
||||
tar -C $out -xf distributions/openhab/target/openhab-3.4.2.tar.gz
|
||||
mv distributions/openhab-addons/target/openhab-addons-3.4.2.kar $out/addons/
|
||||
mkdir $demo
|
||||
tar -C $demo -xf distributions/openhab-demo/target/openhab-demo-3.4.2.tar.gz
|
||||
|
||||
rm -rfv \
|
||||
"$out/"*.bat \
|
||||
"$out/runtime/bin/"*.bat \
|
||||
|
||||
Reference in New Issue
Block a user