Skip to content

Commit 9d59625

Browse files
committed
Nixify website build in GitHub Action
1 parent cc79343 commit 9d59625

File tree

4 files changed

+589
-9
lines changed

4 files changed

+589
-9
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@ jobs:
2727

2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v3
31-
- name: Set up Ruby
32-
uses: ruby/setup-ruby@v1
33-
with:
34-
ruby-version: 2.7
35-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
36-
- name: Build website
37-
run: bundle exec middleman build
38-
3930
- uses: cachix/install-nix-action@v20
4031
with:
4132
nix_path: nixpkgs=channel:nixos-unstable
33+
34+
- uses: actions/checkout@v3
35+
- name: Build website
36+
run: |
37+
nix build .
38+
mkdir -p build
39+
cp -R result/* build
40+
4241
- name: Build documentation
4342
env:
4443
OWNER: afh

flake.lock

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
description = "Website for ledger-cli.org";
3+
4+
nixConfig.bash-prompt = "ledger-cli.org$ ";
5+
6+
inputs = {
7+
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
8+
flake-utils.url = "github:numtide/flake-utils";
9+
};
10+
11+
outputs = { self, nixpkgs, flake-utils }:
12+
flake-utils.lib.eachDefaultSystem( system:
13+
let
14+
pkgs = import nixpkgs { inherit system; };
15+
gems = with pkgs; bundlerEnv {
16+
name = "ledger.github.io";
17+
inherit ruby;
18+
gemdir = ./.;
19+
};
20+
in
21+
{
22+
packages = rec {
23+
default = pkgs.stdenvNoCC.mkDerivation rec {
24+
name = "ledger.github.io";
25+
src = self;
26+
27+
nativeBuildInputs = with pkgs; [ gems ruby ];
28+
29+
buildPhase = ''
30+
runHook preBuild
31+
bundle exec middleman build
32+
runHook postBuild
33+
'';
34+
35+
installPhase = ''
36+
runHook preInstall
37+
mv build $out
38+
runHook postInstall
39+
'';
40+
};
41+
};
42+
43+
devShell = pkgs.mkShell {
44+
buildInputs = self.packages.${system}.default.nativeBuildInputs;
45+
};
46+
});
47+
}

0 commit comments

Comments
 (0)