fix: add wgrib2 nix derivation and DataCase Req.Test shared mode
Some checks failed
Build and Push / Build and Push Docker Image (push) Failing after 13m8s

- nix/wgrib2.nix: build wgrib2 3.8.0 from source with NCEPLIBS-g2c 2.3.0,
  matching the Dockerfile.base build.
- flake.nix: wire wgrib2 derivation into dev shell so direnv loads it.
- DataCase: call Req.Test.set_req_test_from_context/1 in setup so
  async:false tests get shared Req.Test mode, making stubs visible
  to Tasks spawned by async_stream_nolink.
This commit is contained in:
Graham McIntire 2026-08-04 13:50:18 -05:00
parent ec1df7a4df
commit b8a255ac91
3 changed files with 105 additions and 3 deletions

View file

@ -37,8 +37,8 @@
system,
...
}:
{
_module.args.pkgs = import nixpkgs {
let
pkgs' = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
@ -57,9 +57,16 @@
];
};
# wgrib2 is compiled from source — not in nixpkgs
wgrib2 = pkgs'.callPackage ./nix/wgrib2.nix { };
in
{
_module.args.pkgs = pkgs';
# Development shell with PostgreSQL, Rust, Elixir LSP
devShells.default = pkgs.callPackage ./nix/shell.nix {
devShells.default = pkgs'.callPackage ./nix/shell.nix {
pre-commit-hooks = inputs.pre-commit-hooks.lib.${system};
inherit wgrib2;
};
# Nix formatter for flake files

90
nix/wgrib2.nix Normal file
View file

@ -0,0 +1,90 @@
{
stdenv,
lib,
cmake,
gfortran,
zlib,
libaec,
libpng,
openjpeg,
pkg-config,
fetchFromGitHub,
fetchurl,
}:
let
g2cVersion = "2.3.0";
g2c = stdenv.mkDerivation {
pname = "nceplibs-g2c";
version = g2cVersion;
src = fetchFromGitHub {
owner = "NOAA-EMC";
repo = "NCEPLIBS-g2c";
rev = "v${g2cVersion}";
hash = "sha256-9z0QipDqX5e/IgcK6y0q9ovja5jxwszLbWNUQQBIsss=";
};
nativeBuildInputs = [
cmake
pkg-config
];
buildInputs = [
zlib
libaec
libpng
openjpeg
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DUSE_PNG=ON"
"-DUSE_AEC=ON"
"-DUSE_OpenJPEG=ON"
"-DUSE_Jasper=OFF"
];
};
in
stdenv.mkDerivation {
pname = "wgrib2";
version = "3.8.0";
src = fetchFromGitHub {
owner = "NOAA-EMC";
repo = "wgrib2";
rev = "v3.8.0";
hash = "sha256-cJR8CdkAWYVj54saYjigqncKCFXHpekWZ4yAMdYHYYg=";
};
nativeBuildInputs = [
cmake
gfortran
];
buildInputs = [
zlib
libaec
libpng
openjpeg
g2c
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DUSE_AEC=ON"
"-DUSE_G2CLIB_LOW=ON"
# Help CMake find the g2c library from our local build
"-DCMAKE_PREFIX_PATH=${g2c}"
];
postInstall = ''
strip $out/bin/wgrib2
'';
meta = {
description = "Utility to read and write GRIB2 files";
homepage = "https://github.com/NOAA-EMC/wgrib2";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.linux;
};
}

View file

@ -32,6 +32,11 @@ defmodule Microwaveprop.DataCase do
Microwaveprop.DataCase.setup_sandbox(tags)
Microwaveprop.DataCase.reset_score_files()
Microwaveprop.DataCase.stub_nexrad_default()
# sync tests (async: false) need shared Req.Test mode so stubs
# are visible to Tasks spawned by async_stream_nolink.
Req.Test.set_req_test_from_context(tags)
:ok
end