Skip to content

Commit 41b6038

Browse files
committed
Rework Nix Build
1 parent 121ff8a commit 41b6038

File tree

7 files changed

+58
-39
lines changed

7 files changed

+58
-39
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,4 @@ src/auto/
192192

193193

194194
## Nix
195-
/result*
195+
/result*

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
language: nix
2-
# FIXME: Why does pandoc fail in nix-build?
3-
script: nix-shell --pure --run make

Makefile

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PDF ?= sf-idris-2018.pdf
77
.PHONY: pdf site
88

99

10-
all: check pdf site
10+
all: pdf site
1111

1212

1313
build:
@@ -20,7 +20,8 @@ check:
2020

2121
pdf:
2222
$(MAKE) -C src
23-
mv src/all.pdf docs/pdf/${PDF}
23+
mkdir -p ${PREFIX}/pdf
24+
mv src/all.pdf ${PREFIX}/pdf/${PDF}
2425

2526

2627
clean-all: clean clean-docs
@@ -32,17 +33,13 @@ clean:
3233

3334
clean-docs:
3435
$(MAKE) -C src clean
35-
@$(RM) docs/index.html >/dev/null
36+
@$(RM) ${PREFIX}/index.html >/dev/null
3637

3738

38-
site: docs/index.html
39+
site: ${PREFIX}/index.html
3940

4041

41-
docs/index.html: README.md CONTRIBUTING.md
42+
${PREFIX}/index.html: README.md CONTRIBUTING.md
4243
pandoc -f gfm -t gfm -A CONTRIBUTING.md $< | \
4344
pandoc -M title='Software Foundations in Idris' \
4445
-f gfm -t html -s -o $@
45-
46-
47-
install:
48-
install -m644 -Dt "${PREFIX}" docs/pdf/${PDF}

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.2.0
1+
0.0.2.1

default.nix

+44-22
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,45 @@ let
99

1010
fromJSONFile = f: builtins.fromJSON (builtins.readFile f);
1111

12+
genMeta = { ghc, stdenv, ...}: with stdenv.lib; {
13+
description = "Software Foundations in Idris";
14+
homepage = https://idris-hackers.github.io/software-foundations;
15+
license = licenses.mit;
16+
maintainers = with maintainers; [ yurrriq ];
17+
inherit (ghc.meta) platforms;
18+
};
19+
1220
in
1321

1422
{ nixpkgs ? fetchTarballFromGitHub (fromJSONFile ./nixpkgs-src.json) }:
1523

1624
with import nixpkgs {
1725
overlays = [
1826
(self: super: {
19-
ghc-with-pandoc = super.haskellPackages.ghcWithPackages (ps: with ps; [
20-
pandoc
21-
]);
22-
27+
idrisPackages = super.idrisPackages // {
28+
software_foundations = with super.idrisPackages; build-idris-package {
29+
name = "software_foundations";
30+
version = builtins.readFile ./VERSION;
31+
src = ./.;
32+
idrisDeps = [ pruviloj ];
33+
meta = genMeta super;
34+
};
35+
};
36+
})
37+
(self: super: {
2338
idris = with super.idrisPackages; with-packages [
2439
base
2540
prelude
2641
pruviloj
42+
software_foundations
2743
];
2844

45+
pandoc = super.haskellPackages.ghcWithPackages (ps: with ps; [
46+
pandoc
47+
]);
48+
49+
inherit (super.pythonPackages) pygments;
50+
2951
xelatex = super.texlive.combine {
3052
inherit (super.texlive) scheme-small
3153
amsmath
@@ -53,34 +75,34 @@ with import nixpkgs {
5375
];
5476
};
5577

78+
5679
stdenv.mkDerivation rec {
57-
name = "software-foundations-${version}-env";
80+
name = "sf-idris-${version}";
5881
version = builtins.readFile ./VERSION;
5982
src = ./.;
6083

61-
FONTCONFIG_FILE = makeFontsConf {
62-
fontDirectories = [
63-
iosevka
64-
];
65-
};
84+
FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ iosevka ]; };
6685

67-
buildInputs = [
68-
ghc-with-pandoc
69-
idris
70-
python3Packages.pygments
86+
patchPhase = lib.optionalString (! lib.inNixShell) ''
87+
patchShebangs src/pandoc-minted.hs
88+
'';
89+
90+
nativeBuildInputs = [
91+
pandoc
92+
pygments
7193
xelatex
7294
which
7395
];
7496

75-
installFlags = [
76-
"PREFIX=$(out)"
97+
buildInputs = [
98+
idris
7799
];
78100

79-
meta = with stdenv.lib; {
80-
description = "Software Foundations in Idris";
81-
homepage = https://idris-hackers.github.io/software-foundations;
82-
license = licenses.mit;
83-
maintainers = with maintainers; [ yurrriq ];
84-
inherit (ghc.meta) platforms;
101+
makeFlags = [ "PREFIX=$(out)" ];
102+
103+
dontInstall = true;
104+
105+
meta = (genMeta pkgs) // {
106+
platforms = lib.platforms.linux;
85107
};
86108
}

software_foundations.ipkg

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ modules = Basics
1414
, ImpCEvalFun
1515

1616
brief = "Software Foundations in Idris"
17-
version = 0.0.2.0
17+
version = 0.0.2.1
1818
readme = README.md
1919
-- NOTE: For license information see the file LICENSE.
2020

src/Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ PANDOC ?= pandoc
55

66

77
PANDOC_FLAGS := \
8-
--filter pandoc-minted.hs --pdf-engine=xelatex \
9-
-f markdown+lhs+tex_math_single_backslash -t latex+lhs \
10-
--top-level-division=chapter
8+
--filter=pandoc-minted.hs \
9+
--pdf-engine=xelatex \
10+
--top-level-division=chapter \
11+
-f markdown+lhs+tex_math_single_backslash \
12+
-t latex+lhs
1113

1214

1315
LIDR_FILES := Preface.lidr \

0 commit comments

Comments
 (0)