How can I add a module for OpenSSL?

There’s this project that I want to install.

It is a module that allows openssl to work with russian national standart ciphers (GOST). The result of its compilation is an openssl module, that it then tries to add to the directory where other modules are stored, before promptly failing because the nix-store is read-only.

How can I install this additional module “the nix way”?

I have tried writing the followind build script

let 

  nixpkgs = import <nixpkgs> {};
  inherit (nixpkgs) stdenv git cmake openssl;

  gost-engine = stdenv.mkDerivation {
    name = "gost-engine";

    buildInputs = [git cmake openssl];

    src = builtins.fetchGit {
      "url" = "https://github.com/gost-engine/engine.git";
      "rev" = "2a8a5e0ecaa3e3d6f4ec722a49aa72476755c2b7";
      submodules = true;
    };

    cmakeFlags = [
      "-DOPENSSL_ENGINES_DIR=${openssl}/lib/engines-3"
    ];

    buildPhase = ''
      cmake -DCMAKE_BUILD_TYPE=Release  ..
      cmake --build . --config Release
    '';
  };

in gost-engine

and it fails with this error