From dc3cec536896fa224e0ce340557aa02b8d98738f Mon Sep 17 00:00:00 2001 From: Aylur Date: Wed, 11 Sep 2024 14:48:53 +0000 Subject: add lua builder --- nix/lua.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 nix/lua.nix (limited to 'nix/lua.nix') diff --git a/nix/lua.nix b/nix/lua.nix new file mode 100644 index 0000000..36ab4e5 --- /dev/null +++ b/nix/lua.nix @@ -0,0 +1,58 @@ +defaults: { + pkgs ? defaults.pkgs, + astal ? defaults.astal, + name ? "astal-lua", + src, + extraLuaPackages ? (ps: []), + extraPacakges ? [], +}: let + lua = pkgs.lua.withPackages (ps: + (extraLuaPackages ps) + ++ [ + ps.lgi + (ps.luaPackages.toLuaModule (pkgs.stdenv.mkDerivation { + name = "astal"; + version = "0.1.0"; + src = "${astal}/core/lua"; + dontBuild = true; + installPhase = '' + mkdir -p $out/share/lua/${ps.lua.luaversion}/astal + cp -r astal/* $out/share/lua/${ps.lua.luaversion}/astal + ''; + })) + ]); + + nativeBuildInputs = with pkgs; [ + wrapGAppsHook + gobject-introspection + ]; + + buildInputs = + extraPacakges + ++ [ + lua + astal.packages.${pkgs.system}.default + ]; + + script = pkgs.writeScript "astal-lua" '' + #!${lua}/bin/lua + package.path = package.path .. ";${src}/?.lua" + require "app" + ''; +in + pkgs.stdenv.mkDerivation { + inherit nativeBuildInputs buildInputs src name; + + installPhase = '' + mkdir -p $out/bin + cp -r * $out/bin + cp ${script} $out/bin/${name} + chmod +x $out/bin/${name} + ''; + + preFixup = '' + gappsWrapperArgs+=( + --prefix PATH : ${pkgs.lib.makeBinPath extraPacakges} + ) + ''; + } -- cgit v1.2.3