{ description = "gleamtk — Gleam controller + Relm4 foreign node (Erlang distribution POC)"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; outputs = { self, nixpkgs }: let systems = [ "x86_64-linux" "aarch64-linux" ]; forAllSystems = nixpkgs.lib.genAttrs systems; in { packages = forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; gleamtk-ui = pkgs.rustPlatform.buildRustPackage { pname = "gleamtk-ui"; version = "0.1.0"; src = ./ui; cargoLock.lockFile = ./ui/Cargo.lock; nativeBuildInputs = with pkgs; [ pkg-config wrapGAppsHook4 ]; buildInputs = with pkgs; [ gtk4 libadwaita adwaita-icon-theme hicolor-icon-theme ]; meta = with pkgs.lib; { description = "Relm4 foreign node controlled by Gleam over Erlang distribution"; license = licenses.mit; mainProgram = "gleamtk-ui"; platforms = platforms.linux; }; }; in { inherit gleamtk-ui; default = gleamtk-ui; } ); apps = forAllSystems (system: { default = { type = "app"; program = "${self.packages.${system}.gleamtk-ui}/bin/gleamtk-ui"; }; ui = { type = "app"; program = "${self.packages.${system}.gleamtk-ui}/bin/gleamtk-ui"; }; }); devShells = forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; in { default = pkgs.mkShell { name = "gleamtk"; packages = with pkgs; [ gleam beam.packages.erlang_27.erlang rebar3 rustc cargo rustfmt clippy pkg-config gtk4 libadwaita gsettings-desktop-schemas adwaita-icon-theme hicolor-icon-theme just ]; # wrapGAppsHook rewrites packaged bins; bare `cargo run` still needs # schema/icon paths from the shell (see shellHook). nativeBuildInputs = with pkgs; [ wrapGAppsHook4 ]; shellHook = '' export ERL_EPMD_ADDRESS=127.0.0.1 export GSETTINGS_SCHEMAS_PATH="${pkgs.gtk4}/share/gsettings-schemas/${pkgs.gtk4.name}:${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.libadwaita}/share/gsettings-schemas/${pkgs.libadwaita.name}''${GSETTINGS_SCHEMAS_PATH:+:$GSETTINGS_SCHEMAS_PATH}" export XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share:${pkgs.gtk4}/share:${pkgs.libadwaita}/share:${pkgs.adwaita-icon-theme}/share:${pkgs.hicolor-icon-theme}/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" echo "gleamtk dev shell" echo " just ui # start Relm4 foreign node" echo " just gleam # start Gleam controller" echo " just run # ui in bg + gleam (needs display)" echo " just smoke # headless dist handshake test" echo " nix build # package gleamtk-ui" ''; }; } ); formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); }; }