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
This commit is contained in:
parent
440e26fb63
commit
ffea2b6857
8 changed files with 268 additions and 79 deletions
1
.envrc
1
.envrc
|
@ -1 +1,2 @@
|
||||||
|
watch_files .envrc flake.nix nix/*.nix
|
||||||
use flake
|
use flake
|
||||||
|
|
80
flake.lock
generated
80
flake.lock
generated
|
@ -1,43 +1,72 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710146030,
|
"lastModified": 1735774679,
|
||||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
"narHash": "sha256-soePLBazJk0qQdDVhdbM98vYdssfs3WFedcq+raipRI=",
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
"rev": "f2f7418ce0ab4a5309a4596161d154cfc877af66",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1716361217,
|
"lastModified": 1735834308,
|
||||||
"narHash": "sha256-mzZDr00WUiUXVm1ujBVv6A0qRd8okaITyUp4ezYRgc4=",
|
"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",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "46397778ef1f73414b03ed553a3368f0e7e33c2f",
|
"rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"ref": "nixos-23.11",
|
"ref": "nixpkgs-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"systems": "systems",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
|
@ -50,8 +79,25 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"id": "systems",
|
||||||
"repo": "default",
|
"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"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
80
flake.nix
80
flake.nix
|
@ -1,68 +1,24 @@
|
||||||
{
|
{
|
||||||
description = "Development shell for Personal blog";
|
description = "Nix flake for my personal blog";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
flake-utils = {
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
url = "github:numtide/flake-utils";
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { nixpkgs , flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
|
outputs =
|
||||||
let
|
inputs@{
|
||||||
pkgs = import nixpkgs {
|
nixpkgs,
|
||||||
inherit system;
|
flake-parts,
|
||||||
};
|
systems,
|
||||||
pelicanplugins-neighbors = ( with pkgs; stdenv.mkDerivation {
|
...
|
||||||
pname = "pelicanplugins-neighbors";
|
}:
|
||||||
version = "1.2.0";
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
src = pkgs.fetchFromGitHub {
|
systems = [ "x86_64-linux" ];
|
||||||
owner = "pelican-plugins";
|
imports = [
|
||||||
repo = "neighbors";
|
inputs.treefmt-nix.flakeModule
|
||||||
rev = "60649ac6f3494d01a37b9c6d3d455f9dc2502d55";
|
./nix/default.nix
|
||||||
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"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
34
nix/build.nix
Normal file
34
nix/build.nix
Normal 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
9
nix/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./treefmt.nix
|
||||||
|
./packages.nix
|
||||||
|
./devshell.nix
|
||||||
|
./build.nix
|
||||||
|
];
|
||||||
|
}
|
20
nix/devshell.nix
Normal file
20
nix/devshell.nix
Normal file
|
@ -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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
105
nix/packages.nix
Normal file
105
nix/packages.nix
Normal file
|
@ -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
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
18
nix/treefmt.nix
Normal file
18
nix/treefmt.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
_: {
|
||||||
|
config.perSystem =
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
inputs',
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
treefmt = {
|
||||||
|
programs = {
|
||||||
|
shfmt.enable = true;
|
||||||
|
alejandra.enable = true;
|
||||||
|
nixfmt.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue