Skip to content

Commit

Permalink
Merge pull request #133 from Electric-Coin-Company/nix-flake
Browse files Browse the repository at this point in the history
A nix flake for the final rendered result
  • Loading branch information
daira authored Dec 7, 2023
2 parents 15d2d50 + 5fad9e1 commit 4ec80a0
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/merge-acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ jobs:
- run: mdbook build
- name: Check for Orphaned Files
run: ./util/find-orphaned-files.sh

# Reference: https://github.com/marketplace/actions/install-nix
check-flake:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
- run: nix build
- run: nix flake check
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ git config --local core.hooksPath git-hooks

## Prerequisites

Note: Nix users can rely on `flake.nix` which packages the final rendered HTML into `<prefix>/share/doc/tfl-book`. Users can install this via `nix profile install 'github:Electric-Coin-Company/tfl-book'`, or to build the local version `nix build`.

### Rust prerequisites

- `cargo install mdbook`
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
description = "The Zcash Trailing Finality Layer Book";

inputs.nixpkgs.url = "github:nixos/nixpkgs/23.11";

outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages."${system}";

tfl-book-pkg = pkgs.stdenv.mkDerivation rec {
pname = "tfl-book";
version = "0.1.0"; # BUG: This should be derived from the `git describe --dirty`

buildInputs = with pkgs; [
graphviz
mdbook
mdbook-graphviz
mdbook-linkcheck
mdbook-katex
];

src = ./.;

builder = pkgs.writeScript "${pname}-builder-${version}" ''
source "$stdenv/setup"
cp -a "$src" ./src
cd ./src
chmod -R u+w .
mdbook build
dest="$out/share/doc/${pname}/"
mkdir -p "$(dirname "$dest")"
cp -a ./build/html "$dest"
'';
};
in {
packages."${system}".default = tfl-book-pkg;
};
}

0 comments on commit 4ec80a0

Please sign in to comment.