feat(nix): user flake instead regular shell.nix

This commit is contained in:
Yorick Barbanneau 2025-01-28 23:03:53 +01:00
parent b5179b97ac
commit 558fc24911
6 changed files with 248 additions and 26 deletions

8
nix/default.nix Normal file
View file

@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./packages.nix
./devshells.nix
];
}

28
nix/devshells.nix Normal file
View file

@ -0,0 +1,28 @@
_: {
config.perSystem =
{
config,
inputs',
pkgs,
...
}:
{
devShells = {
default = pkgs.mkShell {
name = "hugo-shell";
nativeBuildInputs = config.develPackages
++ config.hugoBuildPackages
;
shellook = ''
mkdir -p themes
ln -snf "${config.themePackage}/" "themes/mainroad"
'';
};
latex = pkgs.mkShell {
name = "latex-shell";
nativeBuildInputs = config.develPackages
++ config.latexBuildPackages;
};
};
};
}

81
nix/packages.nix Normal file
View file

@ -0,0 +1,81 @@
{
lib,
inputs,
...
}:
let
inherit (lib) mkOption mdDoc types;
inherit (inputs.flake-parts.lib) mkPerSystemOption;
in
{
options.perSystem = mkPerSystemOption (
{
pkgs,
config,
...
}:
{
options = {
latexBuildPackages = mkOption {
description = mdDoc "Packages needed to build latex file";
type = types.listOf types.package;
default = with pkgs; [
(pkgs.texlive.combine {
inherit (pkgs.texlive)
babel-french
caption
collection-luatex
float
fontawesome
fontspec
lato
libertine
listings
lstfiracode
pdfpages
pdflscape
scheme-basic
soul
titlesec
xcolor
;
})
fira-code
];
};
hugoBuildPackages = mkOption {
description = mdDoc "Packages needed to build latex file";
type = types.listOf types.package;
default = with pkgs; [
hugo
];
};
themePackage = mkOption {
description = mdDoc "Theme user for my course note";
default = pkgs.stdenvNoCC.mkDerivation {
name = "hugo-theme-mainroad";
pname = "hugo-theme-mainroad";
src = pkgs.fetchFromGitHub {
owner = "vimux";
repo = "mainroad";
rev = "13e04b3694ea2d20a68cfbfaea42a8c565079809";
sha256 = "sha256-td8xQhAz/TnjZmOKIEiQjRgzdoicRrVN9h41Uxnnaso=";
};
installPhase = ''
cp -r $src $out
'';
};
};
develPackages = mkOption {
description = mdDoc "Python package used to development";
type = types.listOf types.package;
default = with pkgs; [
convco
go-task
];
};
};
});
}