wox: refactor derivation

- split sub-packages into separate derivations
- use finalAttrs
- inherit meta attributes
This commit is contained in:
eljamm 2026-06-09 17:34:17 +02:00
commit 262976908b
5 changed files with 204 additions and 140 deletions

View file

@ -1,22 +1,14 @@
{
lib,
stdenv,
fetchFromGitHub,
flutter341,
keybinder3,
callPackage,
nodejs,
pnpm_9,
fetchPnpmDeps,
pnpmConfigHook,
python3Packages,
writableTmpDirAsHomeHook,
buildGoModule,
pkg-config,
autoPatchelfHook,
libxtst,
libx11,
libxkbcommon,
xorgproto,
libayatana-appindicator,
gtk3,
desktop-file-utils,
@ -24,144 +16,24 @@
copyDesktopItems,
makeDesktopItem,
}:
let
buildGoModule (finalAttrs: {
pname = "wox";
version = "2.0.2";
src = fetchFromGitHub {
owner = "Wox-launcher";
repo = "Wox";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-Qav2RhmhJQr2D1D3okshIrnnQuOh7V1gWbZwXR3LBAc=";
};
metaCommon = {
description = "Cross-platform launcher that simply works";
homepage = "https://github.com/Wox-launcher/Wox";
license = with lib.licenses; [ gpl3Plus ];
maintainers = [ ];
};
ui-flutter = flutter341.buildFlutterApplication {
pname = "wox-ui-flutter";
inherit version src;
sourceRoot = "${src.name}/wox.ui.flutter/wox";
pubspecLock = lib.importJSON ./pubspec.lock.json;
postPatch = ''
substituteInPlace linux/runner/my_application.cc \
--replace-fail "X11/Xkeysym.h" "X11/keysym.h"
'';
nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [
keybinder3
xorgproto
libx11
libxtst
];
meta = metaCommon // {
mainProgram = "wox";
platforms = lib.platforms.linux;
};
};
plugin-host-nodejs = stdenv.mkDerivation (finalAttrs: {
pname = "wox-plugin-host-nodejs";
inherit version src;
sourceRoot = "${finalAttrs.src.name}/wox.plugin.host.nodejs";
nativeBuildInputs = [
nodejs
pnpmConfigHook
pnpm_9
];
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs)
pname
version
src
sourceRoot
;
pnpm = pnpm_9;
fetcherVersion = 3;
hash = "sha256-cbuVQV8ih8rztERFLUHGnK63MBz8+QVmzeegYLDwcj4=";
};
buildPhase = ''
runHook preBuild
pnpm run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm644 dist/index.js $out/node-host.js
runHook postInstall
'';
meta = metaCommon;
});
plugin-python = python3Packages.buildPythonApplication {
pname = "wox-plugin";
inherit version src;
pyproject = true;
sourceRoot = "${src.name}/wox.plugin.python";
build-system = with python3Packages; [ hatchling ];
meta = metaCommon;
};
plugin-host-python = python3Packages.buildPythonApplication {
pname = "wox-plugin-host-python";
inherit version src;
pyproject = true;
sourceRoot = "${src.name}/wox.plugin.host.python";
build-system = with python3Packages; [ hatchling ];
nativeBuildInputs = [ writableTmpDirAsHomeHook ];
buildInputs = with python3Packages; [
loguru
websockets
plugin-python
];
dependencies = with python3Packages; [
loguru
websockets
plugin-python
];
meta = metaCommon // {
mainProgram = "run";
};
};
in
buildGoModule {
pname = "wox";
inherit version src;
sourceRoot = "${src.name}/wox.core";
sourceRoot = "${finalAttrs.src.name}/wox.core";
postPatch = ''
substituteInPlace plugin/host/host_python.go \
--replace-fail 'n.findPythonPath(ctx), path.Join(util.GetLocation().GetHostDirectory(), "python-host.pyz")' '"env", "${plugin-host-python}/bin/run"'
--replace-fail \
'n.findPythonPath(ctx), path.Join(util.GetLocation().GetHostDirectory(), "python-host.pyz")' \
'"env", "${finalAttrs.passthru.plugin-host-python}/bin/run"'
substituteInPlace plugin/host/host_nodejs.go \
--replace-fail "/usr/bin/node" "${lib.getExe nodejs}"
substituteInPlace util/deeplink.go \
@ -199,8 +71,8 @@ buildGoModule {
preBuild = ''
mkdir -p resource/ui/flutter resource/hosts
cp -r ${ui-flutter}/app/${ui-flutter.pname} resource/ui/flutter/wox
cp ${plugin-host-nodejs}/node-host.js resource/hosts/node-host.js
cp -r ${finalAttrs.passthru.ui-flutter}/app/${finalAttrs.passthru.ui-flutter.pname} resource/ui/flutter/wox
cp ${finalAttrs.passthru.plugin-host-nodejs}/node-host.js resource/hosts/node-host.js
'';
# XOpenDisplay failure!
@ -220,8 +92,18 @@ buildGoModule {
install -Dm644 ../assets/app.png $out/share/icons/wox.png
'';
meta = metaCommon // {
passthru = {
plugin-host-nodejs = callPackage ./plugin-host-nodejs.nix { };
plugin-host-python = callPackage ./plugin-host-python.nix { };
ui-flutter = callPackage ./ui-flutter.nix { };
};
meta = {
description = "Cross-platform launcher that simply works";
homepage = "https://github.com/Wox-launcher/Wox";
mainProgram = "wox";
platforms = lib.platforms.linux;
license = with lib.licenses; [ gpl3Plus ];
maintainers = [ ];
};
}
})

