From 5bef189c308df9dda1449a8305a7092fb5c77827 Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 1 Dec 2022 19:56:25 +0100 Subject: [PATCH] get working flake --- affection.cabal | 61 +++++++++++++++++++++++-------------------------- flake.nix | 49 +++++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 49 deletions(-) diff --git a/affection.cabal b/affection.cabal index c5772cf..a8f90b6 100644 --- a/affection.cabal +++ b/affection.cabal @@ -127,12 +127,11 @@ executable example00 ghc-options: -threaded -Wall default-language: Haskell2010 default-extensions: OverloadedStrings - if flag(examples) - build-depends: base >=4.9 && < 5 - , affection - , sdl2 >= 2.5 - , stm - else + build-depends: base >=4.9 && < 5 + , affection + , sdl2 >= 2.5 + , stm + if !flag(examples) buildable: False -- A small game of life implementation @@ -143,19 +142,18 @@ executable example01 ghc-options: -threaded -Wall default-language: Haskell2010 default-extensions: OverloadedStrings - if flag(examples) - build-depends: base >=4.9 && < 5 - , affection - , sdl2 >= 2.5 - , stm - , OpenGL - , random - , containers - , linear - , matrix - , nanovg >= 0.6.0.0 - , deepseq - else + build-depends: base >=4.9 && < 5 + , affection + , sdl2 >= 2.5 + , stm + , OpenGL + , random + , containers + , linear + , matrix + , nanovg >= 0.6.0.0 + , deepseq + if !flag(examples) buildable: False -- Another small game of life implementation @@ -166,17 +164,16 @@ executable example02 ghc-options: -threaded -Wall default-language: Haskell2010 default-extensions: OverloadedStrings - if flag(examples) - build-depends: base >=4.9 && < 5 - , affection - , sdl2 >= 2.5 - , stm - , OpenGL - , random - , containers - , linear - , matrix - , nanovg >= 0.6.0.0 - , deepseq - else + build-depends: base >=4.9 && < 5 + , affection + , sdl2 >= 2.5 + , stm + , OpenGL + , random + , containers + , linear + , matrix + , nanovg >= 0.6.0.0 + , deepseq + if !flag(examples) buildable: False diff --git a/flake.nix b/flake.nix index 9f3818b..607ed9b 100644 --- a/flake.nix +++ b/flake.nix @@ -19,28 +19,43 @@ packageName = "affection"; in rec { packages.${packageName} = # (ref:haskell-package-def) - haskellPackages.callCabal2nixWithOptions packageName self "--flag examples" rec { + haskellPackages.callCabal2nixWithOptions packageName self "--flag examples" { # Dependency overrides go here }; defaultPackage = self.packages.${system}.${packageName}; - devShell = defaultPackage.env; - #devShell = pkgs.mkShell { - # buildInputs = with haskellPackages; [ - # haskell-language-server - # ghcid - # cabal-install - # ]; - # nativeBuildInputs = with pkgs; [ - # pkg-config - # glib - # SDL2 - # freetype - # glew - # ]; - # inputsFrom = builtins.attrValues self.packages.${system}; - #}; + apps = { + example00 = { + type = "app"; + program = "${self.packages.${system}.${packageName}}/bin/example00"; + }; + example01 = { + type = "app"; + program = "${self.packages.${system}.${packageName}}/bin/example01"; + }; + example02 = { + type = "app"; + program = "${self.packages.${system}.${packageName}}/bin/example02"; + }; + }; + + #devShell = packages.${packageName}.env; + devShell = pkgs.mkShell { + buildInputs = with haskellPackages; [ + haskell-language-server + ghcid + cabal-install + ]; + nativeBuildInputs = with pkgs; [ + pkg-config + glib + SDL2 + freetype + glew + ]; + inputsFrom = builtins.attrValues self.packages.${system}; + }; }); }