Skip to content

Commit 6e85470

Browse files
replace nix-shell with Nix Flake (#737)
* replace `nix-shell` with Nix Flake This `flake.nix` provides the same resources as the deleted Nix files with less code to maintain. This commit does not fix/update the docs generation via Nix; this remains TODO. * Nix Flake GitHub Action badge * test Nix Flake on both Mac and Linux * Apply suggestions from code review Co-authored-by: Ken Micklas <git@kmicklas.com> --------- Co-authored-by: Ken Micklas <git@kmicklas.com>
1 parent 8bab511 commit 6e85470

File tree

11 files changed

+190
-103
lines changed

11 files changed

+190
-103
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/nix-flake.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Nix Flake"
2+
on:
3+
pull_request:
4+
push:
5+
jobs:
6+
nix:
7+
strategy:
8+
fail-fast: true
9+
matrix:
10+
os:
11+
- ubuntu-latest
12+
- macos-latest
13+
name: Nix on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: DeterminateSystems/nix-installer-action@main
18+
- uses: DeterminateSystems/magic-nix-cache-action@main
19+
- name: "Check `nix develop` shell"
20+
run: nix develop --check
21+
- name: "Check `nix develop` shell can run command"
22+
run: nix develop --command "true"
23+
- run: nix build
24+
- run: nix flake check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ TAGS
2323
docs/ChinookData
2424
result
2525
result-*
26+
.direnv

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Beam: a type-safe, non-TH Haskell relational database library and ORM
22

33
[![Build status](https://github.com/haskell-beam/beam/workflows/Build/badge.svg)](https://github.com/haskell-beam/beam/workflows/Build/badge.svg)
4+
[![Build status](https://github.com/haskell-beam/beam/actions/workflows/nix-flake.yaml/badge.svg)](https://github.com/haskell-beam/beam/actions/workflows/nix-flake.yaml)
45

56
If you use beam commercially, please consider a donation to make this project possible: https://liberapay.com/tathougies
67

@@ -79,12 +80,15 @@ to run this against. See the documentation for examples.
7980

8081
## Building the documentation
8182

82-
Beam uses `mkdocs` for its documentation generation. The included
83-
`build-docs.sh` script can take care of building the documentation and serving
84-
it locally. In order to use the tool though, make sure you have a python
85-
installation with the `mkdocs` module installed. You can do this by creating a
86-
virtualenv, and pip installing `mkdocs`, or in a Nix shell with
87-
`nix-shell docs`.
83+
Beam uses [`mkdocs`](https://www.mkdocs.org/) for its documentation generation.
84+
85+
### Requirements
86+
* Python installation with [`mkdocs` module](https://pypi.org/project/mkdocs/)
87+
* Alternatively, open the Nix Flake shell via `nix develop`.
88+
89+
Then run `build-docs.sh`.
90+
91+
TODO: define Nix package for docs bundle.
8892

8993
The documentation uses a custom Markdown preprocessor to automatically build
9094
examples against the canonical Chinook database. By default, beam will build

docs/default.nix

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
with nixpkgs;
55

66
let
7-
beamLib = import ../nix/lib.nix { inherit nixpkgs; };
8-
beamGhc = beamLib.makeBeamGhc ghc;
97
docsEnv = poetry2nix.mkPoetryEnv {
108
projectDir = ./.;
119
};
@@ -51,7 +49,7 @@ stdenv.mkDerivation {
5149
[]
5250
./..;
5351
nativeBuildInputs = [
54-
(beamGhc.ghc.withPackages beamLib.beamPackageList)
52+
# (beamGhc.ghc.withPackages beamLib.beamPackageList)
5553
docsEnv
5654
poetry
5755
postgresql

flake.lock

Lines changed: 91 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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs";
4+
flake-parts.url = "github:hercules-ci/flake-parts";
5+
haskell-flake.url = "github:srid/haskell-flake";
6+
7+
testcontainers.url =
8+
"github:testcontainers/testcontainers-hs/e286bd2ba9747c2d8c3756a3a89910e579e318e3";
9+
testcontainers.flake = false;
10+
};
11+
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
12+
flake-parts.lib.mkFlake { inherit inputs; } {
13+
systems = nixpkgs.lib.systems.flakeExposed;
14+
imports = [ inputs.haskell-flake.flakeModule ];
15+
16+
perSystem = { self', pkgs, ... }: {
17+
18+
haskellProjects.default = {
19+
basePackages = pkgs.haskell.packages.ghc98;
20+
21+
packages = {
22+
testcontainers.source = inputs.testcontainers;
23+
};
24+
settings = {
25+
testcontainers.check = false;
26+
beam-postgres.check = false;
27+
};
28+
29+
devShell = {
30+
enable = true;
31+
32+
hlsCheck.enable = false;
33+
34+
tools = hp: {
35+
inherit (pkgs)
36+
postgresql
37+
sqlite-interactive
38+
poetry
39+
curl
40+
pv # http://www.ivarch.com/programs/pv.shtml
41+
;
42+
};
43+
};
44+
};
45+
46+
packages.all = pkgs.symlinkJoin {
47+
name = "all";
48+
paths = [
49+
self'.packages.beam-core
50+
self'.packages.beam-migrate
51+
self'.packages.beam-postgres
52+
self'.packages.pagila
53+
self'.packages.beam-sqlite
54+
];
55+
};
56+
57+
packages.default = self'.packages.all;
58+
59+
# docs = import ./docs { inherit nixpkgs; };
60+
};
61+
};
62+
}

nix/lib.nix

Lines changed: 0 additions & 61 deletions
This file was deleted.

nix/nixpkgs.nix

Lines changed: 0 additions & 4 deletions
This file was deleted.

release.nix

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)