Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare nix build times #3

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
19 changes: 3 additions & 16 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: taiki-e/install-action@v1
with:
tool: cargo-binstall,cargo-make,mdbook,mdbook-linkcheck,mdbook-admonish,mdbook-open-on-gh

- name: Setup mdBook prerequisites
run: |
cargo make install-docs-prereqs

- name: Error on broken links
run: |
sed 's/warning-policy = "warn"/warning-policy = "error"/g' book.toml > book.toml

- name: Build the book
run: |
cargo make build-docs
- name: Build Docs
uses: input-output-hk/[email protected]

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book
publish_dir: ./book/html
31 changes: 31 additions & 0 deletions .github/workflows/nix-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: GitHub Pages (with Nix)

on:
pull_request:
push:
branches:
- "main"

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v3

- uses: cachix/install-nix-action@v18
name: Install Nix
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- run: nix develop --command mdbook build

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/html
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vscode

book

result*
/.direnv/
43 changes: 43 additions & 0 deletions flake.lock

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

34 changes: 34 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
description = "Standards for Project Catalyst";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
};

mdbook-kroki = (import ./nix/mdbookPlugins/kroki.nix) { inherit pkgs; };
mdbook-regex = (import ./nix/mdbookPlugins/regex.nix) { inherit pkgs; };
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
mdbook

mdbook-kroki
mdbook-admonish
mdbook-open-on-gh
mdbook-linkcheck
mdbook-regex
];
};
}
);
}
24 changes: 24 additions & 0 deletions nix/mdbookPlugins/kroki.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ pkgs }:

with pkgs;

rustPlatform.buildRustPackage rec {
pname = "mdbook-kroki-preprocessor";
version = "0.1.2";

src = fetchCrate {
inherit pname version;
sha256 = "sha256-hcfJ9oHksTtbrSRQkL7/hyKuA0LfDpPPfIaWeD7a3Fk=";
};

cargoHash = "sha256-IKwDWymAQ1OMQN8Op+DcvqPikoLdOz6lltbhCgOAles=";

buildInputs = [
openssl
];

nativeBuildInputs = [
pkg-config
openssl
];
}
21 changes: 21 additions & 0 deletions nix/mdbookPlugins/new_plugin_template.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use this template to add a new rust package (check first to see if it exists in nixpkgs at search.nixos.org)
# Import it into the flake, add it to nativeBuildInputs, then run `nix develop`
# It will cause errors due to invalid hashes, you can use the error messages to get the correct hash
#
# Make sure you `git add` any new files, as they will cause "no such file or directory" errors if not checked into git

{ pkgs }:

with pkgs;

rustPlatform.buildRustPackage rec {
pname = "<package name>"; # as it appears on crates.io
version = "1.2.3"; # as it appears on crates.io

src = fetchCrate {
inherit pname version;
sha256 = lib.fakeSha256; # copy the value from the error into a string
};

cargoHash = lib.fakeHash;
}
18 changes: 18 additions & 0 deletions nix/mdbookPlugins/regex.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ pkgs }:

with pkgs;

rustPlatform.buildRustPackage rec {
pname = "mdbook-regex";
version = "0.0.1";

src = fetchFromGitHub {
owner = "cameron1024";
repo = "mdbook-regex";
rev = "6234ca571db72cafbc88ed3b1c53373d35eb0595";
sha256 = "sha256-j1Dbgk42GRuCG2BmtyhYL1zYeiPvDz/VYhL/VHDmVPM=";
};

cargoHash = "sha256-ANgMYvmuX0nVI9Y1QlwchfOlrvhlcd6qYeRvueG4PLI=";

}