From e7abbd089179529f3dde3b35ce17de430ba6ea13 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sat, 25 May 2024 01:22:30 +0200 Subject: [PATCH 01/14] refactor: use nix flake instead venv --- .envrc | 1 + .gitignore | 4 ++-- .gitmodules | 3 --- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins | 1 - 6 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix delete mode 160000 plugins diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 2febe43..90fdf0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ output -.venv -venv-install cache __pycache__ +.direnv +plugins diff --git a/.gitmodules b/.gitmodules index 3b89742..1cb184c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ff193d9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716361217, + "narHash": "sha256-mzZDr00WUiUXVm1ujBVv6A0qRd8okaITyUp4ezYRgc4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "46397778ef1f73414b03ed553a3368f0e7e33c2f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4073ebe --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ +{ + description = "Development shell for Personal blog"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + flake-utils = { + url = "github:numtide/flake-utils"; + }; + }; + + outputs = { nixpkgs , flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + pelicanplugins-neighbors = ( with pkgs; stdenv.mkDerivation { + pname = "pelicanplugins-neighbors"; + version = "1.2.0"; + src = pkgs.fetchFromGitHub { + owner = "pelican-plugins"; + repo = "neighbors"; + rev = "60649ac6f3494d01a37b9c6d3d455f9dc2502d55"; + hash = "sha256-c6etuRqve9xj6NhGRAim2A0ae8xv6mI/yez+suQuZ8U="; + }; + installPhase = '' + cp -r $src/pelican/plugins/neighbors $out + ''; + }); + pelicanplugins-md_include = ( with pkgs; stdenv.mkDerivation { + pname = "pelicanplugins-md_include"; + version = "1.0.4"; + src = pkgs.fetchFromGitHub { + owner = "pelican-plugins"; + repo = "markdown-include"; + rev = "df0b3e55c45471283ca62d6e157b61a8caa35e37"; + hash = "sha256-y0dIvyEYLbYqkm+6yJOUYI3apzEMJ/N/JUwWTqjdsNg="; + }; + installPhase = '' + cp -r $src/pelican/plugins/md_include $out + ''; + }); + in { + devShells = { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + lefthook + go-task + convco + typos + shellcheck + shfmt + python3 + python3Packages.pelican + python3Packages.markdown-include + ]; + shellHook = '' + mkdir -p plugins + ln -snf "${pelicanplugins-neighbors}" "plugins/neighbors" + ln -snf "${pelicanplugins-md_include}" "plugins/md_include" + ''; + }; + }; + }); +} diff --git a/plugins b/plugins deleted file mode 160000 index aef91ac..0000000 --- a/plugins +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aef91ac09a57ab61518a35b4b11fe711ee74e5e2 From 9696ec6889d31aa1f9754d0cebed56d0c755e62d Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sat, 25 May 2024 01:23:36 +0200 Subject: [PATCH 02/14] refactor: replace make by go-task --- taskfile.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 taskfile.yaml diff --git a/taskfile.yaml b/taskfile.yaml new file mode 100644 index 0000000..fddfe8b --- /dev/null +++ b/taskfile.yaml @@ -0,0 +1,17 @@ +version: "3" +set: [errexit, pipefail, nounset] +shopt: [globstar] +tasks: + venv:create: + cmds: + - python3 -m venv .venv + status: + - test -f .venv + venv:deps: + cmds: + - ./.venv/bin/python3 -m pip install -r requirements.txt + build: + cmds: + - ./.venv/bin/pelican -o ./output + serve: + - ./.venv/bin/invoke livereload From c666484b2285efddbae5527ff9813d2c25083ac3 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sat, 25 May 2024 01:25:42 +0200 Subject: [PATCH 03/14] feat: add git hook (lefthook) And remove Makefile --- Makefile | 48 ------------------------------------------------ lefthook.yaml | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 48 deletions(-) delete mode 100644 Makefile create mode 100644 lefthook.yaml diff --git a/Makefile b/Makefile deleted file mode 100644 index 9e3a249..0000000 --- a/Makefile +++ /dev/null @@ -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 diff --git a/lefthook.yaml b/lefthook.yaml new file mode 100644 index 0000000..d4f7054 --- /dev/null +++ b/lefthook.yaml @@ -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} From 1a9c3ae81350ff5ea443915d2e9954bc43152393 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sat, 25 May 2024 01:27:03 +0200 Subject: [PATCH 04/14] feat: add markdown-include plugins --- pelicanconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelicanconf.py b/pelicanconf.py index 70db034..374487e 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -73,7 +73,7 @@ AUTHOR_FEED_RSS = None THEME = 'theme/' PLUGIN_PATHS = ['plugins'] -PLUGINS = ['neighbors'] +PLUGINS = ['neighbors', 'md_include'] # Attila theme HEADER_COVERS_BY_CATEGORY = [] From 214a34bedefa2a20a9c6b4de1acfee20bbb3e67a Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sun, 26 May 2024 21:26:33 +0200 Subject: [PATCH 05/14] fix: make livereload work with flake --- flake.nix | 3 +++ taskfile.yaml | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 4073ebe..6c42ea1 100644 --- a/flake.nix +++ b/flake.nix @@ -52,6 +52,9 @@ python3 python3Packages.pelican python3Packages.markdown-include + python3Packages.typogrify + python3Packages.livereload + python3Packages.invoke ]; shellHook = '' mkdir -p plugins diff --git a/taskfile.yaml b/taskfile.yaml index fddfe8b..b4790a8 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -2,16 +2,10 @@ version: "3" set: [errexit, pipefail, nounset] shopt: [globstar] tasks: - venv:create: - cmds: - - python3 -m venv .venv - status: - - test -f .venv - venv:deps: - cmds: - - ./.venv/bin/python3 -m pip install -r requirements.txt + build: cmds: - - ./.venv/bin/pelican -o ./output + - pelican -o ./output serve: - - ./.venv/bin/invoke livereload + cmds: + - invoke livereload From 75baf9efb4f8e9a48bf11f5b2d90d4331bde5fa8 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 5 Jun 2024 23:26:49 +0200 Subject: [PATCH 06/14] feat: add Taskfile and Lefthook to project --- .gitignore | 1 + flake.nix | 1 + taskfile.yaml | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 90fdf0c..84df769 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ cache __pycache__ .direnv plugins +.env diff --git a/flake.nix b/flake.nix index 6c42ea1..e890607 100644 --- a/flake.nix +++ b/flake.nix @@ -55,6 +55,7 @@ python3Packages.typogrify python3Packages.livereload python3Packages.invoke + rsync ]; shellHook = '' mkdir -p plugins diff --git a/taskfile.yaml b/taskfile.yaml index b4790a8..2b9a41f 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -1,11 +1,23 @@ version: "3" set: [errexit, pipefail, nounset] shopt: [globstar] -tasks: +dotenv: + - .env +vars: + OUTPUT_PATH: ./output + DEPLOY_CMD: rsync + DEPLOY_ARGS: -avz --delete +tasks: build: cmds: - - pelican -o ./output + - pelican -o {{.OUTPUT_PATH}} serve: cmds: - invoke livereload + deploy: + deps: + - build + cmds: + - | + {{.DEPLOY_CMD}} {{.DEPLOY_ARGS}} {{.OUTPUT_PATH}} {{.HOSTNAME}}:{{.WWW_PATH}} From 8b84d600294ae6ffa5542956c00fbec2d49e6388 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Thu, 20 Jun 2024 00:35:00 +0200 Subject: [PATCH 07/14] feat: add markdown plugins --- pelicanconf.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pelicanconf.py b/pelicanconf.py index 374487e..b029bc1 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -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 = """ From 1dc77e22fb7b9a3df2f1798435ce63601e6d1f0b Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Thu, 20 Jun 2024 00:38:27 +0200 Subject: [PATCH 08/14] chore: remove useless python requirement file --- requirements.txt | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 6a3f3e2..0000000 --- a/requirements.txt +++ /dev/null @@ -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 From 440e26fb63065b3955cb53f8dbbd647505fb6c90 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Thu, 20 Jun 2024 00:39:33 +0200 Subject: [PATCH 09/14] fix: bas output dir --- taskfile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taskfile.yaml b/taskfile.yaml index 2b9a41f..e95e9d0 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -4,7 +4,7 @@ shopt: [globstar] dotenv: - .env vars: - OUTPUT_PATH: ./output + OUTPUT_PATH: ./output/ DEPLOY_CMD: rsync DEPLOY_ARGS: -avz --delete From ffea2b6857f542a3bbbce53a70282573728bcda5 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Tue, 7 Jan 2025 00:56:34 +0100 Subject: [PATCH 10/14] ci: rework flake integration Now Use flake part and integrate a build system using nix package building and treefmt-nix as a flake-part module --- .envrc | 1 + flake.lock | 80 ++++++++++++++++++++++++++++-------- flake.nix | 80 ++++++++---------------------------- nix/build.nix | 34 +++++++++++++++ nix/default.nix | 9 ++++ nix/devshell.nix | 20 +++++++++ nix/packages.nix | 105 +++++++++++++++++++++++++++++++++++++++++++++++ nix/treefmt.nix | 18 ++++++++ 8 files changed, 268 insertions(+), 79 deletions(-) create mode 100644 nix/build.nix create mode 100644 nix/default.nix create mode 100644 nix/devshell.nix create mode 100644 nix/packages.nix create mode 100644 nix/treefmt.nix diff --git a/.envrc b/.envrc index 3550a30..201e5d8 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,2 @@ +watch_files .envrc flake.nix nix/*.nix use flake diff --git a/flake.lock b/flake.lock index ff193d9..bf641b5 100644 --- a/flake.lock +++ b/flake.lock @@ -1,43 +1,72 @@ { "nodes": { - "flake-utils": { + "flake-parts": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "lastModified": 1735774679, + "narHash": "sha256-soePLBazJk0qQdDVhdbM98vYdssfs3WFedcq+raipRI=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f2f7418ce0ab4a5309a4596161d154cfc877af66", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1716361217, - "narHash": "sha256-mzZDr00WUiUXVm1ujBVv6A0qRd8okaITyUp4ezYRgc4=", + "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": "46397778ef1f73414b03ed553a3368f0e7e33c2f", + "rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-23.11", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" } }, "systems": { @@ -50,8 +79,25 @@ "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "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" } } diff --git a/flake.nix b/flake.nix index e890607..da59fcd 100644 --- a/flake.nix +++ b/flake.nix @@ -1,68 +1,24 @@ { - description = "Development shell for Personal blog"; - + description = "Nix flake for my personal blog"; + inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; - flake-utils = { - url = "github:numtide/flake-utils"; - }; + nixpkgs.url = "nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + treefmt-nix.url = "github:numtide/treefmt-nix"; }; - outputs = { nixpkgs , flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - }; - pelicanplugins-neighbors = ( with pkgs; stdenv.mkDerivation { - pname = "pelicanplugins-neighbors"; - version = "1.2.0"; - src = pkgs.fetchFromGitHub { - owner = "pelican-plugins"; - repo = "neighbors"; - rev = "60649ac6f3494d01a37b9c6d3d455f9dc2502d55"; - hash = "sha256-c6etuRqve9xj6NhGRAim2A0ae8xv6mI/yez+suQuZ8U="; - }; - installPhase = '' - cp -r $src/pelican/plugins/neighbors $out - ''; - }); - pelicanplugins-md_include = ( with pkgs; stdenv.mkDerivation { - pname = "pelicanplugins-md_include"; - version = "1.0.4"; - src = pkgs.fetchFromGitHub { - owner = "pelican-plugins"; - repo = "markdown-include"; - rev = "df0b3e55c45471283ca62d6e157b61a8caa35e37"; - hash = "sha256-y0dIvyEYLbYqkm+6yJOUYI3apzEMJ/N/JUwWTqjdsNg="; - }; - installPhase = '' - cp -r $src/pelican/plugins/md_include $out - ''; - }); - in { - devShells = { - default = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ - lefthook - go-task - convco - typos - shellcheck - shfmt - python3 - python3Packages.pelican - python3Packages.markdown-include - python3Packages.typogrify - python3Packages.livereload - python3Packages.invoke - rsync - ]; - shellHook = '' - mkdir -p plugins - ln -snf "${pelicanplugins-neighbors}" "plugins/neighbors" - ln -snf "${pelicanplugins-md_include}" "plugins/md_include" - ''; - }; + outputs = + inputs@{ + nixpkgs, + flake-parts, + systems, + ... + }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" ]; + imports = [ + inputs.treefmt-nix.flakeModule + ./nix/default.nix + ]; }; - }); } diff --git a/nix/build.nix b/nix/build.nix new file mode 100644 index 0000000..9eddd16 --- /dev/null +++ b/nix/build.nix @@ -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/ + ''; + }; + } + ); +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..7507618 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,9 @@ +{ ... }: +{ + imports = [ + ./treefmt.nix + ./packages.nix + ./devshell.nix + ./build.nix + ]; +} diff --git a/nix/devshell.nix b/nix/devshell.nix new file mode 100644 index 0000000..55208c1 --- /dev/null +++ b/nix/devshell.nix @@ -0,0 +1,20 @@ +_: { + config.perSystem = + { + config, + inputs', + pkgs, + ... + }: + { + devShells = { + default = pkgs.mkShell { + nativeBuildInputs = config.buildPackages ++ config.develPackages ++ config.deployPackages; + shellHook = '' + ln -snf ${config.pelicanplugins} plugins + ln -snf ${config.pelicantheme} theme + ''; + }; + }; + }; +} diff --git a/nix/packages.nix b/nix/packages.nix new file mode 100644 index 0000000..c3bf8b9 --- /dev/null +++ b/nix/packages.nix @@ -0,0 +1,105 @@ +{ + 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; [ + python311 + python311Packages.markdown-include + python311Packages.pelican + python311Packages.typogrify + ]; + }; + develPackages = mkOption { + description = mdDoc "Python package used to development"; + type = types.listOf types.package; + default = with pkgs; [ + convco + go-task + lefthook + python3Packages.invoke + python3Packages.livereload + shellcheck + shfmt + typos + ]; + }; + deployPackages = mkOption { + description = mdDoc "Package use to deploy"; + type = types.listOf types.package; + default = with pkgs; [ + rsync + ]; + }; + 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 + ''; + } + ); + }; + }; + } + ); +} diff --git a/nix/treefmt.nix b/nix/treefmt.nix new file mode 100644 index 0000000..e9641c2 --- /dev/null +++ b/nix/treefmt.nix @@ -0,0 +1,18 @@ +_: { + config.perSystem = + { + config, + inputs', + pkgs, + ... + }: + { + treefmt = { + programs = { + shfmt.enable = true; + alejandra.enable = true; + nixfmt.enable = true; + }; + }; + }; +} From 160afdafa10456a7ce415b55917bd0f5bfda11f0 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Tue, 7 Jan 2025 01:53:49 +0100 Subject: [PATCH 11/14] chore: remove useless theme submodule --- .gitmodules | 3 --- theme | 1 - 2 files changed, 4 deletions(-) delete mode 100644 .gitmodules delete mode 160000 theme diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1cb184c..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "theme"] - path = theme - url = https://git.epha.se/ephase/attila_pelican_theme.git diff --git a/theme b/theme deleted file mode 160000 index 2730c99..0000000 --- a/theme +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2730c99463c7bc3906fb94742240f0796b9370f6 From 5954a5c53072d5ccf127c04f7d5226fd64e5e0d9 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Tue, 7 Jan 2025 23:02:22 +0100 Subject: [PATCH 12/14] chore: update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 84df769..5f8278f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ cache __pycache__ .direnv plugins +theme .env From 698e6fce01c5607fb5cb6e4c54dc30db57e3c1c4 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Tue, 7 Jan 2025 23:12:25 +0100 Subject: [PATCH 13/14] chore: remove useless import script --- content/articles/archives/script.sh | 1 - 1 file changed, 1 deletion(-) delete mode 100644 content/articles/archives/script.sh diff --git a/content/articles/archives/script.sh b/content/articles/archives/script.sh deleted file mode 100644 index bd8a3c4..0000000 --- a/content/articles/archives/script.sh +++ /dev/null @@ -1 +0,0 @@ -find . -type f -name '*.md; -exec sed -ie 's\Category: adminsys\Category: sysadmin\g' {} \; From 7fbf50918396dd42282edaf3a8dad54bc5608f35 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 8 Jan 2025 00:34:33 +0100 Subject: [PATCH 14/14] refactor(nix): rework package management --- nix/devshell.nix | 2 +- nix/packages.nix | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/nix/devshell.nix b/nix/devshell.nix index 55208c1..5a3d0ff 100644 --- a/nix/devshell.nix +++ b/nix/devshell.nix @@ -9,7 +9,7 @@ _: { { devShells = { default = pkgs.mkShell { - nativeBuildInputs = config.buildPackages ++ config.develPackages ++ config.deployPackages; + nativeBuildInputs = config.develPackages; shellHook = '' ln -snf ${config.pelicanplugins} plugins ln -snf ${config.pelicantheme} theme diff --git a/nix/packages.nix b/nix/packages.nix index c3bf8b9..d0e13d1 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -19,12 +19,11 @@ in buildPackages = mkOption { description = mdDoc "Python package used in the project"; type = types.listOf types.package; - default = with pkgs; [ - python311 - python311Packages.markdown-include - python311Packages.pelican - python311Packages.typogrify - ]; + default = ( with pkgs.python311Packages; [ + markdown-include + pelican + typogrify + ]); }; develPackages = mkOption { description = mdDoc "Python package used to development"; @@ -33,19 +32,18 @@ in convco go-task lefthook - python3Packages.invoke - python3Packages.livereload + rsync shellcheck shfmt typos - ]; - }; - deployPackages = mkOption { - description = mdDoc "Package use to deploy"; - type = types.listOf types.package; - default = with pkgs; [ - rsync - ]; + ] + ++ ( with pkgs.python311Packages; [ + markdown-include + pelican + typogrify + livereload + invoke + ]); }; pelicanplugins = mkOption { type = types.package;