Skip to content

Commit

Permalink
add nix flake to generate website with pelican
Browse files Browse the repository at this point in the history
  • Loading branch information
taranarmo committed Jul 9, 2024
1 parent 720bfcb commit 6e5ccc6
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and Deploy

on:
push:
branches:
- main # Adjust this as needed

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Nix
uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Build site
run: nix build .#defaultPackage.${{ matrix.system }} --print-build-logs

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./output
5 changes: 5 additions & 0 deletions content/posts/post1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Title: My First Post
Date: 2023-01-01
Category: Test

This is the content of my first post.
5 changes: 5 additions & 0 deletions content/posts/post2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Title: My Second Post
Date: 2023-01-02
Category: Test

This is the content of my second post.
61 changes: 61 additions & 0 deletions flake.lock

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

26 changes: 26 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
description = "A flake to build a Pelican static site";

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

outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in {
devShell = pkgs.mkShell {
buildInputs = [
pkgs.python310
pkgs.python310Packages.pelican
pkgs.python310Packages.markdown
];
};

defaultPackage = pkgs.writeShellScriptBin "build-site" ''
export PATH=$PATH:${pkgs.python310Packages.pelican}/bin
pelican content -o output -s pelicanconf.py
'';
});
}
1 change: 0 additions & 1 deletion index.html

This file was deleted.

27 changes: 27 additions & 0 deletions pelicanconf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
AUTHOR = 'Sergei Volkov'
SITENAME = 'My Pelican Site'
SITEURL = ''

PATH = 'content'

TIMEZONE = 'Europe/Berlin'

DEFAULT_LANG = 'en'

# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None

# Blogroll
LINKS = (('Pelican', 'https://getpelican.com/'),)

# Social widget
#SOCIAL = (('You can add links in your config file', '#'),)

DEFAULT_PAGINATION = 10

# Uncomment following line if you want document-relative URLs when developing
#RELATIVE_URLS = True
15 changes: 15 additions & 0 deletions publishconf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import pelicanconf

#SITEURL = 'https://taranarmo.github.io/'
RELATIVE_URLS = False

FEED_ALL_ATOM = 'feeds/all.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'

DELETE_OUTPUT_DIRECTORY = True

# Following items are often useful when publishing

#DISQUS_SITENAME = ""
#GOOGLE_ANALYTICS = ""

0 comments on commit 6e5ccc6

Please sign in to comment.