diff --git a/flake.nix b/flake.nix index a0b66a8..50779f0 100644 --- a/flake.nix +++ b/flake.nix @@ -44,22 +44,36 @@ // flake-utils.lib.eachDefaultSystem ( system: let - isDarwin = pkgs.stdenv.isDarwin; - pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; }; - commonBuildInputs = with pkgs; [ - openssl - ] - ++ lib.optionals (!isDarwin) [ - pkgs.udev + isDarwin = pkgs.stdenv.isDarwin; + + x11Libs = with pkgs; [ + libX11 + libXcursor + libXi + libXrandr + libxkbcommon ]; + commonBuildInputs = with pkgs; + [ + openssl + ] + ++ pkgs.lib.optionals (!isDarwin) ( + [ + udev + libGL + ] + ++ x11Libs + ); + commonNativeBuildInputs = with pkgs; [ pkg-config + makeWrapper ]; singerPackage = pkgs.rustPlatform.buildRustPackage { @@ -67,11 +81,15 @@ version = "0.1.0"; src = pkgs.lib.cleanSource ./.; - cargoLock.lockFile = ./Cargo.lock; nativeBuildInputs = commonNativeBuildInputs; buildInputs = commonBuildInputs; + + postFixup = pkgs.lib.optionalString (!isDarwin) '' + wrapProgram $out/bin/singer \ + --prefix LD_LIBRARY_PATH : "${pkgs.lib.makeLibraryPath commonBuildInputs}" + ''; }; in { @@ -86,7 +104,8 @@ }; devShells.default = pkgs.mkShell { - packages = (with pkgs; [ + packages = + (with pkgs; [ rustToolchain cargo-deny cargo-edit @@ -96,6 +115,8 @@ ++ commonBuildInputs ++ commonNativeBuildInputs; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath commonBuildInputs; + shellHook = '' export RUST_SRC_PATH="${pkgs.rustToolchain}/lib/rustlib/src/rust/library" '';