update example to use mkNteDerivation

This commit is contained in:
jacekpoz 2024-09-12 23:09:29 +02:00
parent 5dc4fef45e
commit 06b709f9e1
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
2 changed files with 25 additions and 36 deletions

View file

@ -1,23 +1,28 @@
{
lib,
nte,
stdenv,
mkNteDerivation,
...
}: let
inherit (lib.attrsets) listToAttrs;
inherit (lib.lists) map;
inherit (lib.strings) replaceStrings toLower;
extraArgs = {
extraArgs' = {
h = n: content: let
id = replaceStrings [" " ";"] ["-" "-"] (toLower content);
in /*html*/''
<h${toString n} id="${id}"><a href="#${id}">#</a> ${content}</h${toString n}>
'';
}
};
in mkNteDerivation {
name = "nte-example";
version = "0.1.0";
src = ./.;
extraArgs = extraArgs'
// listToAttrs (map (n: {
name = "h${toString n}";
value = text: extraArgs.h n text;
value = text: extraArgs'.h n text;
}) [ 1 2 3 4 5 6 ]
);
@ -31,27 +36,9 @@
./templates/base.nix
./templates/post.nix
];
in
stdenv.mkDerivation {
name = "nte-example";
version = "0.1.0";
src = ./.;
buildPhase = /*sh*/''
runHook preBuild
${nte {inherit extraArgs entries templates;}}
runHook postBuild
'';
installPhase = /*sh*/''
runHook preInstall
mkdir -p $out
cp -r ./*.css $out
cp -r ./posts/*.css $out/posts
runHook postInstall
'';
}
extraFiles = [
{ source = "./*.css"; destination = "/"; }
{ source = "./posts/*.css"; destination = "/posts"; }
];
}

View file

@ -10,14 +10,15 @@
forEachSystem = nixpkgs.lib.genAttrs (import systems);
pkgsForEach = nixpkgs.legacyPackages;
enginesForEach = import ./engine.nix;
mkNteDerivationsForEach = import ./nte-drv.nix;
in {
functions = forEachSystem (
system: let
pkgs = pkgsForEach.${system};
engine = enginesForEach pkgs;
mkNteDerivation = mkNteDerivationsForEach pkgs engine;
in {
inherit engine;
mkNteDerivation = import ./nte-drv.nix pkgs engine;
inherit engine mkNteDerivation;
}
);
@ -33,10 +34,11 @@
system: let
pkgs = pkgsForEach.${system};
engine = enginesForEach pkgs;
mkNteDerivation = mkNteDerivationsForEach pkgs engine;
in {
default = import ./example/default.nix {
inherit (pkgs) lib stdenv;
nte = engine ./example;
inherit (pkgs) lib;
inherit mkNteDerivation;
};
}
);