Skip to content

Commit

Permalink
Set CPATH in shell.nix for clangd
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Feb 9, 2024
1 parent 7966a06 commit feb2025
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
sha256 = "0rkw9k98qy7ifwypkh2fqhdn7y2qphy2f8xjisj0cyp5pjja62im";
};

in import "${gotk4-nix}/${action}.nix" {
in import "${gotk4-nix}/${action}.nix" rec {
base = {
pname = "gotk4";
version = "dev";
Expand Down Expand Up @@ -44,4 +44,7 @@ in import "${gotk4-nix}/${action}.nix" {
})
];
};
passthru = {
inherit pkgs;
};
}
31 changes: 30 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
{}: import ./.nix { action = "shell"; }
{ }:

let
cPackages = [
"gtk4"
"gtk3"
];

shell = import ./.nix { action = "shell"; };
pkgs = shell.pkgs;
in

shell.overrideAttrs (old: {
shellHook = ''
${old.shellHook or ""}
for pkg in ${pkgs.lib.concatStringsSep " " cPackages}; do
__cpath=$(pkg-config $pkg --cflags-only-I | sed 's/ -I/:/g' | sed 's/^-I//')
if [[ $__cpath == "" ]]; then
continue
fi
if [[ -z $CPATH ]]; then
export CPATH=$__cpath
else
export CPATH=$CPATH:$__cpath
fi
done
'';
})

0 comments on commit feb2025

Please sign in to comment.