Skip to content

Commit 1eb6614

Browse files
authored
Merge pull request #139 from siraben/flake
Add Nix flake
2 parents 75285ed + b35c09c commit 1eb6614

File tree

6 files changed

+138
-46
lines changed

6 files changed

+138
-46
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,25 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Check out code base
9+
- name: 'Checkout codebase'
1010
if: github.event_name == 'push'
11-
uses: actions/checkout@v2.3.1
11+
uses: actions/checkout@v2.4.0
1212
with:
1313
fetch-depth: 0
1414

15-
- name: Check out code base
15+
- name: 'Checkout codebase'
1616
if: github.event_name == 'pull_request'
17-
uses: actions/checkout@v2.3.1
17+
uses: actions/checkout@v2.4.0
1818
with:
1919
fetch-depth: 0
2020
ref: ${{ github.event.pull_request.head.sha }}
2121

22-
- uses: cachix/install-nix-action@v12
23-
with:
24-
nix_path: nixpkgs=channel:nixos-unstable
25-
- run: NIXPKGS_ALLOW_UNFREE=1 nix-build
26-
- name: "Copy book"
27-
run: "cp result/share/book.pdf ."
28-
- name: "Upload artifact to GitHub"
29-
uses: actions/upload-artifact@v2
22+
- uses: cachix/install-nix-action@v14
23+
- run: NIXPKGS_ALLOW_UNFREE=1 nix --experimental-features 'nix-command flakes' build -L --impure
24+
- name: 'Copy book'
25+
run: cp result/share/book.pdf .
26+
- name: 'Upload artifact to GitHub'
27+
uses: actions/[email protected]
3028
with:
3129
name: book.pdf
3230
path: book.pdf

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
**/#*#
2222
tex/gitrev
2323
.DS_Store
24-
24+
result

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
# This is the "Mathematical Components" book.
22
[![build](https://github.com/math-comp/mcb/actions/workflows/build.yml/badge.svg)](https://github.com/math-comp/mcb/actions/workflows/build.yml)
33

4-
To build the book using Nix, run `nix-build`. Alternatively you may
5-
fetch the latest artifact produced by the CI for the master branch
4+
## Building
5+
To build the book using Nix, run
6+
```ShellSession
7+
# without flakes, check out the repo first
8+
$ NIXPKGS_ALLOW_UNFREE=1 nix-build
9+
# with flakes
10+
$ NIXPKGS_ALLOW_UNFREE=1 nix build github:math-comp/mcb --impure
11+
```
12+
13+
Alternatively you may fetch the latest artifact produced by the CI for
14+
the master branch
615
[here](https://github.com/math-comp/mcb/actions?query=branch%3Amaster).
716

8-
The `tex/` directory contains the sources. TexLive 2014 is
17+
The `tex/` directory contains the sources. TexLive 2014, 2021 is
918
known to work.
1019

1120
The `coq/` directory contains snippets corresponding to the chapters

default.nix

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
1-
with import <nixpkgs> {};
2-
3-
stdenv.mkDerivation rec {
4-
name = "math-comp-book";
5-
version = "master";
6-
src = ./.;
7-
8-
nativeBuildInputs = [ git texlive.combined.scheme-full ];
9-
10-
buildPhase = ''
11-
cd tex
12-
make
13-
biber main
14-
make
15-
make
16-
'';
17-
18-
installPhase = ''
19-
mkdir -p $out/share
20-
cp book.pdf $out/share
21-
'';
22-
23-
meta = with lib; {
24-
description = "Mathematical components book";
25-
homepage = "https://github.com/math-comp/mcb";
26-
license = lib.licenses.cc-by-nc-40;
27-
maintainers = with maintainers; [ siraben ];
28-
platforms = platforms.all;
29-
};
30-
}
1+
(import (
2+
let
3+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
4+
in fetchTarball {
5+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
6+
sha256 = lock.nodes.flake-compat.locked.narHash; }
7+
) {
8+
src = ./.;
9+
}).defaultNix

flake.lock

Lines changed: 60 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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
description = "Mathematical Components (the book)";
3+
inputs = {
4+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5+
utils.url = "github:numtide/flake-utils";
6+
flake-compat = {
7+
url = "github:edolstra/flake-compat";
8+
flake = false;
9+
};
10+
};
11+
12+
outputs = { self, nixpkgs, utils, ... }:
13+
utils.lib.eachDefaultSystem (system:
14+
with import nixpkgs { inherit system; }; {
15+
defaultPackage = stdenv.mkDerivation {
16+
name = "math-comp-book";
17+
version = "master";
18+
src = ./.;
19+
20+
nativeBuildInputs = [ git texlive.combined.scheme-full ];
21+
22+
buildPhase = ''
23+
cd tex
24+
make
25+
biber main
26+
make
27+
make
28+
'';
29+
30+
installPhase = ''
31+
mkdir -p $out/share
32+
cp book.pdf $out/share
33+
'';
34+
35+
meta = with lib; {
36+
description = "Mathematical components book";
37+
homepage = "https://github.com/math-comp/mcb";
38+
license = lib.licenses.cc-by-nc-40;
39+
maintainers = with maintainers; [ siraben ];
40+
platforms = platforms.all;
41+
};
42+
};
43+
}
44+
);
45+
}
46+

0 commit comments

Comments
 (0)