Skip to content
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

Install tools to use hugo with Nix to avoid unstable snap #279

Merged
merged 2 commits into from
Apr 4, 2024
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
28 changes: 9 additions & 19 deletions .github/workflows/generate_site_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,33 @@ defaults:
jobs:
build:
runs-on: ubuntu-latest
env:
# Keep same version with `make deps`
HUGO_VERSION: 0.124.1
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v4
# Required go env because hugo module depends on it
- name: Cache hugo resources
uses: actions/cache@v4
with:
path: /home/runner/.cache/hugo_cache
key: ${{ runner.os }}-hugo-v${{ env.HUGO_VERSION }}-hugomod-${{ hashFiles('go.sum') }}
key: ${{ runner.os }}-flake-${{ hashFiles('flake.lock') }}-hugomod-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-hugo-v${{ env.HUGO_VERSION }}-hugomod-
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
${{ runner.os }}-flake-${{ hashFiles('flake.lock') }}-hugomod-
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
- name: Build hugo-nix to measure how longtime used to build
run: 'nix run .#hugo-nix -- version'
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && nix develop --command npm ci || true"
# Required go env before this step because hugo module depends on it. Now whole setup is completed with Nix
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo --panicOnWarning \
nix run .#hugo-nix -- --panicOnWarning \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
Expand Down
25 changes: 23 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,31 @@
nixpkgs-fmt
vim

edge-pkgs.dprint

edge-pkgs.hugo
edge-pkgs.go_1_22
edge-pkgs.dprint
dart-sass
];
};
});

apps = {
hugo-nix = {
type = "app";
program = with pkgs;lib.getExe (writeShellApplication
{
name = "hugo-with-dependencies";
runtimeInputs = [
edge-pkgs.hugo
edge-pkgs.go_1_22
dart-sass
];
text = ''
hugo "$@"
'';
});
};
};
}
);
}