From 5275fc2606cddd4ae5dd6260cd40e7138f610b66 Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 28 Mar 2018 02:12:35 +0200 Subject: [PATCH] nixify --- shell.nix | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..30c2334 --- /dev/null +++ b/shell.nix @@ -0,0 +1,68 @@ +{ nixpkgs ? import {}, compiler ? "default", doBenchmark ? false }: + +let + + inherit (nixpkgs) pkgs; + + nanovgNeko = with haskellPackages; callPackage ({ + mkDerivation, base, bytestring, c2hs, containers, glew, hspec, + inline-c, libGL, libGLU, QuickCheck, text, vector, pkgconfig }: + mkDerivation { + pname = "nanovg"; + version = "0.5.2.0"; + #src = pkgs.fetchFromGitHub { + # owner = "nek0"; + # repo = "nanovg-hs"; + # rev = "21868dc2c8e6eae8e7c0962d22890a8f2522cab0"; + # sha256 = "0diyyajniyxzmg5za34crwwlajf40x8bplja6mbgv2syax5d446d"; + # fetchSubmodules = true; + #}; + src = ../nanovg-hs; + revision = "1"; + isLibrary = true; + isExecutable = true; + doCheck = false; + libraryHaskellDepends = [ base bytestring containers text vector ]; + librarySystemDepends = [ glew libGL libGLU pkgconfig ]; + libraryToolDepends = [ c2hs ]; + testHaskellDepends = [ base containers hspec inline-c QuickCheck ]; + homepage = "https://github.com/cocreature/nanovg-hs"; + description = "Haskell bindings for nanovg"; + license = pkgs.stdenv.lib.licenses.isc; + hydraPlatforms = pkgs.stdenv.lib.platforms.none; + }) { inherit (pkgs) glew; inherit (pkgs) libGL; inherit (pkgs) libGLU; inherit (pkgs) pkgconfig; }; + + f = { mkDerivation, base, bytestring, clock, containers, deepseq + , glib, linear, matrix, monad-loops, monad-parallel, mtl + , OpenGL, random, sdl2, stdenv, stm, text, uuid, vector + }: + mkDerivation { + pname = "affection"; + version = "0.0.0.9"; + src = ./.; + configureFlags = [ "-fexamples" ]; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + base bytestring clock containers glib linear monad-loops + monad-parallel mtl OpenGL sdl2 stm text uuid vector + ]; + executableHaskellDepends = [ + base containers deepseq linear matrix nanovgNeko OpenGL random sdl2 stm + ]; + homepage = "https://github.com/nek0/affection#readme"; + description = "A simple Game Engine using SDL"; + license = stdenv.lib.licenses.lgpl3; + }; + + haskellPackages = if compiler == "default" + then pkgs.haskellPackages + else pkgs.haskell.packages.${compiler}; + + variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; + + drv = variant (haskellPackages.callPackage f {}); + +in + + if pkgs.lib.inNixShell then drv.env else drv