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

Add flake and related GH workflows #505

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions .github/workflows/cachix-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Workflow to build and push the static hugo files to Cachix
name: 🛫 Build and push to Cachix

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
name: qgis-org
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build .#qgis-website
- run: nix flake check
37 changes: 37 additions & 0 deletions .github/workflows/flake-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update Nix Flake inputs

on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:

jobs:
test:
name: Update flakes and commit changes
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# This will allow us to trigger other workflows (cachix-build, etc.)
# when we commit changes using the git-auto-commit-action
token: ${{ secrets.PAT }}

- name: Install Nix
uses: cachix/install-nix-action@v25

- name: Run nix flake update
run: >
nix flake update

- name: '✉️ Commit'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Flakes updated and committed via a GitHub Action.'

2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
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: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: 🛠️ Setup Hugo
uses: peaceiris/actions-hugo@v3
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/update-feeds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ jobs:
if: github.repository_owner == 'qgis'
steps:
- name: '🛒 Checkout QGIS Website'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main
path: ./qgis-website
# This will allow us to trigger other workflows (cachix-build, etc.)
# when we commit changes using the git-auto-commit-action
token: ${{ secrets.PAT }}

- name: '🐍 Setup Python'
uses: actions/setup-python@v3
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ You can find the extended version `v0.139.0` [here](https://github.com/gohugoio/

![Download](./img/hugo-download.png)

### Nix/NixOs:
The development environment is using Nix flakes. Please visit https://nixos.wiki/wiki/Flakes for more details.

Start the Nix development environment by running:

```sh
nix develop # Add --experimental-features 'nix-command flakes' if you haven't enable Nix flakes
hugo server
# If you want to run VSCode:
./vscode
```

To build the website:
```sh
nix build .#qgis-website # Add | cachix push qgis-org to push it to cachix
```

### 🐧 Linux:

Download the latest version and then do
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
description = "Development environment and build process for a Hugo app with Python requirements";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs = { self, nixpkgs }:
let
system = "x86_64-linux";

# Importing packages from nixpkgs
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true; # Allow unfree packages like VSCode if needed
};


mkDevShell = pkgs.mkShell {
packages = with pkgs; [
hugo # Hugo for building the website
vscode # VSCode for development
python312Packages.icalendar # Python packages
python312Packages.requests # Python packages
gnumake # GNU Make for build automation
];

shellHook = ''
export DIRENV_LOG_FORMAT=
echo "-----------------------"
echo "🌈 Your Hugo Dev Environment is ready."
echo "It provides hugo and vscode for use with the QGIS Website Project"
echo ""
echo "🪛 VSCode:"
echo "--------------------------------"
echo "Start vscode like this:"
echo ""
echo "./vscode.sh"
echo ""
echo "🪛 Hugo:"
echo "--------------------------------"
echo "Start Hugo like this:"
echo ""
echo "hugo server"
echo "-----------------------"
'';
};

in
{
devShells.x86_64-linux.default = mkDevShell;

packages = {
x86_64-linux = {
qgis-website = pkgs.callPackage ./package.nix {};
};
};
};
}
32 changes: 32 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ lib, stdenv, hugo, gnumake }:

stdenv.mkDerivation {
name = "qgis-website";
src = lib.cleanSourceWith {
src = ./.;
filter = (
path: type: (builtins.all (x: x != baseNameOf path) [
".git"
".github"
"flake.nix"
"package.nix"
])
);
};
buildInputs = [ hugo gnumake ];

buildPhase = ''
make deploy
'';

installPhase = ''
mkdir -p $out
cp -r public_www public_prod $out/
'';

meta = with lib; {
description = "A built QGIS website";
license = licenses.mit;
};
}

37 changes: 0 additions & 37 deletions shell.nix

This file was deleted.

Loading