From 0738a7b7cd1b23b2af215b8d4b1fd5e999c0d279 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 6 May 2020 07:55:37 -0400 Subject: [PATCH] fix CI --- .drone.yml | 24 ++++++++---------------- book/default.nix | 40 ++++++++++++++++++++++++++++++++++++++++ book/result | 1 + book/src/build.sh | 16 ++++++---------- nix/sources.json | 8 ++++---- nix/texlive.nix | 2 ++ shell.nix | 6 +++--- 7 files changed, 64 insertions(+), 33 deletions(-) create mode 100644 book/default.nix create mode 120000 book/result create mode 100644 nix/texlive.nix diff --git a/.drone.yml b/.drone.yml index 1a79be6..e051fde 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,31 +4,23 @@ workspace: base: /lewa steps: - - name: build ebook files - image: xena/pandoc - pull: always + - name: build book docker image + image: "monacoremo/nix:2020-04-05-05f09348-circleci" commands: - - cd book/src && ./build.sh + - cd book && nix-build + - cp $(readlink result) /lewa/result/docker.tgz volumes: - name: book - path: /lewa/book/book - - name: build mdbook - image: xena/mdbook - pull: always - commands: - - cd book && mdbook build - volumes: - - name: book - path: /lewa/book/book - - name: build image + path: /lewa/result + - name: push image image: docker:dind volumes: - name: book - path: /lewa/book/book + path: /lewa/result - name: dockersock path: /var/run/docker.sock commands: - - cd book && sh -c 'docker build -t xena/lewa:$DRONE_COMMIT .' + - docker import -f /lewa/result/docker.tgz volumes: - name: book diff --git a/book/default.nix b/book/default.nix new file mode 100644 index 0000000..b4cd2c1 --- /dev/null +++ b/book/default.nix @@ -0,0 +1,40 @@ +let + sources = import ../nix/sources.nix; + pkgs = import sources.nixpkgs { }; + nur = import (builtins.fetchTarball + "https://github.com/nix-community/NUR/archive/master.tar.gz") { + inherit pkgs; + }; + tex = pkgs.callPackage ../nix/texlive.nix { }; + book = pkgs.stdenv.mkDerivation { + pname = "lewa-book"; + version = "devel"; + src = ./.; + phases = "buildPhase installPhase"; + buildInputs = with pkgs; [ + kindlegen + mdbook + nur.repos.mic92.pandoc-bin + tex + ]; + + buildPhase = '' + cp -vrf $src/src . + cp -vrf $src/book.toml . + mkdir book + mdbook build + ls -la ./book + cd ./src && ./build.sh && cd .. + cd ./book && kindlegen lewa.epub ||: && cd .. + ''; + + installPhase = '' + mkdir -p $out + cp -vrf book $out/book + ''; + }; +in pkgs.dockerTools.buildLayeredImage { + name = "xena/lewa-book"; + contents = [ book nur.repos.xe.quickserv ]; + config.Cmd = [ "/bin/quickserv" "-port=9001" "-dir=/book" ]; +} diff --git a/book/result b/book/result new file mode 120000 index 0000000..32bc67b --- /dev/null +++ b/book/result @@ -0,0 +1 @@ +/nix/store/gy2ifmas4zw9i1l9i2m2411fqhbrmyf6-docker-image-lewa-book.tar.gz \ No newline at end of file diff --git a/book/src/build.sh b/book/src/build.sh index 8ca874b..b4a645d 100755 --- a/book/src/build.sh +++ b/book/src/build.sh @@ -1,18 +1,14 @@ #!/bin/sh +set -e + FILES=' intro/index.md -intro/diary_language.md -intro/CHANGELOG.md + intro/diary_language.md + intro/CHANGELOG.md ' set -x -pandoc -o lewa.epub --epub-chapter-level=2 --resource-path=. title.md $FILES -pandoc -o test.tex -s --include-in-header sectionpagebreak.tex --variable=subparagraph --toc --toc-depth=2 --resource-path=. title.md $FILES -pandoc -o lewa.pdf --include-in-header sectionpagebreak.tex --variable=subparagraph --toc --toc-depth=2 --pdf-engine xelatex --resource-path=. title.md $FILES || exit -kindlegen lewa.epub -mkdir -p ../book -cp -vrf lewa.mobi ../book/ -cp -vrf lewa.epub ../book/ -cp -vrf lewa.pdf ../book/ +pandoc -o ../book/lewa.epub --epub-chapter-level=2 --resource-path=. title.md $FILES +pandoc -o ../book/lewa.pdf --include-in-header sectionpagebreak.tex --variable=subparagraph --toc --toc-depth=2 --pdf-engine xelatex --resource-path=. title.md $FILES diff --git a/nix/sources.json b/nix/sources.json index 5e0a418..685fbf8 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -12,15 +12,15 @@ "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { - "branch": "nixos-19.09", + "branch": "nixpkgs-unstable", "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", "homepage": "https://github.com/NixOS/nixpkgs", "owner": "NixOS", "repo": "nixpkgs-channels", - "rev": "a7ceb2536ab11973c59750c4c48994e3064a75fa", - "sha256": "0hka65f31njqpq7i07l22z5rs7lkdfcl4pbqlmlsvnysb74ynyg1", + "rev": "e23f530858308b9248cfaffb4b99966c0545d4f2", + "sha256": "02hjg0zgy0wc6bczsqnqhs4d0gh1idhgdgv114nfkfwlfyx2a2r1", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs-channels/archive/a7ceb2536ab11973c59750c4c48994e3064a75fa.tar.gz", + "url": "https://github.com/NixOS/nixpkgs-channels/archive/e23f530858308b9248cfaffb4b99966c0545d4f2.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/nix/texlive.nix b/nix/texlive.nix new file mode 100644 index 0000000..5b20742 --- /dev/null +++ b/nix/texlive.nix @@ -0,0 +1,2 @@ +{ texlive }: +texlive.combine { inherit (texlive) scheme-medium noto titlesec; } diff --git a/shell.nix b/shell.nix index aa4383b..e3244d2 100644 --- a/shell.nix +++ b/shell.nix @@ -1,12 +1,12 @@ let - pkgs = import { }; + sources = import ./nix/sources.nix; + pkgs = import sources.nixpkgs { }; nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { inherit pkgs; }; dyson = pkgs.callPackage ./nix/dyson.nix { }; - tex = with pkgs; - texlive.combine { inherit (texlive) scheme-medium noto titlesec; }; + tex = pkgs.callPackage ./nix/texlive.nix { }; in pkgs.mkShell { buildInputs = with pkgs; [ dyson