Compare commits
2 commits
5dc4fef45e
...
75e05bcc68
Author | SHA1 | Date | |
---|---|---|---|
75e05bcc68 | |||
06b709f9e1 |
3 changed files with 26 additions and 37 deletions
|
@ -1,25 +1,30 @@
|
|||
{
|
||||
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}>
|
||||
'';
|
||||
}
|
||||
// listToAttrs (map (n: {
|
||||
name = "h${toString n}";
|
||||
value = text: extraArgs.h n text;
|
||||
}) [ 1 2 3 4 5 6 ]
|
||||
);
|
||||
};
|
||||
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;
|
||||
}) [ 1 2 3 4 5 6 ]
|
||||
);
|
||||
|
||||
entries = [
|
||||
./index.nix
|
||||
|
@ -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"; }
|
||||
];
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
created = "2024-05-22";
|
||||
content = /*html*/''
|
||||
<p>
|
||||
This is a test post on an example nte site. Feel free to read the <a href="#lorem-ipsum">lorem ipsum</a> below. Its header was generated using an additional helper function added to <code>extraArgs</code>
|
||||
This is a test post on an example nte site. Feel free to read the <a href="#lorem-ipsum">lorem ipsum</a> below. Its heading was generated using an additional helper function added to <code>extraArgs</code>
|
||||
</p>
|
||||
${h2 "Lorem ipsum"}
|
||||
<p>
|
||||
|
|
10
flake.nix
10
flake.nix
|
@ -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;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue