|
| 1 | +{ |
| 2 | + description = "sslang: a language built atop the Sparse Synchronous Model"; |
| 3 | + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 4 | + inputs.flake-utils.url = "github:numtide/flake-utils"; |
| 5 | + |
| 6 | + outputs = { self, nixpkgs, flake-utils }: |
| 7 | + flake-utils.lib.eachDefaultSystem (system: |
| 8 | + let |
| 9 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 10 | + |
| 11 | + hPkgs = |
| 12 | + pkgs.haskell.packages."ghc8107"; # need to match Stackage LTS version |
| 13 | + # from stack.yaml resolver |
| 14 | + |
| 15 | + myDevTools = [ |
| 16 | + hPkgs.ghc # GHC compiler in the desired version (will be available on PATH) |
| 17 | + hPkgs.hlint # Haskell codestyle checker |
| 18 | + hPkgs.haskell-language-server # LSP server for editor |
| 19 | + stack-wrapped |
| 20 | + pkgs.zlib # External C library needed by some Haskell packages |
| 21 | + ]; |
| 22 | + |
| 23 | + # Wrap Stack to work with our Nix integration. We don't want to modify |
| 24 | + # stack.yaml so non-Nix users don't notice anything. |
| 25 | + # - no-nix: We don't want Stack's way of integrating Nix. |
| 26 | + # --system-ghc # Use the existing GHC on PATH (will come from this Nix file) |
| 27 | + # --no-install-ghc # Don't try to install GHC if no matching GHC found on PATH |
| 28 | + stack-wrapped = pkgs.symlinkJoin { |
| 29 | + name = "stack"; # will be available as the usual `stack` in terminal |
| 30 | + paths = [ pkgs.stack ]; |
| 31 | + buildInputs = [ pkgs.makeWrapper ]; |
| 32 | + postBuild = '' |
| 33 | + wrapProgram $out/bin/stack \ |
| 34 | + --add-flags "\ |
| 35 | + --no-nix \ |
| 36 | + --system-ghc \ |
| 37 | + --no-install-ghc \ |
| 38 | + " |
| 39 | + ''; |
| 40 | + }; |
| 41 | + in { |
| 42 | + devShells.default = pkgs.mkShell { |
| 43 | + buildInputs = myDevTools; |
| 44 | + |
| 45 | + # Make external Nix c libraries like zlib known to GHC, like |
| 46 | + # pkgs.haskell.lib.buildStackProject does |
| 47 | + # https://github.com/NixOS/nixpkgs/blob/d64780ea0e22b5f61cd6012a456869c702a72f20/pkgs/development/haskell-modules/generic-stack-builder.nix#L38 |
| 48 | + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath myDevTools; |
| 49 | + }; |
| 50 | + }); |
| 51 | +} |
0 commit comments