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 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 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..9f5a153 --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + 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}"; + # 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 + ''; + installPhase = '' + mkdir -p $out + cp DaoFP.pdf $out/ + ''; + }; + }; + }; +}