{ # Builds a small Haskell program that uses external libraries from the # package set, so the example shows how Cabal dependencies flow through Nix. description = "A Haskell project with external dependencies"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; outputs = { self, nixpkgs, ... }: let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; inherit (pkgs) haskellPackages; project = haskellPackages.callCabal2nix "mini-json" ./. { }; checkedProject = pkgs.haskell.lib.doCheck project; in { packages.${system}.default = project; apps.${system}.default = { type = "app"; program = "${self.packages.${system}.default}/bin/mini-json"; meta.description = "Run the Haskell JSON parsing example."; }; devShells.${system}.default = pkgs.mkShell { packages = [ haskellPackages.ghc pkgs.cabal-install pkgs.haskell-language-server ]; }; # `doCheck` runs the Cabal test suite, which exercises both valid and # invalid JSON input through the library function. checks.${system}.test-suite = checkedProject; }; }