Skip to content

Commit 6d641f1

Browse files
committed
Add Nix flake for build configuration.
This makes it easy for `nix` users to take advantage of recent updates to the project.
1 parent f3d3805 commit 6d641f1

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.stack-work
2+
.*.swp
3+
.cabal-sandbox
4+
cabal.sandbox.config
5+
dist
26
dist-newstyle
37
result

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
description = "Relational database migrations modeled as a directed acyclic graph";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/release-25.11";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }: let
10+
pkg-name = "dbmigrations";
11+
haskell-overlay = pkgs: hfinal: hprev: let
12+
dontCheck = pkg: pkgs.haskell.lib.dontCheck pkg;
13+
in {
14+
${pkg-name} = dontCheck (hfinal.callCabal2nixWithOptions pkg-name ./. "-f sqlite -f postgresql" {});
15+
};
16+
17+
overlay = final: prev: {
18+
haskellPackages = prev.haskellPackages.extend (haskell-overlay final);
19+
dbm-postgresql = "${final.haskellPackages.dbmigrations}/bin/dbm-postgresql";
20+
dbm-sqlite = "${final.haskellPackages.dbmigrations}/bin/dbm-sqlite";
21+
};
22+
in
23+
{
24+
overlays = {
25+
default = overlay;
26+
};
27+
}
28+
// flake-utils.lib.eachDefaultSystem (
29+
system: let
30+
pkgs = import nixpkgs {
31+
inherit system;
32+
overlays = [overlay];
33+
};
34+
35+
hspkgs = pkgs.haskellPackages;
36+
in {
37+
packages = {
38+
${pkg-name} = hspkgs.${pkg-name};
39+
default = self.packages.${system}.${pkg-name};
40+
};
41+
42+
devShells = {
43+
default = hspkgs.shellFor {
44+
packages = _: [self.packages.${system}.${pkg-name}];
45+
buildInputs = [
46+
pkgs.cabal-install
47+
pkgs.dbm-sqlite
48+
hspkgs.ormolu
49+
];
50+
withHoogle = true;
51+
inputsFrom = builtins.attrValues self.packages.${system};
52+
};
53+
};
54+
55+
formatter = pkgs.alejandra;
56+
}
57+
);
58+
}

0 commit comments

Comments
 (0)