phoboslab / qoi

The “Quite OK Image Format” for fast, lossless image compression
MIT License
6.98k stars 330 forks source link

nixpkg file #265

Open Cloudef opened 1 year ago

Cloudef commented 1 year ago

For anyone looking for easy way to install this:

{ pkgs ? import <nixpkgs> {}, stdenv ? pkgs.stdenv, lib ? pkgs.lib, fetchFromGitHub ? pkgs.fetchFromGitHub, fetchurl ? pkgs.fetchurl }:

let
  stb_image = fetchurl {
    url = "https://raw.githubusercontent.com/nothings/stb/5736b15f7ea0ffb08dd38af21067c314d6a3aae9/stb_image.h";
    hash = "sha256-OOCMHFq4hpro1gXdrvqFrT/qJKKWT9Y6CZwMD3nHC8w=";
  };
  stb_image_write = fetchurl {
    url = "https://raw.githubusercontent.com/nothings/stb/5736b15f7ea0ffb08dd38af21067c314d6a3aae9/stb_image_write.h";
    hash = "sha256-y9XwrXqc9EaK/7NjVKHSM4A08sEkc88ajjIFPLaRSgU=";
  };
in stdenv.mkDerivation rec {
  pname = "qoiconv";
  version = "0.0.1";

  src = fetchFromGitHub {
    owner = "phoboslab";
    repo = "qoi";
    rev = "f6dffaf1e8170cdd79945a4fb60f6403e447e020";
    hash = "sha256-yxDvll2kJVnlkPnXqCTC5uRrJnntEhwtd3JqQiPzins=";
  };

  makeFlags = [ "conv" ];

  patchPhase = ''
    ln -s ${stb_image} stb_image.h
    ln -s ${stb_image_write} stb_image_write.h
    '';

  installPhase = ''
    install -Dm744 qoiconv $out/bin/qoiconv
    '';

  meta = with lib; {
    description = "The “Quite OK Image Format” for fast, lossless image compression";
    homepage = "https://github.com/phoboslab/qoi";
    license = licenses.mit;
    maintainers = with maintainers; [];
  };
}

Feel free to contribute into nixpkgs and become a maintainer if you want. (Would be nice if makefile had install rule that took in the usual PREFIX, and that stb headers were actually included in the repo)