Skip to content

Commit

Permalink
fix cargo run on nixos
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sodiboo authored and YaLTeR committed Aug 25, 2024
1 parent f86a9be commit dd919fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 10 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; [
Expand All @@ -68,6 +68,9 @@
stdenv.cc.cc.lib
pipewire
pango
cairo
glib
pixman
];

runtimeDependencies = with pkgs; [
Expand All @@ -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;
};
}
);
Expand Down

0 comments on commit dd919fe

Please sign in to comment.