summaryrefslogtreecommitdiff
path: root/nix/lua.nix
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-09-12 00:40:04 +0200
committerGitHub <[email protected]>2024-09-12 00:40:04 +0200
commit6c5d7659a75c093588117c4c28dd046409b3ac8f (patch)
treec120efe485c6d699d29480e12298c2cd7fe4626c /nix/lua.nix
parentd203255ec20bb6e3b2917dd4aee53dee3a090137 (diff)
parent8b75dadc76274692988eb317d3cc6ce1aaa44780 (diff)
Merge pull request #5 from Aylur/nix/lua-builder
lua example, nix 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..a790021
--- /dev/null
+++ b/nix/lua.nix
@@ -0,0 +1,58 @@
+defaults: {
+ pkgs ? defaults.pkgs,
+ astal ? defaults.astal,
+ name ? "astal-lua",
+ src,
+ extraLuaPackages ? (ps: []),
+ extraPackages ? [],
+}: 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
+ '';
+ }))
+ ]);
+
+ script = ''
+ #!${lua}/bin/lua
+ package.path = package.path .. ";${src}/?.lua"
+ require "app"
+ '';
+in
+ pkgs.stdenvNoCC.mkDerivation {
+ inherit src name;
+
+ nativeBuildInputs = with pkgs; [
+ wrapGAppsHook
+ gobject-introspection
+ ];
+
+ buildInputs =
+ extraPackages
+ ++ [
+ lua
+ astal.packages.${pkgs.system}.default
+ ];
+
+ installPhase = ''
+ runHook preInstall
+ mkdir -p $out/bin
+ cp -r * $out/bin
+ echo '${script}' > astal-lua
+ install -m 755 astal-lua $out/bin/${name}
+ runHook postInstall
+ '';
+
+ gappsWrapperArgs = [
+ "--prefix PATH : ${pkgs.lib.makeBinPath extraPackages}"
+ ];
+ }