Skip to content

Add flake to build site and update theme url #8

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

Merged
merged 4 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Deploy to Gihub Pages

on:
Expand All @@ -16,24 +15,17 @@ jobs:
submodules: true
fetch-depth: 0
lfs: true
- name: Checkout LFS objects
run: git lfs checkout

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
extended: true

- name: Build
run: hugo --minify
- name: Install Nix
uses: cachix/install-nix-action@v17
- name: Build site
run: nix build

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_dir: ./result
cname: allthingsembedded.com

deploy-staging:
Expand All @@ -47,19 +39,15 @@ jobs:
- name: Checkout LFS objects
run: git lfs checkout

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
extended: true

- name: Build
run: hugo --minify -D --baseURL https://allthingsembedded.com/staging-web
- name: Install Nix
uses: cachix/install-nix-action@v17
- name: Build site
run: nix build .#allthingsembedded-staging

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
publish_dir: ./public
publish_dir: ./result
external_repository: allthingsembedded/staging-web
personal_token: ${{ secrets.PERSONAL_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ public/
.direnv
.hugo_build.lock
result/
nix-portable
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "themes/even"]
path = themes/even
url = https://github.com/allthingsembedded/hugo-theme-even
url = https://github.com/olOwOlo/hugo-theme-even
3 changes: 2 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ pygmentsCodefences = true
pygmentsUseClasses = true
pygmentsCodefencesGuessSyntax = true

paginate = 5
googleAnalytics = "UA-120967880-1" # UA-XXXXXXXX-X

[pagination]
pagerSize = 5

[sitemap] # essential
changefreq = "weekly"
Expand Down
47 changes: 32 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,45 @@
in
fn pkgs
);

buildHugoPackage = { pkgs, pname, version, src, extraBuildArgs ? "" }: (pkgs.stdenvNoCC.mkDerivation {
inherit pname version src;

nativeBuildInputs = [
pkgs.hugo
];

patchPhase = ''
mkdir -p themes/
cp -r ${even-theme}/ themes/even
'';

buildPhase = ''
hugo ${extraBuildArgs}
'';

installPhase = ''
cp -r public $out
'';
});

in
{
packages = forEachSystem (pkgs: rec {
allthingsembedded = pkgs.stdenvNoCC.mkDerivation {
allthingsembedded = buildHugoPackage {
inherit pkgs;
pname = "allthingsembedded";
version = "1.0.0";

src = self;
extraBuildArgs = "--minify";
};

nativeBuildInputs = [
pkgs.hugo
];

buildPhase = ''
mkdir -p themes/even/
cp -r ${even-theme} themes/even
hugo
'';

installPhase = ''
cp -r public $out
'';
allthingsembedded-staging = buildHugoPackage {
inherit pkgs;
pname = "allthingsembedded";
version = "1.0.0";
src = self;
extraBuildArgs = "--minify -D --baseURL https://allthingsembedded.com/staging-web";
};

default = allthingsembedded;
Expand Down
9 changes: 9 additions & 0 deletions portable_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

curl -L https://github.com/DavHau/nix-portable/releases/latest/download/nix-portable-$(uname -m) > ./nix-portable
chmod +x ./nix-portable

./nix-portable nix build
./nix-portable nix-shell -p bash --run "cp -rL result public"