From 3c5b114c564ecb28e1ed3303146f0a059295c5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?=
Date: Mon, 3 Jul 2023 04:41:09 +0200 Subject: [PATCH] Include xP and xS in the xK derivation --- xK-master.nix | 56 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/xK-master.nix b/xK-master.nix index 487bd7e..9e181e9 100644 --- a/xK-master.nix +++ b/xK-master.nix @@ -10,6 +10,8 @@ pkgs.stdenv.mkDerivation rec { cmake pkg-config perl + ] ++ lib.optionals full [ + makeWrapper ]; buildInputs = with pkgs; [ @@ -24,8 +26,6 @@ pkgs.stdenv.mkDerivation rec { libedit ]; - # TODO: Try to integrate xP in the build. - # That might need a separate package. See https://nixos.wiki/wiki/Go. src = if local then builtins.path { path = ../${pname}/git; @@ -45,10 +45,60 @@ pkgs.stdenv.mkDerivation rec { "-DWANT_LIBEDIT=ON" ]; + xP = pkgs.buildGoModule rec { + pname = "xP"; + inherit version src doCheck meta; + + modRoot = "./${pname}/"; +# vendorHash = pkgs.lib.fakeHash; + vendorHash = "sha256-TK3rivjzYZwG8bfia22iQO5ZKnBzeIidsHNl6jnQUio="; + + mithril = pkgs.fetchurl { + url = "https://unpkg.com/mithril@2.2.3/mithril.js"; + sha256 = "sha256-136Ow56fShnPfIrUvyjg4oR7tHXyGUkdzThYm+940AY="; + }; + + # This invokes a premature build that may miss compiler flags. + preBuild = '' + cp ${mithril} public/mithril.js + make + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib/xP $out/share/xP + mv $GOPATH/bin/xP $out/lib/xP/ + cp -r public/ $out/share/xP/ + + runHook postInstall + ''; + }; + + xS = pkgs.buildGoModule rec { + pname = "xS"; + inherit version src doCheck meta; + + modRoot = "./${pname}/"; + vendorHash = null; + + # This invokes a premature build that may miss compiler flags. + preBuild = '' + make + ''; + }; + + # While we can't include them in this derivation, we can link to them. + postInstall = pkgs.lib.optionals full '' + makeWrapper ${xP}/lib/xP/xP $out/bin/xP --chdir ${xP}/share/xP/public + makeWrapper ${xS}/bin/xS $out/bin/xS + ''; + doCheck = true; meta = with pkgs.lib; { - description = "IRC daemon, bot, TUI client"; + description = "IRC daemon, bot, TUI client" + + optionals full " and its web frontend"; homepage = "https://git.janouch.name/p/${pname}"; platforms = platforms.all; license = licenses.bsd0;