From fd429b3261cef6c7e38453fa623d9ac84ec7d8ec Mon Sep 17 00:00:00 2001 From: Nate Wilcox Date: Wed, 6 Dec 2023 08:17:55 -0800 Subject: [PATCH 1/7] A nix flake (not yet successfully rendering due to version mismatch). --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..26fed68 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1701282334, + "narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "057f9aecfb71c4437d2b27d3323df7f93c010b7e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2159f44 --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + 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; [ + mdbook + mdbook-graphviz + mdbook-linkcheck + strace + ]; + + src = ./.; + + builder = pkgs.writeScript "${pname}-builder-${version}" '' + source "$stdenv/setup" + cp -a "$src" ./src + cd ./src + chmod -R u+w . + find "$(pwd)" -exec ls -ld '{}' \; + dest="$out/share/doc/${pname}/${version}" + mkdir -p "$dest" + strace mdbook build --dest-dir="$dest/" + ''; + }; + in { + packages."${system}".default = tfl-book-pkg; + }; +} From bf5b1448957f4567af67c8187c2c1e779c436de9 Mon Sep 17 00:00:00 2001 From: Nate Wilcox Date: Wed, 6 Dec 2023 08:47:47 -0800 Subject: [PATCH 2/7] Add missing `graphviz` dependency; book now renders. --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 2159f44..a1aff51 100644 --- a/flake.nix +++ b/flake.nix @@ -13,10 +13,10 @@ version = "0.1.0"; # BUG: This should be derived from the `git describe --dirty` buildInputs = with pkgs; [ + graphviz mdbook mdbook-graphviz mdbook-linkcheck - strace ]; src = ./.; @@ -29,7 +29,7 @@ find "$(pwd)" -exec ls -ld '{}' \; dest="$out/share/doc/${pname}/${version}" mkdir -p "$dest" - strace mdbook build --dest-dir="$dest/" + mdbook build --dest-dir="$dest/" ''; }; in { From 96d062d40c1a9b5e41001ce03f0318ddad8876f8 Mon Sep 17 00:00:00 2001 From: Nate Wilcox Date: Wed, 6 Dec 2023 08:52:41 -0800 Subject: [PATCH 3/7] Add nix user advice in `README.md`. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 25c4055..8815762 100644 --- a/README.md +++ b/README.md @@ -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 `/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` From 73d22413f37273e3030ef45c6ce91426e699a264 Mon Sep 17 00:00:00 2001 From: Nate Wilcox Date: Wed, 6 Dec 2023 08:55:03 -0800 Subject: [PATCH 4/7] Simplify the nix flake output hierarchy: remove version and only produce the `html` dir. --- flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index a1aff51..2b41802 100644 --- a/flake.nix +++ b/flake.nix @@ -26,10 +26,10 @@ cp -a "$src" ./src cd ./src chmod -R u+w . - find "$(pwd)" -exec ls -ld '{}' \; - dest="$out/share/doc/${pname}/${version}" - mkdir -p "$dest" - mdbook build --dest-dir="$dest/" + mdbook build + dest="$out/share/doc/${pname}/" + mkdir -p "$(dirname "$dest")" + cp -a ./build/html "$dest" ''; }; in { From 590ae86939002040e49f7916405bcc8c5258e344 Mon Sep 17 00:00:00 2001 From: Nate Wilcox Date: Wed, 6 Dec 2023 09:00:53 -0800 Subject: [PATCH 5/7] Add nix build/check to `merge-acceptance.yaml` workflow. --- .github/workflows/merge-acceptance.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/merge-acceptance.yaml b/.github/workflows/merge-acceptance.yaml index 2161fa0..36d50e0 100644 --- a/.github/workflows/merge-acceptance.yaml +++ b/.github/workflows/merge-acceptance.yaml @@ -21,3 +21,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 From 90b35060e4cc0bdb8a427960ccb8eaa4cd954589 Mon Sep 17 00:00:00 2001 From: Daira Emma Hopwood Date: Thu, 7 Dec 2023 16:04:40 +0000 Subject: [PATCH 6/7] Update flake.nix to add mdbook-katex as a build input --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 2b41802..2873d6c 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,7 @@ mdbook mdbook-graphviz mdbook-linkcheck + mdbook-katex ]; src = ./.; From 5fad9e11ca19cc64ce259af9c896aa51b1c3f605 Mon Sep 17 00:00:00 2001 From: Daira Emma Hopwood Date: Thu, 7 Dec 2023 16:05:01 +0000 Subject: [PATCH 7/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8815762..ae99096 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ git config --local core.hooksPath git-hooks ## Prerequisites -Note: nix users can rely on `flake.nix` which packages the final rendered html into `/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`. +Note: Nix users can rely on `flake.nix` which packages the final rendered HTML into `/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