Compare commits

..

14 commits

18 changed files with 381 additions and 81 deletions

2
.envrc Normal file
View file

@ -0,0 +1,2 @@
watch_files .envrc flake.nix nix/*.nix
use flake

6
.gitignore vendored
View file

@ -1,5 +1,7 @@
output
.venv
venv-install
cache
__pycache__
.direnv
plugins
theme
.env

6
.gitmodules vendored
View file

@ -1,6 +0,0 @@
[submodule "theme"]
path = theme
url = https://git.epha.se/ephase/attila_pelican_theme.git
[submodule "plugins"]
path = plugins
url = https://github.com/getpelican/pelican-plugins

View file

@ -1,48 +0,0 @@
-include include.mk
# pelican variables
P_OUTPUT?=output
P_OPT?=
# deploy variables
D_BIN?=rsync
D_OPT?=-avz --delete
D_DST?="blog:$(D_FOLDER)"
# venv variables
VENV_SOURCE?=.venv
REQUIREMENT?=requirements.txt
PYTHON_BIN?=python3
VENV_CMD?=. $(VENV_SOURCE)/bin/activate
# Pelican part
.PHONY: build
build: $(VENV_SOURCE)/dep
$(VENV_CMD) && pelican -o $(P_OUTPUT) $(P_OPT)
.PHONY: deploy
deploy: build
[ -d $(P_OUTPUT) ] && $(D_BIN) $(D_OPT) $(P_OUTPUT)/ $(D_DST)
.PHONY: clean
clean:
[ -d $(P_OUTPUT) ] && rm -rf $(P_OUTPUT)
# venv management
$(VENV_SOURCE):
$(PYTHON_BIN) -m venv $(VENV_SOURCE)
$(REQUIREMENT):
$(VENV_SOURCE)/dep: $(VENV_SOURCE) $(REQUIREMENT)
touch $(VENV_SOURCE)/dep
$(VENV_CMD) && pip install -r $(REQUIREMENT)
.PHONY: clean-venv
clean-venv:
[ -d $(VENV_SOURCE) ] && rm -rf $(VENV_SOURCE)
.PHONY: serve
serve: $(VENV_SOURCE)/dep
$(VENV_CMD) && invoke livereload

View file

@ -1 +0,0 @@
find . -type f -name '*.md; -exec sed -ie 's\Category: adminsys\Category: sysadmin\g' {} \;

107
flake.lock generated Normal file
View file

@ -0,0 +1,107 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1735774679,
"narHash": "sha256-soePLBazJk0qQdDVhdbM98vYdssfs3WFedcq+raipRI=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f2f7418ce0ab4a5309a4596161d154cfc877af66",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1735834308,
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1735774519,
"narHash": "sha256-CewEm1o2eVAnoqb6Ml+Qi9Gg/EfNAxbRx1lANGVyoLI=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1735554305,
"narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"systems": "systems",
"treefmt-nix": "treefmt-nix"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"id": "systems",
"type": "indirect"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1736154270,
"narHash": "sha256-p2r8xhQZ3TYIEKBoiEhllKWQqWNJNoT9v64Vmg4q8Zw=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "13c913f5deb3a5c08bb810efd89dc8cb24dd968b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

24
flake.nix Normal file
View file

@ -0,0 +1,24 @@
{
description = "Nix flake for my personal blog";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs =
inputs@{
nixpkgs,
flake-parts,
systems,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
imports = [
inputs.treefmt-nix.flakeModule
./nix/default.nix
];
};
}

26
lefthook.yaml Normal file
View file

@ -0,0 +1,26 @@
---
commit-msg:
parallel: true
commands:
lint:convco:
run: cat {1} | convco check --from-stdin
lint:typos:
run: cat {1} | typos -
pre-commit:
parallel: true
commands:
nixcheck:
glob: "flake.{nix,lock}"
run: nix flake check
shellcheck:
glob: "*.sh"
run: shellcheck {staged_files}
shfmt:
glob: "*.sh"
run: shfmt -d -ln bash -i 4 {staged_files}

34
nix/build.nix Normal file
View file

@ -0,0 +1,34 @@
{ inputs, ... }:
let
inherit (inputs.flake-parts.lib) mkPerSystemOption;
in
{
options.perSystem = mkPerSystemOption (
{
pkgs,
config,
...
}:
{
packages.default = pkgs.stdenvNoCC.mkDerivation {
name = "xiemeart";
src = ../.;
nativeBuildInputs = config.buildPackages;
configurePhase = ''
ln -snf ${config.pelicantheme} theme
ln -snf ${config.pelicanplugins} plugins
'';
buildPhase = ''
ls -la
mkdir -p output
pelican --verbose -o output/ 2>& 1>build.log
'';
installPhase = ''
mkdir -p $out/
cp build.log $out/
cp -r output/* $out/
'';
};
}
);
}

9
nix/default.nix Normal file
View file

@ -0,0 +1,9 @@
{ ... }:
{
imports = [
./treefmt.nix
./packages.nix
./devshell.nix
./build.nix
];
}

20
nix/devshell.nix Normal file
View file

@ -0,0 +1,20 @@
_: {
config.perSystem =
{
config,
inputs',
pkgs,
...
}:
{
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = config.develPackages;
shellHook = ''
ln -snf ${config.pelicanplugins} plugins
ln -snf ${config.pelicantheme} theme
'';
};
};
};
}

103
nix/packages.nix Normal file
View file

@ -0,0 +1,103 @@
{
lib,
inputs,
...
}:
let
inherit (lib) mkOption mdDoc types;
inherit (inputs.flake-parts.lib) mkPerSystemOption;
in
{
options.perSystem = mkPerSystemOption (
{
pkgs,
config,
...
}:
{
options = {
buildPackages = mkOption {
description = mdDoc "Python package used in the project";
type = types.listOf types.package;
default = ( with pkgs.python311Packages; [
markdown-include
pelican
typogrify
]);
};
develPackages = mkOption {
description = mdDoc "Python package used to development";
type = types.listOf types.package;
default = with pkgs; [
convco
go-task
lefthook
rsync
shellcheck
shfmt
typos
]
++ ( with pkgs.python311Packages; [
markdown-include
pelican
typogrify
livereload
invoke
]);
};
pelicanplugins = mkOption {
type = types.package;
description = mdDoc "Pelican plugins used in my blog";
default =
with pkgs;
stdenvNoCC.mkDerivation {
name = "pelicanplugins";
pname = "pelicanplugins";
version = "1.0.0";
sourceRoot = ".";
srcs = [
(pkgs.fetchFromGitHub {
name = "neighbors";
owner = "pelican-plugins";
repo = "neighbors";
rev = "60649ac6f3494d01a37b9c6d3d455f9dc2502d55";
hash = "sha256-c6etuRqve9xj6NhGRAim2A0ae8xv6mI/yez+suQuZ8U=";
})
(pkgs.fetchFromGitHub {
name = "markdown-include";
owner = "pelican-plugins";
repo = "markdown-include";
rev = "df0b3e55c45471283ca62d6e157b61a8caa35e37";
hash = "sha256-y0dIvyEYLbYqkm+6yJOUYI3apzEMJ/N/JUwWTqjdsNg=";
})
];
installPhase = ''
cp -r markdown-include/pelican/plugins/ $out/
cp -r neighbors/pelican/plugins/neighbors $out/
'';
};
};
pelicantheme = mkOption {
type = types.package;
description = mdDoc "My personnal Pelican theme";
default = (
with pkgs;
stdenvNoCC.mkDerivation {
name = "pelicantheme-atilla";
pname = "pelicantheme-atilla";
version = "main";
src = pkgs.fetchgit {
url = "https://git.epha.se/ephase/attila_pelican_theme";
rev = "c5923a4be38d9c646a9dc261fb0ba4f24fe5655a";
hash = "sha256-DaaumjR23pXrACRHX9FssxE56nV7vLRy7HjRclm6rgs=";
};
installPhase = ''
cp -r $src/ $out
'';
}
);
};
};
}
);
}

18
nix/treefmt.nix Normal file
View file

@ -0,0 +1,18 @@
_: {
config.perSystem =
{
config,
inputs',
pkgs,
...
}:
{
treefmt = {
programs = {
shfmt.enable = true;
alejandra.enable = true;
nixfmt.enable = true;
};
};
};
}

View file

@ -2,6 +2,16 @@
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
MARKDOWN = {
'extension_configs': {
'markdown.extensions.codehilite': {'css_class': 'highlight'},
'markdown.extensions.extra': {},
'markdown.extensions.meta': {},
'markdown.extensions.fenced_code': {},
},
'output_format': 'html5',
}
SITENAME = 'Xieme-Art'
SITEURL = 'https://xieme-art.org'
SITESUBTITLE = """
@ -73,7 +83,7 @@ AUTHOR_FEED_RSS = None
THEME = 'theme/'
PLUGIN_PATHS = ['plugins']
PLUGINS = ['neighbors']
PLUGINS = ['neighbors', 'md_include']
# Attila theme
HEADER_COVERS_BY_CATEGORY = []

@ -1 +0,0 @@
Subproject commit aef91ac09a57ab61518a35b4b11fe711ee74e5e2

View file

@ -1,21 +0,0 @@
blinker==1.6.2
commonmark==0.9.1
docutils==0.20.1
feedgenerator==2.1.0
invoke==2.1.3
Jinja2==3.1.2
livereload==2.6.3
Markdown==3.4.3
markdown-it-py==3.0.0
MarkupSafe==2.1.3
mdurl==0.1.2
pelican==4.8.0
Pygments==2.15.1
python-dateutil==2.8.2
pytz==2023.3
rich==13.4.2
six==1.16.0
smartypants==2.0.1
tornado==6.3.2
typogrify==2.0.7
Unidecode==1.3.6

23
taskfile.yaml Normal file
View file

@ -0,0 +1,23 @@
version: "3"
set: [errexit, pipefail, nounset]
shopt: [globstar]
dotenv:
- .env
vars:
OUTPUT_PATH: ./output/
DEPLOY_CMD: rsync
DEPLOY_ARGS: -avz --delete
tasks:
build:
cmds:
- pelican -o {{.OUTPUT_PATH}}
serve:
cmds:
- invoke livereload
deploy:
deps:
- build
cmds:
- |
{{.DEPLOY_CMD}} {{.DEPLOY_ARGS}} {{.OUTPUT_PATH}} {{.HOSTNAME}}:{{.WWW_PATH}}

1
theme

@ -1 +0,0 @@
Subproject commit 2730c99463c7bc3906fb94742240f0796b9370f6