From dd919fe01b7d235c8e23660732bf24aa4629c8b5 Mon Sep 17 00:00:00 2001 From: sodiboo Date: Sat, 24 Aug 2024 23:40:08 +0200 Subject: fix `cargo run` on nixos this boils down to adding some extra dependencies to the shell environment. they're also inherited from craneArgs because the ones from the package are actually transformed into the WRONG outputs of the packages. also refactors to use craneLib.devShell because it's somewhat cleaner. --- flake.lock | 12 ++++++------ flake.nix | 28 ++++++++++------------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index 2c87678e..fd42894c 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1722960479, - "narHash": "sha256-NhCkJJQhD5GUib8zN9JrmYGMwt4lCRp6ZVNzIiYCl0Y=", + "lastModified": 1724533099, + "narHash": "sha256-ZIDtvVQHoCkNoBlLUB3wmqbqCb0Es3DfdUGeDI/58aY=", "owner": "ipetkov", "repo": "crane", - "rev": "4c6c77920b8d44cd6660c1621dea6b3fc4b4c4f4", + "rev": "7543c8d76f91b8844e0f3b3cc347a72d8fb4b49e", "type": "github" }, "original": { @@ -77,11 +77,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1723572004, - "narHash": "sha256-U5gKtbKuPahB02iGeGHFPlKr/HqrvSsHlEDEXoVyaPc=", + "lastModified": 1724395761, + "narHash": "sha256-zRkDV/nbrnp3Y8oCADf5ETl1sDrdmAW6/bBVJ8EbIdQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "19674872444bb3e0768249e724d99c8649c3bd78", + "rev": "ae815cee91b417be55d43781eb4b73ae1ecc396c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index f8c4b63f..1e7c77bc 100644 --- a/flake.nix +++ b/flake.nix @@ -42,9 +42,9 @@ src = nixpkgs.lib.cleanSourceWith { src = craneLib.path ./.; filter = path: type: - (builtins.match "resources" path == null) || - ((craneLib.filterCargoSources path type) && - (builtins.match "niri-visual-tests" path == null)); + (builtins.match "resources" path == null) + || ((craneLib.filterCargoSources path type) + && (builtins.match "niri-visual-tests" path == null)); }; nativeBuildInputs = with pkgs; [ @@ -68,6 +68,9 @@ stdenv.cc.cc.lib pipewire pango + cairo + glib + pixman ]; runtimeDependencies = with pkgs; [ @@ -91,22 +94,11 @@ checks.niri = niri; packages.default = niri; - devShells.default = pkgs.mkShell.override {stdenv = pkgs.clangStdenv;} rec { - inherit (niri) LIBCLANG_PATH; - packages = niri.runtimeDependencies ++ niri.nativeBuildInputs ++ niri.buildInputs; - - # Force linking to libEGL, which is always dlopen()ed, and to - # libwayland-client, which is always dlopen()ed except by the - # obscure winit backend. - RUSTFLAGS = map (a: "-C link-arg=${a}") [ - "-Wl,--push-state,--no-as-needed" - "-lEGL" - "-lwayland-client" - "-Wl,--pop-state" - ]; + devShells.default = craneLib.devShell { + inputsFrom = [niri]; - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages; - PKG_CONFIG_PATH = pkgs.lib.makeLibraryPath packages; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (craneArgs.runtimeDependencies ++ craneArgs.nativeBuildInputs ++ craneArgs.buildInputs); + inherit (niri) LIBCLANG_PATH; }; } ); -- cgit