Skip to content

Commit

Permalink
Merge pull request #352 from pankona/no-nix-build
Browse files Browse the repository at this point in the history
Directly install dart-sass and hugo without package managers
  • Loading branch information
pankona authored Jan 20, 2025
2 parents b4e3af8 + 57c7e4f commit dbbf6c0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/generate_site_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,54 @@ defaults:
jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: '0.141.0'
SASS_VERSION: '1.80.3'
DART_SASS_SHA_LINUX: '7c933edbad0a7d389192c5b79393485c088bd2c4398e32f5754c32af006a9ffd'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache hugo resources
uses: actions/cache@v4
with:
path: /home/runner/.cache/hugo_cache
key: ${{ runner.os }}-flake-${{ hashFiles('flake.lock') }}-hugomod-${{ hashFiles('go.sum') }}
key: ${{ runner.os }}-hugo-${{ env.HUGO_VERSION }}-hugomod-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-flake-${{ hashFiles('flake.lock') }}-hugomod-
${{ runner.os }}-hugo-${{ env.HUGO_VERSION }}-hugomod-
- name: Set up Go # Required go env because of hugo module depends on it.
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- uses: DeterminateSystems/nix-installer-action@v16
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Build hugo-nix to measure how longtime used to build
run: 'nix run .#hugo-nix -- version'
- 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 # We can remove this step if all themes and modules are not using Sass
# Workaround to avoid slow methods such as `snap install`. See GH-276
run: |
echo "Install Dart Sass version ${SASS_VERSION} ..."
curl -LJO "https://github.com/sass/dart-sass/releases/download/${SASS_VERSION}/dart-sass-${SASS_VERSION}-linux-x64.tar.gz";
echo "${DART_SASS_SHA_LINUX} dart-sass-${SASS_VERSION}-linux-x64.tar.gz" | sha256sum -c;
tar -xvf "dart-sass-${SASS_VERSION}-linux-x64.tar.gz";
echo "$GOBIN"
echo "$GITHUB_WORKSPACE/dart-sass/" >> $GITHUB_PATH
- name: Make sure dependency versions
run: |
hugo version
sass --version
- name: Install Node.js dependencies
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
run: '[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true'
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
nix run .#hugo-nix -- --panicOnWarning \
hugo --panicOnWarning \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
Expand Down
25 changes: 0 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,5 @@
};
}
);

apps = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
hugo-nix = {
type = "app";
program = pkgs.lib.getExe (
pkgs.writeShellApplication {
name = "hugo-with-dependencies";
runtimeInputs = with pkgs; [
hugo
go_1_23
dart-sass
];
text = ''
hugo "$@"
'';
}
);
};
}
);
};
}

0 comments on commit dbbf6c0

Please sign in to comment.