Skip to content

Commit

Permalink
Merge pull request #21 from TristanCacqueray/flake
Browse files Browse the repository at this point in the history
Introduce flake to build hakyll website
  • Loading branch information
morucci authored Jan 16, 2024
2 parents d3de247 + e49ef47 commit ea34084
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 64 deletions.
42 changes: 14 additions & 28 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
name: "Test"
name: "Publish GH Pages"
on:
pull_request:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-20.09
- run: nix-build --attr pages
- name: Artifact pages
uses: actions/upload-artifact@v2
with:
name: pages
path: result/docs
deploy:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v2.3.4
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: pages
path: result/docs
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: gh-pages
folder: result/docs
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build the website (Nix) 🔧
run: nix build .#website
- name: Deploy to gh-pages 🚀
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./result/
cname: changemetrics.io
35 changes: 0 additions & 35 deletions default.nix

This file was deleted.

60 changes: 60 additions & 0 deletions flake.lock

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

48 changes: 48 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
description = "hakyll-website";

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

outputs = inputs:
inputs.flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import inputs.nixpkgs { inherit system; };
# the name of the cabal package and command line
name = "changemetrics-io";

haskellExtend = hpFinal: hpPrev: {
${name} =
hpPrev.callCabal2nix name inputs.self { };
};
hsPkgs = pkgs.haskellPackages.extend haskellExtend;

website = pkgs.stdenv.mkDerivation {
name = "${name}-pages";
buildInputs = [ hsPkgs.${name} ];
src = inputs.self;
# https://github.com/jaspervdj/hakyll/issues/614
# https://github.com/NixOS/nix/issues/318#issuecomment-52986702
# https://github.com/MaxDaten/brutal-recipes/blob/source/default.nix#L24
LOCALE_ARCHIVE =
pkgs.lib.optionalString (pkgs.buildPlatform.libc == "glibc")
"${pkgs.glibcLocales}/lib/locale/locale-archive";
LANG = "en_US.UTF-8";

buildPhase = ''
${name} build
'';
installPhase = ''
mv _site $out
'';
};
in {
packages.website = website;
devShell = hsPkgs.shellFor {
packages = p: [ p.${name} ];
buildInputs = [ pkgs.cabal-install ];
};
});
}
1 change: 0 additions & 1 deletion shell.nix

This file was deleted.

0 comments on commit ea34084

Please sign in to comment.