summaryrefslogtreecommitdiff
path: root/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
parentd203255ec20bb6e3b2917dd4aee53dee3a090137 (diff)
parent8b75dadc76274692988eb317d3cc6ce1aaa44780 (diff)
Merge pull request #5 from Aylur/nix/lua-builder
lua example, nix builder
Diffstat (limited to 'nix')
-rw-r--r--nix/devshell.nix57
-rw-r--r--nix/lua.nix58
2 files changed, 115 insertions, 0 deletions
diff --git a/nix/devshell.nix b/nix/devshell.nix
new file mode 100644
index 0000000..936f4b4
--- /dev/null
+++ b/nix/devshell.nix
@@ -0,0 +1,57 @@
+{
+ self,
+ pkgs,
+}: let
+ lua = pkgs.lua.withPackages (ps: [
+ ps.lgi
+ (ps.luaPackages.toLuaModule (pkgs.stdenv.mkDerivation {
+ name = "astal";
+ src = "${self}/core/lua";
+ dontBuild = true;
+ installPhase = ''
+ mkdir -p $out/share/lua/${ps.lua.luaversion}/astal
+ cp -r astal/* $out/share/lua/${ps.lua.luaversion}/astal
+ '';
+ }))
+ ]);
+
+ python = pkgs.python3.withPackages (ps: [
+ ps.pygobject3
+ ps.pygobject-stubs
+ ]);
+
+ buildInputs = with pkgs; [
+ wrapGAppsHook
+ gobject-introspection
+ meson
+ pkg-config
+ ninja
+ vala
+ gtk3
+ gtk-layer-shell
+ json-glib
+ pam
+ gvfs
+ networkmanager
+ gdk-pixbuf
+ wireplumber
+ libdbusmenu-gtk3
+ wayland
+
+ dart-sass
+ lua
+ python
+ gjs
+ ];
+in {
+ default = pkgs.mkShell {
+ inherit buildInputs;
+ };
+ astal = pkgs.mkShell {
+ buildInputs =
+ buildInputs
+ ++ builtins.attrValues (
+ builtins.removeAttrs self.packages.${pkgs.system} ["docs"]
+ );
+ };
+}
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}"
+ ];
+ }