summaryrefslogtreecommitdiff
path: root/nix/lua.nix
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-09-11 14:48:53 +0000
committerAylur <[email protected]>2024-09-11 14:48:53 +0000
commitdc3cec536896fa224e0ce340557aa02b8d98738f (patch)
tree9dcc2f5c3ca3d8d4b16fb0435d203a869249fb48 /nix/lua.nix
parent137345755c1c02d4766f1788198096013df9080c (diff)
add lua builder
Diffstat (limited to 'nix/lua.nix')
-rw-r--r--nix/lua.nix58
1 files changed, 58 insertions, 0 deletions
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}
+ )
+ '';
+ }