View file

@ -0,0 +1,61 @@
{
lib,
stdenv,
wox,
fetchPnpmDeps,
nodejs,
pnpmConfigHook,
pnpm_9,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "wox-plugin-host-nodejs";
inherit (wox)
version
src
;
sourceRoot = "${finalAttrs.src.name}/wox.plugin.host.nodejs";
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs)
pname
version
src
sourceRoot
;
pnpm = pnpm_9;
fetcherVersion = 3;
hash = "sha256-cbuVQV8ih8rztERFLUHGnK63MBz8+QVmzeegYLDwcj4=";
};
nativeBuildInputs = [
nodejs
pnpmConfigHook
pnpm_9
];
buildPhase = ''
runHook preBuild
pnpm run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm644 dist/index.js $out/node-host.js
runHook postInstall
'';
meta = {
inherit (wox.meta)
description
homepage
license
maintainers
;
};
})

View file

@ -0,0 +1,46 @@
{
python3Packages,
callPackage,
wox,
writableTmpDirAsHomeHook,
}:
python3Packages.buildPythonApplication (finalAttrs: {
pname = "wox-plugin-host-python";
inherit (wox) version src;
pyproject = true;
sourceRoot = "${finalAttrs.src.name}/wox.plugin.host.python";
build-system = with python3Packages; [
hatchling
];
nativeBuildInputs = [
writableTmpDirAsHomeHook
];
buildInputs = with python3Packages; [
loguru
websockets
finalAttrs.passthru.plugin-python
];
dependencies = with python3Packages; [
loguru
websockets
finalAttrs.passthru.plugin-python
];
passthru = {
plugin-python = callPackage ./plugin-python.nix { };
};
meta = {
inherit (wox.meta)
description
homepage
license
maintainers
;
};
})

View file

@ -0,0 +1,27 @@
{
python3Packages,
wox,
}:
python3Packages.buildPythonApplication (finalAttrs: {
pname = "wox-plugin";
inherit (wox)
version
src
;
pyproject = true;
sourceRoot = "${finalAttrs.src.name}/wox.plugin.python";
build-system = with python3Packages; [
hatchling
];
meta = {
inherit (wox.meta)
description
homepage
license
maintainers
;
};
})

View file

@ -0,0 +1,48 @@
{
lib,
flutter341,
wox,
autoPatchelfHook,
keybinder3,
xorgproto,
libx11,
libxtst,
}:
flutter341.buildFlutterApplication (finalAttrs: {
pname = "wox-ui-flutter";
inherit (wox)
version
src
;
postPatch = ''
substituteInPlace linux/runner/my_application.cc \
--replace-fail "X11/Xkeysym.h" "X11/keysym.h"
'';
sourceRoot = "${finalAttrs.src.name}/wox.ui.flutter/wox";
pubspecLock = lib.importJSON ./pubspec.lock.json;
nativeBuildInputs = [
autoPatchelfHook
];
buildInputs = [
keybinder3
xorgproto
libx11
libxtst
];
meta = {
inherit (wox.meta)
description
homepage
mainProgram
platforms
license
maintainers
;
};
})