summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.nix5
-rw-r--r--nix/lua.nix58
2 files changed, 63 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
index 000ded1..a975e78 100644
--- a/flake.nix
+++ b/flake.nix
@@ -29,6 +29,11 @@
outputs = ["out" "dev"];
};
in {
+ mkLuaPackage = import ./nix/lua.nix {
+ inherit pkgs;
+ astal = self;
+ };
+
packages.${system} = with pkgs; {
docs = import ./docs {inherit self pkgs;};
default = self.packages.${system}.astal;
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}
+ )
+ '';
+ }