diff --git a/.gitignore b/.gitignore index 81dcf06..0a5dea4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ 100gex .direnv +result diff --git a/assets/100gex.desktop b/assets/100gex.desktop new file mode 100644 index 0000000..1291d82 --- /dev/null +++ b/assets/100gex.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Name=100gex +Comment=Fun-sized client for Rex +Exec=100gex +Icon=100gex +Categories=Development;TerminalEmulator; diff --git a/assets/100gex.svg b/assets/100gex.svg new file mode 100644 index 0000000..f1bf4ef --- /dev/null +++ b/assets/100gex.svg @@ -0,0 +1,35 @@ + + + + diff --git a/assets/100gex_src.svg b/assets/100gex_src.svg new file mode 100644 index 0000000..6099641 --- /dev/null +++ b/assets/100gex_src.svg @@ -0,0 +1,78 @@ + + + + diff --git a/flake.nix b/flake.nix index 0a6c56a..e1adf11 100644 --- a/flake.nix +++ b/flake.nix @@ -28,11 +28,76 @@ "aarch64-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + + # C libraries Gio builds against on Linux. + gioBuildInputs = + pkgs: with pkgs; [ + wayland + libxkbcommon + libGL + vulkan-headers + vulkan-loader + libx11 + libxcursor + libxfixes + libxcb + ]; + + # Libraries Gio loads at runtime (EGL, Vulkan), which must be findable. + gioRuntimeLibraryPath = + pkgs: + pkgs.lib.makeLibraryPath ( + with pkgs; + [ + libGL + vulkan-loader + wayland + libxkbcommon + libx11 + libxcursor + libxfixes + ] + ); in { - packages = forAllSystems (pkgs: { - inherit (ghostty.packages.${pkgs.stdenv.hostPlatform.system}) libghostty-vt; - }); + packages = forAllSystems ( + pkgs: + let + inherit (ghostty.packages.${pkgs.stdenv.hostPlatform.system}) libghostty-vt; + in + { + inherit libghostty-vt; + + default = pkgs.buildGoModule { + pname = "100gex"; + version = self.shortRev or self.dirtyShortRev or "dev"; + src = self; + vendorHash = "sha256-33wnqOt4PlcZkri6OcPoeHlyEs7CwEba3vBbftSi0uU="; + + subPackages = [ "." ]; + + nativeBuildInputs = with pkgs; [ + pkg-config + makeWrapper + ]; + buildInputs = gioBuildInputs pkgs ++ [ libghostty-vt ]; + + # The tests start Rex servers and open windows. + doCheck = false; + + # The binary is named 100gex, which Gio uses as the Wayland app_id + # and X11 class, so it matches the desktop entry and icon names. + postInstall = '' + install -Dm644 assets/100gex.desktop -t $out/share/applications + install -Dm644 assets/100gex.svg -t $out/share/icons/hicolor/scalable/apps + wrapProgram $out/bin/100gex \ + --prefix LD_LIBRARY_PATH : ${gioRuntimeLibraryPath pkgs} + ''; + + meta.mainProgram = "100gex"; + }; + } + ); devShells = forAllSystems (pkgs: { default = pkgs.mkShell { @@ -42,37 +107,14 @@ pkg-config ]; - # C libraries Gio builds against on Linux. - buildInputs = with pkgs; [ - wayland - libxkbcommon - libGL - vulkan-headers - vulkan-loader - libx11 - libxcursor - libxfixes - libxcb + buildInputs = gioBuildInputs pkgs ++ [ # Provides libghostty-vt.pc and libghostty-vt-static.pc for cgo. self.packages.${pkgs.stdenv.hostPlatform.system}.libghostty-vt ]; # Gio loads EGL and Vulkan at runtime; make the Nix-provided libraries findable. shellHook = '' - export LD_LIBRARY_PATH=${ - pkgs.lib.makeLibraryPath ( - with pkgs; - [ - libGL - vulkan-loader - wayland - libxkbcommon - libx11 - libxcursor - libxfixes - ] - ) - }''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} + export LD_LIBRARY_PATH=${gioRuntimeLibraryPath pkgs}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ''; }; });