From 2ffc6f8fd39b06cd63c434cb7974f022173184ab Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 4 Nov 2022 22:18:56 -0400 Subject: [PATCH 1/5] Add flake.nix to build PDF --- flake.lock | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 34 +++++++++++++++++++++++++++++ 2 files changed, 98 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..b5e03b3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1666885127, + "narHash": "sha256-uXA/3lhLhwOTBMn9a5zJODKqaRT+SuL5cpEmOz2ULoo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "0e101dbae756d35a376a5e1faea532608e4a4b9a", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1667580403, + "narHash": "sha256-IoCMTRO51HNtpEzGSdaFprj3E8lH1aut+3tkh/spRTk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f0adf4fcae2aecdd6ade53cb5d4b94d3b7446efd", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1665349835, + "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..99ccaa9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit self; } { + systems = nixpkgs.lib.systems.flakeExposed; + perSystem = { self', pkgs, ... }: { + packages.default = pkgs.stdenvNoCC.mkDerivation rec { + name = "DaoFP.pdf"; + src = self; + buildInputs = [ + pkgs.coreutils + (pkgs.texlive.combine { + inherit (pkgs.texlive) scheme-full latex-bin latexmk pygmentex; + }) + pkgs.python37Packages.pygments + pkgs.which + ]; + phases = [ "unpackPhase" "buildPhase" "installPhase" ]; + buildPhase = '' + set -e + export PATH="${pkgs.lib.makeBinPath buildInputs}"; + pdflatex -shell-escape DaoFP.tex + ''; + installPhase = '' + mkdir -p $out + cp DaoFP.pdf $out/ + ''; + }; + }; + }; +} From eee5a03d82915fe879f34e31973ed07af0186e21 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 4 Nov 2022 22:19:35 -0400 Subject: [PATCH 2/5] Ignore ./result symlink --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c22f646..a542566 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ DaoFP.ilg *.fls *.out *.pyg + +# Nix +result From b34dd3b09b275a8e9b65fe8793e500961d355ea3 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 4 Nov 2022 22:22:15 -0400 Subject: [PATCH 3/5] CI: build & publish the PDF To Github Pages --- .github/workflows/publish.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..4bf9349 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,25 @@ +name: "Publish" +on: + # Run only when pushing to master branch + push: + branches: + - master + - nixify +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v17 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Build content (Nix) 🔧 + run: | + nix build -j 4 + - name: Deploy to gh-pages 🚀 + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./result/ + # cname: yoursite.com From ae0c16925f0973054667f94bc761a0970abe6fa2 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Sat, 5 Nov 2022 16:26:12 -0400 Subject: [PATCH 4/5] Compile twice to see if that generates ToC --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 99ccaa9..36fbdbe 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,7 @@ set -e export PATH="${pkgs.lib.makeBinPath buildInputs}"; pdflatex -shell-escape DaoFP.tex + pdflatex -shell-escape DaoFP.tex ''; installPhase = '' mkdir -p $out From 79c643905917ec2786c1ab26451273157b1dd471 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Sat, 5 Nov 2022 16:42:51 -0400 Subject: [PATCH 5/5] add comment for the hack --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 36fbdbe..9f5a153 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,8 @@ buildPhase = '' set -e export PATH="${pkgs.lib.makeBinPath buildInputs}"; + # Due to quirks of TeX, we must run this *twice* to + # get the ToC to generate. pdflatex -shell-escape DaoFP.tex pdflatex -shell-escape DaoFP.tex '';