There is a file that someone has made, but I am trying to get on the flakes train and translate it into a usable flake.nix file that is also a shell. It comes with the challenge of compiling a file from a repository on github. If someone could help walk me through how to turn this would be great!

{ lib, stdenv, fetchurl, zlib, bzip2, lzma, perl, ncurses }:

stdenv.mkDerivation rec {
  version = "1.16.1";
  name = "samtools-${version}";

  src = fetchurl {
    url = "https://github.com/samtools/samtools/releases/download/${version}/${name}.tar.bz2";
    sha256 = "01qxvygvq6m7m3vhlysdw5g1qkx1c182vly90wyz4k2rg1gs581g";
  };

  buildInputs = [ zlib bzip2 lzma perl ncurses ];

  #patches = [ ./install-lib_1.13.patch ];

  doCheck = false;

  installPhase = ''
    make prefix=$out install
  '';

  meta = with lib; {
    description = "Tools for reading/writing/editing/indexing/viewing SAM/BAM/CRAM format";
    license     = licenses.free;
    homepage    = "http://www.htslib.org"; 
    platforms   = platforms.unix;
  };
}

For reference I am running NixOS on a 2020 Mac M1, so:

system: "aarch64-darwin"