From 6d4f7d3227e7765158c97bfd676a207ff98dfde0 Mon Sep 17 00:00:00 2001 From: nek0 Date: Fri, 20 Dec 2019 11:51:02 +0100 Subject: [PATCH] modernization --- affection.cabal | 2 +- default.nix | 18 +++++++ shell.nix | 123 +----------------------------------------------- 3 files changed, 21 insertions(+), 122 deletions(-) create mode 100644 default.nix diff --git a/affection.cabal b/affection.cabal index b0276a8..bd5ffc5 100644 --- a/affection.cabal +++ b/affection.cabal @@ -106,7 +106,7 @@ library , monad-loops , monad-parallel , containers - , clock + , clock >= 0.8 , glib , bytestring , OpenGL diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..4a89a74 --- /dev/null +++ b/default.nix @@ -0,0 +1,18 @@ +{ pkgs ? import (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz)) +, haskellCompiler ? "ghc865" +}: + pkgs.haskell-nix.cabalProject { + src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; }; + ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler}; + # pkg-def-extras = [ + # # Additional packages ontop of all those listed in `cabal.project` + # ]; + # modules = [ + # # Specific package overrides would go here for example: + # packages.cbors.package.ghcOptions = "-Werror"; + # packages.cbors.patches = [ ./one.patch ]; + # packages.cbors.flags.optimize-gmp = false; + # # It may be better to set flags in `cabal.project` instead + # # (`plan-to-nix` will include them as defaults). + # ]; + } diff --git a/shell.nix b/shell.nix index e616402..4d9f121 100644 --- a/shell.nix +++ b/shell.nix @@ -1,123 +1,4 @@ -{ 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, stdenv, text, vector - }: - mkDerivation { - pname = "nanovg"; - version = "0.6.0.0"; - src = ../nanovg-hs; - isLibrary = true; - isExecutable = true; - doCheck = false; - libraryHaskellDepends = [ base bytestring containers text vector ]; - librarySystemDepends = [ glew libGL libGLU ]; - libraryPkgconfigDepends = [ glew ]; - libraryToolDepends = [ c2hs ]; - testHaskellDepends = [ base containers hspec inline-c QuickCheck ]; - homepage = "https://github.com/cocreature/nanovg-hs"; - description = "Haskell bindings for nanovg"; - license = stdenv.lib.licenses.isc; - }) {}; - - glib = with haskellPackages; callPackage( - { mkDerivation, base, bytestring, Cabal, containers, glib - , stdenv, text, utf8-string - }: - mkDerivation { - pname = "glib"; - version = "0.13.6.0"; - sha256 = "4e71062c6a458440294d820e21449aa4666deed2ea233ef5915da7c1d4aee8eb"; - setupHaskellDepends = [ base Cabal gtk2hs-buildtools ]; - libraryHaskellDepends = [ - base bytestring containers text utf8-string - ]; - libraryPkgconfigDepends = [ pkgs.glib ]; - homepage = "http://projects.haskell.org/gtk2hs/"; - description = "Binding to the GLIB library for Gtk2Hs"; - license = stdenv.lib.licenses.lgpl21; - }) {}; - - gtk2hs-buildtools = with haskellPackages; callPackage( - { mkDerivation, alex, array, base, Cabal, containers, directory - , filepath, happy, hashtables, pretty, process, random, stdenv - }: - mkDerivation { - pname = "gtk2hs-buildtools"; - version = "0.13.4.0"; - src = ../gtk2hs/tools; - isLibrary = true; - isExecutable = true; - enableSeparateDataOutput = true; - libraryHaskellDepends = [ - array base Cabal containers directory filepath hashtables pretty - process random - ]; - libraryToolDepends = [ alex happy ]; - executableHaskellDepends = [ base ]; - homepage = "http://projects.haskell.org/gtk2hs/"; - description = "Tools to build the Gtk2Hs suite of User Interface libraries"; - license = stdenv.lib.licenses.gpl2; - }) {}; - - sdl2Nek0 = with haskellPackages; callPackage( - { mkDerivation, base, bytestring, deepseq, exceptions, linear, SDL2 - , StateVar, stdenv, text, transformers, vector, weigh - }: - mkDerivation { - pname = "sdl2"; - version = "2.4.1.0"; - sha256 = "21a569c0c19f8ff2bbe1cf1d3eb32f65e8143806de353cedd240df5e9d088b5c"; - isLibrary = true; - isExecutable = true; - enableSeparateDataOutput = true; - libraryHaskellDepends = [ - base bytestring exceptions linear StateVar text transformers vector - ]; - librarySystemDepends = [ SDL2 ]; - libraryPkgconfigDepends = [ SDL2 ]; - testHaskellDepends = [ base deepseq linear vector weigh ]; - doCheck = false; - description = "Both high- and low-level bindings to the SDL library (version 2.0.4+)."; - license = stdenv.lib.licenses.bsd3; - }) {}; - - f = { mkDerivation, base, bytestring, clock, containers, deepseq - , linear, matrix, monad-loops, monad-parallel, mtl - , OpenGL, random, 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 sdl2Nek0 stm text uuid vector - ]; - executableHaskellDepends = [ - base containers deepseq linear matrix nanovgNeko OpenGL random sdl2Nek0 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 {}); - + hsPkgs = import ./default.nix {}; in - - if pkgs.lib.inNixShell then drv.env else drv + hsPkgs.affection.components.all