diff --git a/README.md b/README.md index 6ad0336..37ee180 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,11 @@ Just trying it: `nix run github:house-of-vanity/tsunagi#tsunagi-cli -- --help`. `packages..tsunagi` (with the tray) and `tsunagi-cli` are also exported, along with `overlays.default`. +For development from a checkout, `nix develop` also exposes the tray's native +runtime libraries, including AppIndicator and graphics/windowing libraries. +Cargo-built binaries such as `target/debug/tsunagi-tray` can run directly inside +this shell, without installing the packaged wrapper. + ## Build from source Rust 1.91 or newer. diff --git a/flake.nix b/flake.nix index ac4a232..4906d4f 100644 --- a/flake.nix +++ b/flake.nix @@ -26,14 +26,26 @@ nixosModules.default = import ./nix/module.nix self; - devShells = forAllSystems (pkgs: { - default = pkgs.mkShell { - inputsFrom = [ self.packages.${pkgs.stdenv.hostPlatform.system}.tsunagi ]; - packages = [ - pkgs.rustfmt - pkgs.clippy - ]; - }; - }); + devShells = forAllSystems ( + pkgs: + let + trayPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.tsunagi; + in + { + default = pkgs.mkShell { + inputsFrom = [ trayPackage ]; + packages = [ + pkgs.rustfmt + pkgs.clippy + ] + ++ trayPackage.trayRuntimeLibs; + # Cargo binaries have no installed wrapper. Expose runtime-loaded + # libraries here too, while preserving the caller's library path. + shellHook = '' + export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath trayPackage.trayRuntimeLibs}:/run/opengl-driver/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + ''; + }; + } + ); }; } diff --git a/nix/package.nix b/nix/package.nix index 7cf1e05..87553b7 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -52,7 +52,10 @@ rustPlatform.buildRustPackage { # The suite opens real sockets and interfaces; it runs in CI instead. doCheck = false; - nativeBuildInputs = [ pkg-config ] ++ lib.optionals withTray [ + nativeBuildInputs = [ + pkg-config + ] + ++ lib.optionals withTray [ copyDesktopItems wrapGAppsHook3 ]; @@ -64,6 +67,10 @@ rustPlatform.buildRustPackage { dontWrapGApps = true; + # The development shell runs unwrapped Cargo binaries and needs the same + # dynamically loaded libraries as the installed tray wrapper. + passthru = { inherit trayRuntimeLibs; }; + postInstall = '' install -Dm644 dist/linux/50-tsunagi-resolved.rules \ "$out/share/doc/tsunagi/50-tsunagi-resolved.rules"