Created
February 20, 2024 00:40
-
-
Save piq9117/168dd0353806055babb44a01843b916c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "Basic haskell cabal template"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/23.11"; | |
}; | |
outputs = { self, nixpkgs }: | |
let | |
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; | |
nixpkgsFor = forAllSystems (system: import nixpkgs { | |
inherit system; | |
overlays = [self.overlay]; | |
}); | |
in | |
{ | |
overlay = final: prev: { | |
hsPkgs = prev.haskell.packages.ghc944.override { | |
overrides = hfinal: hprev: { | |
ghcid = prev.haskell.lib.dontCheck hprev.ghcid; | |
stamina = hprev.callCabal2nix "stamina" (final.fetchFromGitHub { | |
owner = "cachix"; | |
repo = "stamina.hs"; | |
rev = "6cb9ff43bf53ffd4548e5b6cf08d5564c2c6ff91"; | |
sha256 = "0c5kaiwa1pnqfqh5sv1gfzgq90543aswassd7rk0pz80y2v2jfkd"; | |
}){}; | |
websockets = hprev.callCabal2nix "websockets" (final.fetchFromGitHub { | |
owner = "jaspervdj"; | |
repo = "websockets"; | |
rev = "cbba20b9e073e15e767052fc08b9e35cf8afb985"; | |
sha256 = "0bdkgc4ra5fbwhjhik28w4972mj0wdrp6ryb59a2gg5m0msr9jx4"; | |
}){}; | |
wuss = hprev.callCabal2nix "wuss" (final.fetchFromGitHub { | |
owner = "tfausak"; | |
repo = "wuss"; | |
rev = "7340d03280e77977b49ea2011431f4beee538088"; | |
sha256 = "0gzxqrmh0gvsi7j8cvf0fl4a2lqd018ymcgzwqnbv51y5b4kwrmn"; | |
}){}; | |
typed-websockets = hprev.callCabal2nix "typed-websockets" (final.fetchFromGitHub { | |
owner = "cachix"; | |
repo = "typed-websockets"; | |
rev = "252e382cf186b32285893bef4b23153075907806"; | |
sha256 = "sha256-Q6Xnpx1R/laVku1KPs/qlIyOvIgaL6U4FayeH/2hGLo="; | |
}){}; | |
websocket-simple = hfinal.callCabal2nix "websocket-simple" ./. {}; | |
}; | |
}; | |
init-project = final.writeScriptBin "init-project" '' | |
${final.hsPkgs.cabal-install}/bin/cabal init --non-interactive | |
''; | |
}; | |
packages = forAllSystems (system: | |
let pkgs = nixpkgsFor.${system}; | |
in { | |
default = nixpkgsFor.${system}.hsPkgs.websocket-simple; | |
}); | |
devShells = forAllSystems (system: | |
let | |
pkgs = nixpkgsFor.${system}; | |
libs = with pkgs; [ | |
zlib | |
]; | |
in | |
{ | |
default = pkgs.hsPkgs.shellFor { | |
packages = hsPkgs: [ ]; | |
buildInputs = with pkgs; [ | |
hsPkgs.cabal-install | |
hsPkgs.cabal-fmt | |
hsPkgs.ghcid | |
hsPkgs.ghc | |
ormolu | |
treefmt | |
nixpkgs-fmt | |
hsPkgs.cabal-fmt | |
init-project | |
hsPkgs.typed-websockets | |
] ++ libs; | |
shellHook = '' | |
export PS1='[$PWD]\n❄ ' | |
''; | |
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath libs; | |
}; | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment