diff options
author | Aylur <[email protected]> | 2024-09-12 00:40:04 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-09-12 00:40:04 +0200 |
commit | 6c5d7659a75c093588117c4c28dd046409b3ac8f (patch) | |
tree | c120efe485c6d699d29480e12298c2cd7fe4626c /nix/lua.nix | |
parent | d203255ec20bb6e3b2917dd4aee53dee3a090137 (diff) | |
parent | 8b75dadc76274692988eb317d3cc6ce1aaa44780 (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.nix | 58 |
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}" + ]; + } |