From 94cc68313402957892d859329bd6b4210a8dcb8e Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 27 Mar 2018 22:45:00 +0200 Subject: [PATCH] trying to make nix expressions --- default.nix | 21 +++++++++++++++++++++ haskelloids.cabal | 3 ++- haskelloids.nix | 17 +++++++++++++++++ shell.nix | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 default.nix create mode 100644 haskelloids.nix create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..d287b5e --- /dev/null +++ b/default.nix @@ -0,0 +1,21 @@ +{ compiler ? "ghc822" }: + let + config = { + packageOverrides = pkgs: with pkgs.haskell.lib; { + haskell = pkgs.haskell // { + packages = pkgs.haskell.packages // { + ${compiler} = pkgs.haskell.packages.${compiler}.override { + overrides = self: super: rec { + nanovg = + buildStrictly (self.callPackage ../nanovg-hs/nanovg.nix {}); + }; + }; + }; + }; + }; +}; +in + let + pkgs = import { inherit config; }; + nanovg = pkgs.haskell.packages.${compiler}.nanovg; +in { inherit nanovg; } diff --git a/haskelloids.cabal b/haskelloids.cabal index 845bf6d..0ccce77 100644 --- a/haskelloids.cabal +++ b/haskelloids.cabal @@ -51,7 +51,8 @@ executable haskelloids -- .hs or .lhs file containing the Main module. main-is: Main.hs ghc-options: -Wall - extra-libraries: GLEW + extra-libraries: GLEW + pkgconfig-depends: glew -- Modules included in this executable, other than Main. other-modules: Types diff --git a/haskelloids.nix b/haskelloids.nix new file mode 100644 index 0000000..f49b326 --- /dev/null +++ b/haskelloids.nix @@ -0,0 +1,17 @@ +{ mkDerivation, affection, base, containers, glew, linear +, nanovg, OpenGL, random, sdl2, stdenv, stm +}: +mkDerivation { + pname = "haskelloids"; + version = "0.0.0.1"; + src = ./.; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ + affection base containers linear nanovg OpenGL random sdl2 stm + ]; + executableSystemDepends = [ glew ]; + executablePkgconfigDepends = [ glew sdl2 ]; + description = "A little game using Affection"; + license = stdenv.lib.licenses.gpl3; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..1ff269f --- /dev/null +++ b/shell.nix @@ -0,0 +1,39 @@ +{ nixpkgs ? import {} +, compiler ? "default" +, doBenchmark ? false +, nanovg +}: + +let + + inherit (nixpkgs) pkgs; + + f = { mkDerivation, affection, base, containers, glew + , linear, nanovg, OpenGL, random, sdl2, stdenv, stm + }: + mkDerivation { + pname = "haskelloids"; + version = "0.0.0.1"; + src = ./.; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ + affection base containers linear nanovg OpenGL random sdl2 stm + ]; + executableSystemDepends = [ glew ]; + executablePkgconfigDepends = [ glew ]; + description = "A little game using Affection"; + license = stdenv.lib.licenses.gpl3; + }; + + 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