diff --git a/flake.nix b/flake.nix index 586536cb..fbb66b56 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/nix/wgrib2.nix b/nix/wgrib2.nix new file mode 100644 index 00000000..76cb96df --- /dev/null +++ b/nix/wgrib2.nix @@ -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; + }; +} diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 350fad3b..2ba7ad7f 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -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