From a0265835ca5733e08f881456afa3b24c5272f4b2 Mon Sep 17 00:00:00 2001 From: Javier Alvarez Date: Mon, 24 Feb 2025 23:11:48 +0100 Subject: [PATCH 1/4] update submodule --- .gitmodules | 2 +- themes/even | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5b48215..ad9251e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/themes/even b/themes/even index 50b4d1e..e030809 160000 --- a/themes/even +++ b/themes/even @@ -1 +1 @@ -Subproject commit 50b4d1e2eb1736b31b916cc4fef813b6f5b40141 +Subproject commit e03080913d6148d055471f76027a33f28234cb32 From 77f1862fecc3bea674e0d0b8269610ecc730c9ae Mon Sep 17 00:00:00 2001 From: Javier Alvarez Date: Mon, 24 Feb 2025 23:12:42 +0100 Subject: [PATCH 2/4] Update deprecated config --- config.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.toml b/config.toml index f153966..8f9bcce 100644 --- a/config.toml +++ b/config.toml @@ -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" From f81f03ff39cdb2a390d75450b04d845ed9b284df Mon Sep 17 00:00:00 2001 From: Javier Alvarez Date: Mon, 24 Feb 2025 23:13:09 +0100 Subject: [PATCH 3/4] Rewrite github workflow to use flakes --- .github/workflows/deploy.yml | 32 ++++++++------------------ flake.nix | 44 ++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 439f36c..dacfe74 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,3 @@ - name: Deploy to Gihub Pages on: @@ -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: @@ -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 }} diff --git a/flake.nix b/flake.nix index a1882b2..5949285 100644 --- a/flake.nix +++ b/flake.nix @@ -31,28 +31,42 @@ in fn pkgs ); + + buildHugoPackage = { pkgs, pname, version, src, extraBuildArgs ? "" }: (pkgs.stdenvNoCC.mkDerivation { + inherit pname version src; + + nativeBuildInputs = [ + pkgs.hugo + ]; + + buildPhase = '' + mkdir -p themes/even/ + cp -r ${even-theme} themes/even + 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; From 77af6245bc83f1840998b31096e09abe18a503b2 Mon Sep 17 00:00:00 2001 From: Javier Alvarez Date: Mon, 24 Feb 2025 23:24:59 +0100 Subject: [PATCH 4/4] Add portable build file --- .gitignore | 1 + flake.nix | 7 +++++-- portable_build.sh | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 portable_build.sh diff --git a/.gitignore b/.gitignore index e6369ba..a3c6297 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ public/ .direnv .hugo_build.lock result/ +nix-portable diff --git a/flake.nix b/flake.nix index 5949285..6fbd91c 100644 --- a/flake.nix +++ b/flake.nix @@ -39,9 +39,12 @@ pkgs.hugo ]; + patchPhase = '' + mkdir -p themes/ + cp -r ${even-theme}/ themes/even + ''; + buildPhase = '' - mkdir -p themes/even/ - cp -r ${even-theme} themes/even hugo ${extraBuildArgs} ''; diff --git a/portable_build.sh b/portable_build.sh new file mode 100755 index 0000000..c86e5d9 --- /dev/null +++ b/portable_build.sh @@ -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"