Last active
April 27, 2023 02:57
-
-
Save piq9117/53dbf9717a868847f4c1bccb8d81aaca 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 = "nixpkgs/nixos-22.11"; | |
outputs = { self, nixpkgs }: | |
let | |
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; | |
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); | |
nixpkgsFor = forAllSystems (system: import nixpkgs { | |
inherit system; | |
overlays = [ self.overlay ]; | |
}); | |
in | |
{ | |
overlay = self: super: { | |
hsPkgs = super.haskell.packages.ghc943.override { | |
overrides = hself: hsuper: { | |
beam-core = hsuper.beam-core.overrideAttrs (oldAttrs: { | |
src = (super.fetchFromGitHub { | |
owner = "haskell-beam"; | |
repo = "beam"; | |
rev = "98b61e8ab7f5fa96da4157c2e4790b6da65224da"; | |
sha256 = "1ksmw973hlzibpzny6ivw5gg166br0rylaxzr9nbphas5qbnw80m"; | |
}) + "/beam-core"; | |
}); | |
beam-migrate = super.haskell.lib.doJailbreak (hsuper.beam-migrate.overrideAttrs (oldAttrs: { | |
src = (super.fetchFromGitHub { | |
owner = "haskell-beam"; | |
repo = "beam"; | |
rev = "98b61e8ab7f5fa96da4157c2e4790b6da65224da"; | |
sha256 = "1ksmw973hlzibpzny6ivw5gg166br0rylaxzr9nbphas5qbnw80m"; | |
}) + "/beam-migrate"; | |
})); | |
beam-postgres = super.haskell.lib.doJailbreak (hsuper.beam-postgres.overrideAttrs (oldAttrs: { | |
src = (super.fetchFromGitHub { | |
owner = "haskell-beam"; | |
repo = "beam"; | |
rev = "98b61e8ab7f5fa96da4157c2e4790b6da65224da"; | |
sha256 = "1ksmw973hlzibpzny6ivw5gg166br0rylaxzr9nbphas5qbnw80m"; | |
}) + "/beam-postgres"; | |
})); | |
vinyl = hsuper.vinyl.overrideAttrs (oldAttrs: { | |
src = super.fetchFromGitHub { | |
owner = "VinylRecords"; | |
repo = "Vinyl"; | |
rev = "0e864100849356030299ebd95919f0d8c21ee218"; | |
sha256 = "0bq98ndlh86p8fbg20c22h6zb1qrcvpm07xd0wvy0b5cvqprjq22"; | |
}; | |
}); | |
microlens-platform = super.haskell.lib.doJailbreak hsuper.microlens-platform; | |
relude = hsuper.relude.overrideAttrs (oldAttrs: { | |
version = "1.2.0.0"; | |
src = super.fetchFromGitHub { | |
owner = "kowainik"; | |
repo = "relude"; | |
rev = "e633cb33308d259d6e4ea058ef506eb496b12323"; | |
sha256 = "0p29sk41c51f4vqlazyw5pf6n5v59llk34b45bf747sgqbqbxzwi"; | |
}; | |
}); | |
tasty-discover = hsuper.tasty-discover.overrideAttrs (oldAttrs: { | |
version = "5.0.0"; | |
src = super.fetchFromGitHub { | |
owner = "haskell-works"; | |
repo = "tasty-discover"; | |
rev = "109ef0fcd6af057d24f05f11de5b8348a2a0484e"; | |
sha256 = "0x2sz1cqclqjv133bf3wfas6bfkm946j5vz6ani8ri88kr36iip8"; | |
}; | |
}); | |
tasty-hedgehog = super.haskell.lib.doJailbreak (super.haskell.lib.markUnbroken (hsuper.tasty-hedgehog.overrideAttrs (oldAttrs: { | |
version = "1.4.0.1"; | |
src = super.fetchFromGitHub { | |
owner = "qfpl"; | |
repo = "tasty-hedgehog"; | |
rev = "3c254e1b012ec2cb3f39801e2adf55b4c72432fa"; | |
sha256 = "0fdn56g4h62w61p7xmdfv9qm4qmgqr49zj87q0jfyr97jan8ii20"; | |
}; | |
}))); | |
openapi3 = super.haskell.lib.dontCheck (super.haskell.lib.doJailbreak (hsuper.callCabal2nix "openapi3" | |
(builtins.fetchGit { | |
url = "https://github.com/alexbiehl/openapi3.git"; | |
rev = "4793b3c09f8c146161f7e78f8c0924bc9b0ec395"; | |
ref = "alex/aeson-2-support-for-extensions"; | |
}) | |
{ })); | |
tie = hsuper.callCabal2nix "tie" | |
(builtins.fetchGit { | |
url = "[email protected]:scarf-sh/tie.git"; | |
ref = "main"; | |
rev = "1aadc110adea816874a91b415d9a5a064a73b6f0"; | |
}) | |
{ }; | |
resource-pool = hsuper.resource-pool.overrideAttrs (oldAttrs: { | |
pname = "resource-pool"; | |
src = super.fetchFromGitHub { | |
owner = "scrive"; | |
repo = "pool"; | |
rev = "d8e5e061b475d51ba973ebb4431c24d17a60793e"; | |
sha256 = "18vd5f196y9ndj0knzpaircxysn15hlw9zsn54cmrry1y9dhcww2"; | |
}; | |
}); | |
opentracing = self.haskell.lib.dontCheck (self.haskell.lib.dontHaddock (hsuper.opentracing.overrideAttrs (oldAtts: { | |
pname = "opentracing"; | |
src = (self.fetchFromGitHub { | |
owner = "piq9117"; | |
repo = "opentracing"; | |
rev = "f5523a30a4c2e0c9d9bc2e922ffa266801c7417c"; | |
sha256 = "0ppmb7r0v03b2np11dkm2kprhsq1h739b23p1qdd7n21vq1lknb5"; | |
}) + "/opentracing"; | |
}))); | |
opentracing-wai = self.haskell.lib.dontCheck (self.haskell.lib.dontHaddock (hsuper.opentracing-wai.overrideAttrs (oldAtts: { | |
pname = "opentracing"; | |
src = (self.fetchFromGitHub { | |
owner = "piq9117"; | |
repo = "opentracing"; | |
rev = "f5523a30a4c2e0c9d9bc2e922ffa266801c7417c"; | |
sha256 = "0ppmb7r0v03b2np11dkm2kprhsq1h739b23p1qdd7n21vq1lknb5"; | |
}) + "/opentracing-wai"; | |
}))); | |
opentracing-jaeger = self.haskell.lib.dontCheck (self.haskell.lib.dontHaddock (hsuper.opentracing-jaeger.overrideAttrs (oldAtts: { | |
pname = "opentracing-jaeger"; | |
src = (self.fetchFromGitHub { | |
owner = "piq9117"; | |
repo = "opentracing"; | |
rev = "f5523a30a4c2e0c9d9bc2e922ffa266801c7417c"; | |
sha256 = "0ppmb7r0v03b2np11dkm2kprhsq1h739b23p1qdd7n21vq1lknb5"; | |
}) + "/opentracing-jaeger"; | |
}))); | |
todo-api = hself.callCabal2nix "todo-api" ./todo-api { }; | |
todo-app = hself.callCabal2nix "todo-app" ./. { }; | |
}; | |
}; | |
generate-api = self.writeScriptBin "generate-api" | |
'' | |
${self.hsPkgs.tie}/bin/tie --output todo-api \ | |
--module-name Todo.API --package-name todo-api todo-api.yaml | |
''; | |
}; | |
packages = forAllSystems (system: | |
let | |
pkgs = nixpkgsFor.${system}; | |
in | |
{ | |
default = pkgs.hsPkgs.todo-app; | |
run-app = pkgs.writeShellApplication { | |
name = "run-app"; | |
runtimeInputs = [ ]; | |
text = '' | |
cabal run exe:todo-app | |
''; | |
}; | |
}); | |
devShells = forAllSystems (system: | |
let | |
pkgs = nixpkgsFor.${system}; | |
libs = with pkgs; [ | |
zlib | |
dbmate | |
ormolu | |
nixpkgs-fmt | |
postgresql | |
treefmt | |
]; | |
in | |
{ | |
default = pkgs.hsPkgs.shellFor { | |
packages = hsPkgs: [ | |
hsPkgs.todo-app | |
# hsPkgs.beam-core | |
# hsPkgs.opentracing | |
# hsPkgs.beam-migrate | |
# hsPkgs.beam-postgres | |
# hsPkgs.vinyl | |
# hsPkgs.microlens-platform | |
# hsPkgs.relude | |
# hsPkgs.tasty-discover | |
# hsPkgs.tasty-hedgehog | |
# hsPkgs.openapi3 | |
# hsPkgs.tie | |
# hsPkgs.resource-pool | |
# hsPkgs.opentracing | |
# hsPkgs.opentracing-wai | |
# hsPkgs.opentracing-jaeger | |
]; | |
buildInputs = with pkgs; [ | |
hsPkgs.cabal-install | |
hsPkgs.cabal-fmt | |
hsPkgs.tie | |
hsPkgs.ghcid | |
hsPkgs.ghc | |
generate-api | |
] ++ 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