Skip to content

Commit

Permalink
Add Go version guard into shell.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Feb 11, 2024
1 parent cde742b commit e3c7699
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
16 changes: 13 additions & 3 deletions .nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ let
gotk4-nix = systemPkgs.fetchFromGitHub {
owner = "diamondburned";
repo = "gotk4-nix";
rev = "ad91dabf706946c4380d0a105f0937e4e8ffd75f";
sha256 = "0rkw9k98qy7ifwypkh2fqhdn7y2qphy2f8xjisj0cyp5pjja62im";
rev = "4eab6a0";
sha256 = "sha256-WsJ2Cf1hvKT3BUYYVxQ5rNMYi6z7NWccbSsw39lgqO8=";
};

minGoVersion =
with builtins;
elemAt (elemAt (split "go ([0-9][^\n]*)" (readFile ../go.mod)) 1) 0;

in import "${gotk4-nix}/${action}.nix" rec {
base = {
pname = "gotk4";
Expand All @@ -39,8 +43,14 @@ in import "${gotk4-nix}/${action}.nix" rec {
go =
let
upstreamPkgs = import "${gotk4-nix}/pkgs.nix" {};
go = upstreamPkgs.go;
in
upstreamPkgs.go;
with systemPkgs.lib;
assert assertMsg
(versionAtLeast go.version minGoVersion)
"go version ${go.version} is too old, need at least ${minGoVersion}";

go;
})
];
};
Expand Down
24 changes: 1 addition & 23 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
{ }:

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
'';
})
shell

0 comments on commit e3c7699

Please sign in to comment.