Skip to content

Commit

Permalink
Rework Nix Build
Browse files Browse the repository at this point in the history
  • Loading branch information
yurrriq committed Nov 1, 2018
1 parent 121ff8a commit 41b6038
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ src/auto/


## Nix
/result*
/result*
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
language: nix
# FIXME: Why does pandoc fail in nix-build?
script: nix-shell --pure --run make
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PDF ?= sf-idris-2018.pdf
.PHONY: pdf site


all: check pdf site
all: pdf site


build:
Expand All @@ -20,7 +20,8 @@ check:

pdf:
$(MAKE) -C src
mv src/all.pdf docs/pdf/${PDF}
mkdir -p ${PREFIX}/pdf
mv src/all.pdf ${PREFIX}/pdf/${PDF}


clean-all: clean clean-docs
Expand All @@ -32,17 +33,13 @@ clean:

clean-docs:
$(MAKE) -C src clean
@$(RM) docs/index.html >/dev/null
@$(RM) ${PREFIX}/index.html >/dev/null


site: docs/index.html
site: ${PREFIX}/index.html


docs/index.html: README.md CONTRIBUTING.md
${PREFIX}/index.html: README.md CONTRIBUTING.md
pandoc -f gfm -t gfm -A CONTRIBUTING.md $< | \
pandoc -M title='Software Foundations in Idris' \
-f gfm -t html -s -o $@


install:
install -m644 -Dt "${PREFIX}" docs/pdf/${PDF}
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.2.0
0.0.2.1
66 changes: 44 additions & 22 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,45 @@ let

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

genMeta = { ghc, stdenv, ...}: with stdenv.lib; {
description = "Software Foundations in Idris";
homepage = https://idris-hackers.github.io/software-foundations;
license = licenses.mit;
maintainers = with maintainers; [ yurrriq ];
inherit (ghc.meta) platforms;
};

in

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

with import nixpkgs {
overlays = [
(self: super: {
ghc-with-pandoc = super.haskellPackages.ghcWithPackages (ps: with ps; [
pandoc
]);

idrisPackages = super.idrisPackages // {
software_foundations = with super.idrisPackages; build-idris-package {
name = "software_foundations";
version = builtins.readFile ./VERSION;
src = ./.;
idrisDeps = [ pruviloj ];
meta = genMeta super;
};
};
})
(self: super: {
idris = with super.idrisPackages; with-packages [
base
prelude
pruviloj
software_foundations
];

pandoc = super.haskellPackages.ghcWithPackages (ps: with ps; [
pandoc
]);

inherit (super.pythonPackages) pygments;

xelatex = super.texlive.combine {
inherit (super.texlive) scheme-small
amsmath
Expand Down Expand Up @@ -53,34 +75,34 @@ with import nixpkgs {
];
};


stdenv.mkDerivation rec {
name = "software-foundations-${version}-env";
name = "sf-idris-${version}";
version = builtins.readFile ./VERSION;
src = ./.;

FONTCONFIG_FILE = makeFontsConf {
fontDirectories = [
iosevka
];
};
FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ iosevka ]; };

buildInputs = [
ghc-with-pandoc
idris
python3Packages.pygments
patchPhase = lib.optionalString (! lib.inNixShell) ''
patchShebangs src/pandoc-minted.hs
'';

nativeBuildInputs = [
pandoc
pygments
xelatex
which
];

installFlags = [
"PREFIX=$(out)"
buildInputs = [
idris
];

meta = with stdenv.lib; {
description = "Software Foundations in Idris";
homepage = https://idris-hackers.github.io/software-foundations;
license = licenses.mit;
maintainers = with maintainers; [ yurrriq ];
inherit (ghc.meta) platforms;
makeFlags = [ "PREFIX=$(out)" ];

dontInstall = true;

meta = (genMeta pkgs) // {
platforms = lib.platforms.linux;
};
}
2 changes: 1 addition & 1 deletion software_foundations.ipkg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ modules = Basics
, ImpCEvalFun

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

Expand Down
8 changes: 5 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ PANDOC ?= pandoc


PANDOC_FLAGS := \
--filter pandoc-minted.hs --pdf-engine=xelatex \
-f markdown+lhs+tex_math_single_backslash -t latex+lhs \
--top-level-division=chapter
--filter=pandoc-minted.hs \
--pdf-engine=xelatex \
--top-level-division=chapter \
-f markdown+lhs+tex_math_single_backslash \
-t latex+lhs


LIDR_FILES := Preface.lidr \
Expand Down

0 comments on commit 41b6038

Please sign in to comment.