chore(son): search.infra.dgnum.eu is live
This commit is contained in:
parent
b6b25d5f35
commit
57de9d22a6
13 changed files with 0 additions and 637 deletions
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
@ -12,7 +11,6 @@
|
||||||
imports = [
|
imports = [
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./disks.nix
|
./disks.nix
|
||||||
./doc
|
|
||||||
];
|
];
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
|
@ -89,116 +87,6 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
extranix = {
|
|
||||||
enable = true;
|
|
||||||
modules = {
|
|
||||||
"netconf" =
|
|
||||||
let
|
|
||||||
netconf = pkgs.fetchgit {
|
|
||||||
url = "https://git.dgnum.eu/DGNum/Netconf-Module.git";
|
|
||||||
rev = "8f58ee21fe9c0ad22e3f16e58c3837c1c97eb5e8";
|
|
||||||
outputHash = "sha256-OXKSFEOjeeRFVbVodJSkhuT+r7+p6QPUzjbw2vs6Xao=";
|
|
||||||
name = "netconf";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
paths = [
|
|
||||||
"${netconf.outPath}/junos"
|
|
||||||
"${netconf.outPath}/dgn-module.nix"
|
|
||||||
];
|
|
||||||
path-translations = [
|
|
||||||
{
|
|
||||||
base = netconf.outPath;
|
|
||||||
url = "https://git.dgnum.eu/DGNum/Netconf-Module/src/branch/master/";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
"infra DGNum" =
|
|
||||||
let
|
|
||||||
infra = pkgs.fetchgit {
|
|
||||||
url = "https://git.dgnum.eu/DGNum/infrastructure.git";
|
|
||||||
rev = "417ce615079ca26e1251e7f0b6b24c36b293a17d";
|
|
||||||
outputHash = "sha256-LhjQoVZqYARpUxuuWhcNY7HLE64H8PIIBZ0QwlmGD2I=";
|
|
||||||
name = "DGN-infra";
|
|
||||||
};
|
|
||||||
infra-hive = import "${infra}/hive.nix";
|
|
||||||
infra-source = infra-hive.meta.specialArgs.sources;
|
|
||||||
infra-nixpkgs = infra-hive.meta.nixpkgs { };
|
|
||||||
infra-modulesPath = "${infra-nixpkgs.path}/nixos/modules/";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
paths = [
|
|
||||||
"${infra}/modules/generic"
|
|
||||||
"${infra}/modules/nixos"
|
|
||||||
];
|
|
||||||
ignored-modules = import "${infra-modulesPath}/module-list.nix" ++ [
|
|
||||||
"${infra-source.agenix}/modules/age.nix"
|
|
||||||
"${infra-source.arkheon}/module.nix"
|
|
||||||
"${infra-source."microvm.nix"}/nixos-modules/host"
|
|
||||||
{ system.stateVersion = "25.05"; }
|
|
||||||
];
|
|
||||||
specialArgs = {
|
|
||||||
lib = infra-nixpkgs.lib // {
|
|
||||||
extra = import "${infra}/lib/nix-lib";
|
|
||||||
};
|
|
||||||
modulesPath = infra-modulesPath;
|
|
||||||
pkgs = infra-nixpkgs;
|
|
||||||
name = "<nodeName>";
|
|
||||||
nodeMeta = {
|
|
||||||
nix-modules = [ ];
|
|
||||||
admins = [ ];
|
|
||||||
adminGroups = [ ];
|
|
||||||
};
|
|
||||||
meta = {
|
|
||||||
organization.groups.root = [ ];
|
|
||||||
};
|
|
||||||
sources = infra-source;
|
|
||||||
};
|
|
||||||
path-translations = [
|
|
||||||
{
|
|
||||||
base = infra.outPath;
|
|
||||||
url = "https://git.dgnum.eu/DGNum/infrastructure/src/branch/main/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
base = infra-source.nix-modules;
|
|
||||||
url = "https://git.hubrecht.ovh/hubrecht/nix-modules/src/branch/main/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
base = infra-modulesPath;
|
|
||||||
url = "https://github.com/NixOS/nixpkgs/tree/master/nixos/modules";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
base = infra-source.cgroup-exporter;
|
|
||||||
url = "https://github.com/arianvp/cgroup-exporter/blob/main/";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
static-data = ./static-data;
|
|
||||||
host = "son.katvayor.net";
|
|
||||||
settings = {
|
|
||||||
baseUrl = "https://dgnum.eu/";
|
|
||||||
title = "DGNum module documentation";
|
|
||||||
languageCode = "en-us";
|
|
||||||
params = {
|
|
||||||
release_current_stable = "infra-DGNum";
|
|
||||||
logo = "images/dgnum.png";
|
|
||||||
footer_credits_line = ''
|
|
||||||
Powered by catvayor |
|
|
||||||
Based on <a href="https://github.com/mipmip/home-manager-option-search">Home Manager Option Search</a>
|
|
||||||
'';
|
|
||||||
footer_copyright_line = ''
|
|
||||||
Made by catvayor for the <a href="https://dgnum.eu">DGNum</a>.
|
|
||||||
'';
|
|
||||||
main_menu = [
|
|
||||||
{
|
|
||||||
name = ''<img src="images/forgejo.png" style="display:inline-block; height:2.5em; transform:translate(0, -0.7em)" /> Source'';
|
|
||||||
url = "https://git.dgnum.eu/DGNum/Netconf-Module/";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
system.stateVersion = "23.11";
|
system.stateVersion = "23.11";
|
||||||
|
|
|
@ -1,147 +0,0 @@
|
||||||
From 5e5f68209b3b023fce260c9da1625844ca4d3c22 Mon Sep 17 00:00:00 2001
|
|
||||||
From: catvayor <catvayor@katvayor.net>
|
|
||||||
Date: Mon, 16 Dec 2024 00:11:47 +0100
|
|
||||||
Subject: [PATCH 1/2] revert: don't parse md in js
|
|
||||||
|
|
||||||
---
|
|
||||||
static/js/script.js | 106 +-------------------------------------------
|
|
||||||
1 file changed, 2 insertions(+), 104 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/static/js/script.js b/static/js/script.js
|
|
||||||
index 04234d7..d3ec223 100644
|
|
||||||
--- a/static/js/script.js
|
|
||||||
+++ b/static/js/script.js
|
|
||||||
@@ -27,97 +27,6 @@ function encodeAttr(str) {
|
|
||||||
return (str+'').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
||||||
}
|
|
||||||
|
|
||||||
-/** Parse Markdown into an HTML String. */
|
|
||||||
-function parseMD(md, prevLinks) {
|
|
||||||
- let tokenizer = /((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,
|
|
||||||
- context = [],
|
|
||||||
- out = '',
|
|
||||||
- links = prevLinks || {},
|
|
||||||
- last = 0,
|
|
||||||
- chunk, prev, token, inner, t;
|
|
||||||
-
|
|
||||||
- function tag(token) {
|
|
||||||
- let desc = TAGS[token[1] || ''];
|
|
||||||
- let end = context[context.length-1] == token;
|
|
||||||
- if (!desc) return token;
|
|
||||||
- if (!desc[1]) return desc[0];
|
|
||||||
- if (end) context.pop();
|
|
||||||
- else context.push(token);
|
|
||||||
- return desc[end|0];
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- function flush() {
|
|
||||||
- let str = '';
|
|
||||||
- while (context.length) str += tag(context[context.length-1]);
|
|
||||||
- return str;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- md = md.replace(/^\[(.+?)\]:\s*(.+)$/gm, (s, name, url) => {
|
|
||||||
- links[name.toLowerCase()] = url;
|
|
||||||
- return '';
|
|
||||||
- }).replace(/^\n+|\n+$/g, '');
|
|
||||||
-
|
|
||||||
- while ( (token=tokenizer.exec(md)) ) {
|
|
||||||
- prev = md.substring(last, token.index);
|
|
||||||
- last = tokenizer.lastIndex;
|
|
||||||
- chunk = token[0];
|
|
||||||
- if (prev.match(/[^\\](\\\\)*\\$/)) {
|
|
||||||
- // escaped
|
|
||||||
- }
|
|
||||||
- // Code/Indent blocks:
|
|
||||||
- else if (t = (token[3] || token[4])) {
|
|
||||||
- chunk = '<pre class="code '+(token[4]?'poetry':token[2].toLowerCase())+'"><code'+(token[2] ? ` class="language-${token[2].toLowerCase()}"` : '')+'>'+outdent(encodeAttr(t).replace(/^\n+|\n+$/g, ''))+'</code></pre>';
|
|
||||||
- }
|
|
||||||
- // > Quotes, -* lists:
|
|
||||||
- else if (t = token[6]) {
|
|
||||||
- if (t.match(/\./)) {
|
|
||||||
- token[5] = token[5].replace(/^\d+/gm, '');
|
|
||||||
- }
|
|
||||||
- inner = parse(outdent(token[5].replace(/^\s*[>*+.-]/gm, '')));
|
|
||||||
- if (t=='>') t = 'blockquote';
|
|
||||||
- else {
|
|
||||||
- t = t.match(/\./) ? 'ol' : 'ul';
|
|
||||||
- inner = inner.replace(/^(.*)(\n|$)/gm, '<li>$1</li>');
|
|
||||||
- }
|
|
||||||
- chunk = '<'+t+'>' + inner + '</'+t+'>';
|
|
||||||
- }
|
|
||||||
- // Images:
|
|
||||||
- else if (token[8]) {
|
|
||||||
- chunk = `<img src="${encodeAttr(token[8])}" alt="${encodeAttr(token[7])}">`;
|
|
||||||
- }
|
|
||||||
- // Links:
|
|
||||||
- else if (token[10]) {
|
|
||||||
- out = out.replace('<a>', `<a href="${encodeAttr(token[11] || links[prev.toLowerCase()])}">`);
|
|
||||||
- chunk = flush() + '</a>';
|
|
||||||
- }
|
|
||||||
- else if (token[9]) {
|
|
||||||
- chunk = '<a>';
|
|
||||||
- }
|
|
||||||
- // Headings:
|
|
||||||
- else if (token[12] || token[14]) {
|
|
||||||
- t = 'h' + (token[14] ? token[14].length : (token[13]>'=' ? 1 : 2));
|
|
||||||
- chunk = '<'+t+'>' + parse(token[12] || token[15], links) + '</'+t+'>';
|
|
||||||
- }
|
|
||||||
- // `code`:
|
|
||||||
- else if (token[16]) {
|
|
||||||
- chunk = '<code>'+encodeAttr(token[16])+'</code>';
|
|
||||||
- }
|
|
||||||
- // Inline formatting: *em*, **strong** & friends
|
|
||||||
- else if (token[17] || token[1]) {
|
|
||||||
- chunk = tag(token[17] || '--');
|
|
||||||
- }
|
|
||||||
- out += prev;
|
|
||||||
- out += chunk;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return (out + md.substring(last) + flush()).replace(/^\n+|\n+$/g, '');
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-
|
|
||||||
-/*************************
|
|
||||||
- * END MARKDOWN PARSER
|
|
||||||
- */
|
|
||||||
-
|
|
||||||
|
|
||||||
var search, results, allOptions, currentSet = [];
|
|
||||||
var lastUpdate = "?";
|
|
||||||
@@ -254,22 +163,11 @@ var updateOptionsTable = function(options) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-function parseDescription(text){
|
|
||||||
-
|
|
||||||
- text = text.replace(/<https(\s*([^>]*))/gi ,'<a href="https$1"><https$1</a>');
|
|
||||||
- text = text.replace(/\[\]\(#opt-(\s*([^)]*))/gi ,'<strong>$1</strong>').replace(/\)/gi,'');
|
|
||||||
- //[](#opt-wayland.windowManager.hyprland.plugins)
|
|
||||||
- text = text.replace(/\{var\}(\s*([^\n]*))/gi ,'<strong>$1</strong>').replace(/`/gi,'')
|
|
||||||
- text = text.replace(/:::\ \{\.note\}(\s*([^:::]*))/gi ,'<div class="alert alert-info" role="alert">$1</div>').replace(/:::/,'').replace(/\n/g, '<br />')
|
|
||||||
- return text;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
var expandOptionMD = function(el){
|
|
||||||
|
|
||||||
modalTitle.innerHTML = currentSet[el].title;
|
|
||||||
|
|
||||||
- let dhtml = parseMD(currentSet[el].doc);
|
|
||||||
- var elDesc = "<h5 style='margin:1em 0 0 0'>Description</h5><div>" + dhtml + "</div>";
|
|
||||||
+ var elDesc = "<h5 style='margin:1em 0 0 0'>Description</h5><div>" + currentSet[el].doc + "</div>";
|
|
||||||
var elArgs = "<h5 style='margin:1em 0 0 0'>Args</h5><div>" + currentSet[el].args.join(', ') + "</div>";
|
|
||||||
// var elNote = ( currentSet[el].note == "" ? "": "<h5 style='margin:1em 0 0 0'>Note</h5><div>" + currentSet[el].note + "</div>");
|
|
||||||
// var elDefault = "<h5 style='margin:1em 0 0 0'>Default</h5><div><pre style='margin-top:0.5em'>" + currentSet[el].default + "</pre></div>";
|
|
||||||
@@ -290,7 +188,7 @@ var expandOption = function(el){
|
|
||||||
|
|
||||||
//console.log(currentSet[el].description.replace(/:::\ \{\.note\}(\s*([^:::]*))/gi ,'<div class="alert alert-info" role="alert">$1</div>').replace(/:::/,''));
|
|
||||||
|
|
||||||
- var elDesc = "<h5 style='margin:1em 0 0 0'>Description</h5><div>" + parseDescription(currentSet[el].description) + "</div>";
|
|
||||||
+ var elDesc = "<h5 style='margin:1em 0 0 0'>Description</h5><div>" + currentSet[el].description + "</div>";
|
|
||||||
var elType = "<h5 style='margin:1em 0 0 0'>Type</h5><div>" + currentSet[el].type + "</div>";
|
|
||||||
//var elNote = ( currentSet[el].note == "" ? "": "<h5 style='margin:1em 0 0 0'>Note</h5><div>" + currentSet[el].note + "</div>");
|
|
||||||
var elDefault = ( currentSet[el].default == "" ? "" : "<h5 style='margin:1em 0 0 0'>Default</h5><div><pre style='margin-top:0.5em'>" + currentSet[el].default + "</pre></div>");
|
|
||||||
--
|
|
||||||
2.47.0
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
From 957189be0a61f954a1bcfb204f982f59ae6435ea Mon Sep 17 00:00:00 2001
|
|
||||||
From: catvayor <catvayor@katvayor.net>
|
|
||||||
Date: Thu, 12 Dec 2024 17:04:45 +0100
|
|
||||||
Subject: [PATCH 2/2] chore: remove useless dependencies
|
|
||||||
|
|
||||||
---
|
|
||||||
layouts/index.html | 1 -
|
|
||||||
1 file changed, 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/layouts/index.html b/layouts/index.html
|
|
||||||
index 63a6158..780ea78 100644
|
|
||||||
--- a/layouts/index.html
|
|
||||||
+++ b/layouts/index.html
|
|
||||||
@@ -17,7 +17,6 @@
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
|
|
||||||
<link href="css/nucleus.css" rel="stylesheet">
|
|
||||||
<link href="css/style-nix.css" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="css/style-q2.css">
|
|
||||||
--
|
|
||||||
2.47.0
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
From b0f6c845280bee20bcc28a136436e000bde8a457 Mon Sep 17 00:00:00 2001
|
|
||||||
From: catvayor <catvayor@katvayor.net>
|
|
||||||
Date: Mon, 16 Dec 2024 11:25:38 +0100
|
|
||||||
Subject: [PATCH] feat: separate HTML description of MD description
|
|
||||||
|
|
||||||
---
|
|
||||||
static/js/script.js | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/static/js/script.js b/static/js/script.js
|
|
||||||
index d3ec223..5d9fc6e 100644
|
|
||||||
--- a/static/js/script.js
|
|
||||||
+++ b/static/js/script.js
|
|
||||||
@@ -188,7 +188,7 @@ var expandOption = function(el){
|
|
||||||
|
|
||||||
//console.log(currentSet[el].description.replace(/:::\ \{\.note\}(\s*([^:::]*))/gi ,'<div class="alert alert-info" role="alert">$1</div>').replace(/:::/,''));
|
|
||||||
|
|
||||||
- var elDesc = "<h5 style='margin:1em 0 0 0'>Description</h5><div>" + currentSet[el].description + "</div>";
|
|
||||||
+ var elDesc = "<h5 style='margin:1em 0 0 0'>Description</h5><div>" + currentSet[el].descriptionHTML + "</div>";
|
|
||||||
var elType = "<h5 style='margin:1em 0 0 0'>Type</h5><div>" + currentSet[el].type + "</div>";
|
|
||||||
//var elNote = ( currentSet[el].note == "" ? "": "<h5 style='margin:1em 0 0 0'>Note</h5><div>" + currentSet[el].note + "</div>");
|
|
||||||
var elDefault = ( currentSet[el].default == "" ? "" : "<h5 style='margin:1em 0 0 0'>Default</h5><div><pre style='margin-top:0.5em'>" + currentSet[el].default + "</pre></div>");
|
|
||||||
--
|
|
||||||
2.47.0
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
From e31e0330b9b012b6e09f8eb6bc670e4336d1aedc Mon Sep 17 00:00:00 2001
|
|
||||||
From: catvayor <catvayor@katvayor.net>
|
|
||||||
Date: Mon, 16 Dec 2024 12:53:27 +0100
|
|
||||||
Subject: [PATCH] fix: indentation of <ul>
|
|
||||||
|
|
||||||
---
|
|
||||||
static/css/nucleus.css | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/static/css/nucleus.css b/static/css/nucleus.css
|
|
||||||
index a4674a8..9ada521 100644
|
|
||||||
--- a/static/css/nucleus.css
|
|
||||||
+++ b/static/css/nucleus.css
|
|
||||||
@@ -533,7 +533,8 @@ p {
|
|
||||||
|
|
||||||
ul, ol {
|
|
||||||
margin-top: 1.7rem;
|
|
||||||
- margin-bottom: 1.7rem; }
|
|
||||||
+ margin-bottom: 1.7rem;
|
|
||||||
+ margin-left: 1rem; }
|
|
||||||
ul ul, ul ol, ol ul, ol ol {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0; }
|
|
||||||
--
|
|
||||||
2.47.0
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
From 206ce2744cdaa166ee482fba90a879f2688b234a Mon Sep 17 00:00:00 2001
|
|
||||||
From: catvayor <catvayor@katvayor.net>
|
|
||||||
Date: Sat, 21 Dec 2024 10:14:46 +0100
|
|
||||||
Subject: [PATCH] feat: match all substring by default
|
|
||||||
|
|
||||||
---
|
|
||||||
layouts/index.html | 4 ++--
|
|
||||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/layouts/index.html b/layouts/index.html
|
|
||||||
index 780ea78..c50ada4 100644
|
|
||||||
--- a/layouts/index.html
|
|
||||||
+++ b/layouts/index.html
|
|
||||||
@@ -109,9 +109,9 @@
|
|
||||||
<li>Strategy</li>
|
|
||||||
<li>
|
|
||||||
<select id="indexStrategySelect" style="margin-bottom:0">
|
|
||||||
- <option value="JsSearch.AllSubstringsIndexStrategy">All substrings</option>
|
|
||||||
+ <option value="JsSearch.AllSubstringsIndexStrategy" selected>All substrings</option>
|
|
||||||
<option value="JsSearch.ExactWordIndexStrategy">Exact match</option>
|
|
||||||
- <option value="JsSearch.PrefixIndexStrategy" selected>Prefix matching</option>
|
|
||||||
+ <option value="JsSearch.PrefixIndexStrategy">Prefix matching</option>
|
|
||||||
</select>
|
|
||||||
</li>
|
|
||||||
</div>
|
|
||||||
--
|
|
||||||
2.47.0
|
|
||||||
|
|
|
@ -1,182 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (lib)
|
|
||||||
mkOption
|
|
||||||
mkEnableOption
|
|
||||||
mkIf
|
|
||||||
types
|
|
||||||
importJSON
|
|
||||||
mapAttrs'
|
|
||||||
mapAttrsToList
|
|
||||||
removePrefix
|
|
||||||
pathIsDirectory
|
|
||||||
hasSuffix
|
|
||||||
hasPrefix
|
|
||||||
attrNames
|
|
||||||
filter
|
|
||||||
head
|
|
||||||
getExe
|
|
||||||
;
|
|
||||||
inherit (lib.strings)
|
|
||||||
sanitizeDerivationName
|
|
||||||
;
|
|
||||||
yaml = pkgs.formats.yaml { };
|
|
||||||
json = pkgs.formats.json { };
|
|
||||||
cfg = config.services.extranix;
|
|
||||||
|
|
||||||
module-eval =
|
|
||||||
module-name: module:
|
|
||||||
let
|
|
||||||
ignored-eval = lib.evalModules {
|
|
||||||
modules = module.ignored-modules;
|
|
||||||
inherit (module) specialArgs;
|
|
||||||
};
|
|
||||||
ignored-opts-doc = pkgs.nixosOptionsDoc { inherit (ignored-eval) options; };
|
|
||||||
ignored-opts = importJSON "${ignored-opts-doc.optionsJSON}/share/doc/nixos/options.json";
|
|
||||||
eval = lib.evalModules {
|
|
||||||
modules = module.paths ++ module.ignored-modules;
|
|
||||||
inherit (module) specialArgs;
|
|
||||||
};
|
|
||||||
opts-doc = pkgs.nixosOptionsDoc { inherit (eval) options; };
|
|
||||||
opts = importJSON "${opts-doc.optionsJSON}/share/doc/nixos/options.json";
|
|
||||||
filtered-opts = removeAttrs opts (attrNames ignored-opts);
|
|
||||||
path-translation =
|
|
||||||
let
|
|
||||||
translations = map (
|
|
||||||
{ base, url }:
|
|
||||||
{
|
|
||||||
url = "${url}${if hasSuffix "/" url then "" else "/"}";
|
|
||||||
base =
|
|
||||||
let
|
|
||||||
base1 = toString base;
|
|
||||||
in
|
|
||||||
base1 + (if hasSuffix "/" base1 then "" else "/");
|
|
||||||
}
|
|
||||||
) module.path-translations;
|
|
||||||
in
|
|
||||||
path:
|
|
||||||
let
|
|
||||||
fullPath = path + (if pathIsDirectory path then "/default.nix" else "");
|
|
||||||
fitting = filter ({ base, ... }: hasPrefix base fullPath) translations;
|
|
||||||
translate-info = head (
|
|
||||||
fitting ++ [ (throw "${fullPath} is not in any base path of ${module-name}") ]
|
|
||||||
);
|
|
||||||
innerPath = removePrefix translate-info.base fullPath;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
name = "<${innerPath}>";
|
|
||||||
url = "${translate-info.url}${innerPath}";
|
|
||||||
};
|
|
||||||
result' = json.generate "options-extranix-fileDesc.json" {
|
|
||||||
last_update = "-/-";
|
|
||||||
options = mapAttrsToList (title: val: {
|
|
||||||
inherit title;
|
|
||||||
inherit (val)
|
|
||||||
type
|
|
||||||
readOnly
|
|
||||||
loc
|
|
||||||
description
|
|
||||||
;
|
|
||||||
descriptionHTML = pkgs.runCommand "option-${title}.html" { } ''
|
|
||||||
${getExe pkgs.pandoc} -f markdown ${pkgs.writeText "option-${title}.md" val.description} > $out
|
|
||||||
'';
|
|
||||||
example = val.example.text or "";
|
|
||||||
default = val.default.text or "";
|
|
||||||
declarations = map path-translation val.declarations;
|
|
||||||
}) filtered-opts;
|
|
||||||
};
|
|
||||||
result =
|
|
||||||
pkgs.runCommand "options-extranix.json"
|
|
||||||
{
|
|
||||||
nativeBuildInputs = [ pkgs.jq ];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
jq -r '.options[].descriptionHTML | "--rawfile\n" + . + "\n" + .' ${result'} | xargs \
|
|
||||||
jq -c '.options |= map(.descriptionHTML as $desc | .descriptionHTML |= $ARGS.named.[$desc])' ${result'} \
|
|
||||||
> $out
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
result;
|
|
||||||
|
|
||||||
options-files = mapAttrs' (name: value: {
|
|
||||||
name = sanitizeDerivationName name;
|
|
||||||
value = module-eval name value;
|
|
||||||
}) cfg.modules;
|
|
||||||
|
|
||||||
webroot = pkgs.callPackage ./webroot.nix {
|
|
||||||
inherit options-files;
|
|
||||||
inherit (cfg) static-data;
|
|
||||||
settings = yaml.generate "config.yaml" cfg.settings;
|
|
||||||
hugo-theme-extranix-options-search = pkgs.callPackage ./hugo-theme-extranix-options-search.nix { };
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.services.extranix = {
|
|
||||||
enable = mkEnableOption "extranix documentation";
|
|
||||||
modules = mkOption {
|
|
||||||
type =
|
|
||||||
let
|
|
||||||
module-mod.options = {
|
|
||||||
specialArgs = mkOption {
|
|
||||||
type = types.attrs;
|
|
||||||
default = { };
|
|
||||||
};
|
|
||||||
paths = mkOption {
|
|
||||||
type = types.listOf types.deferredModule;
|
|
||||||
};
|
|
||||||
ignored-modules = mkOption {
|
|
||||||
type = types.listOf types.deferredModule;
|
|
||||||
default = [ ];
|
|
||||||
};
|
|
||||||
path-translations = mkOption {
|
|
||||||
type =
|
|
||||||
let
|
|
||||||
path-mod.options = {
|
|
||||||
base = mkOption {
|
|
||||||
type = types.path;
|
|
||||||
};
|
|
||||||
url = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
types.listOf (types.submodule path-mod);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
types.attrsOf (types.submodule module-mod);
|
|
||||||
};
|
|
||||||
settings = mkOption {
|
|
||||||
type = yaml.type;
|
|
||||||
};
|
|
||||||
static-data = mkOption {
|
|
||||||
type = types.path;
|
|
||||||
};
|
|
||||||
host = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
services = {
|
|
||||||
extranix = {
|
|
||||||
settings = {
|
|
||||||
markup.goldmark.renderer.unsafe = true;
|
|
||||||
theme = "extranix-options-search";
|
|
||||||
params.releases = mapAttrsToList (name: _: {
|
|
||||||
inherit name;
|
|
||||||
value = sanitizeDerivationName name;
|
|
||||||
}) cfg.modules;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
nginx = {
|
|
||||||
enable = true;
|
|
||||||
virtualHosts.${cfg.host}.locations."/".alias = "${webroot}/";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
{
|
|
||||||
fetchFromGitHub,
|
|
||||||
stdenv,
|
|
||||||
lib,
|
|
||||||
fetchurl,
|
|
||||||
}:
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "hugo-theme-extranix-options-search";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "mipmip";
|
|
||||||
repo = "hugo-theme-extranix-options-search";
|
|
||||||
rev = "3252b5bd98adcbbe629327d72c8416c25014a0d6";
|
|
||||||
hash = "sha256-XV7Js1KaBiWv9qao8iyzQ546nT1KkwCtvyAs++oeXFo=";
|
|
||||||
};
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
./0001-revert-don-t-parse-md-in-js.patch
|
|
||||||
./0002-chore-remove-useless-dependencies.patch
|
|
||||||
./0003-feat-separate-HTML-description-of-MD-description.patch
|
|
||||||
./0004-fix-indentation-of-ul.patch
|
|
||||||
./0005-feat-match-all-substring-by-default.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
installPhase =
|
|
||||||
let
|
|
||||||
js-search = fetchurl {
|
|
||||||
url = "https://unpkg.com/js-search@2.0.1/dist/umd/js-search.min.js";
|
|
||||||
hash = "sha256-LD9UsSATk+xTzAbk8nD2gA2bjHKvetXtCMDAFkM2K5Q=";
|
|
||||||
};
|
|
||||||
jquery = fetchurl {
|
|
||||||
url = "https://code.jquery.com/jquery-3.7.1.slim.min.js";
|
|
||||||
hash = "sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=";
|
|
||||||
};
|
|
||||||
bootstrap.css.main = fetchurl {
|
|
||||||
url = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css";
|
|
||||||
hash = "sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=";
|
|
||||||
};
|
|
||||||
bootstrap.css.theme = fetchurl {
|
|
||||||
url = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css";
|
|
||||||
hash = "sha256-ZT4HPpdCOt2lvDkXokHuhJfdOKSPFLzeAJik5U/Q+l4=";
|
|
||||||
};
|
|
||||||
bootstrap.js = fetchurl {
|
|
||||||
url = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js";
|
|
||||||
hash = "sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
''
|
|
||||||
mkdir $out
|
|
||||||
rm static/images/favicon.*
|
|
||||||
cp -r * $out
|
|
||||||
cp ${js-search} $out/static/js/js-search.min.js
|
|
||||||
cp ${jquery} $out/static/js/jquery.slim.min.js
|
|
||||||
cp ${bootstrap.css.main} $out/static/css/bootstrap.min.css
|
|
||||||
cp ${bootstrap.css.theme} $out/static/css/bootstrap-theme.min.css
|
|
||||||
cp ${bootstrap.js} $out/static/js/bootstrap.min.js
|
|
||||||
substituteInPlace $out/layouts/index.html \
|
|
||||||
--replace-fail 'https://unpkg.com/js-search@2.0.1/dist/umd/js-search.min.js' js/js-search.min.js \
|
|
||||||
--replace-fail 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js' js/jquery.slim.min.js \
|
|
||||||
--replace-fail 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' css/bootstrap.min.css \
|
|
||||||
--replace-fail 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css' css/bootstrap-theme.min.css \
|
|
||||||
--replace-fail 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' js/bootstrap.min.js \
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "Theme which implements a nix modules options search machine.";
|
|
||||||
homepage = "https://github.com/mipmip/hugo-theme-extranix-options-search";
|
|
||||||
license = lib.licenses.asl20;
|
|
||||||
maintainers = [ ];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
hugo,
|
|
||||||
hugo-theme-extranix-options-search,
|
|
||||||
options-files,
|
|
||||||
settings,
|
|
||||||
static-data,
|
|
||||||
lib,
|
|
||||||
runCommand,
|
|
||||||
}:
|
|
||||||
runCommand "nix-doc-webroot" { }
|
|
||||||
''
|
|
||||||
mkdir themes
|
|
||||||
ln -s ${hugo-theme-extranix-options-search} themes/extranix-options-search
|
|
||||||
cp -rs ${static-data} static
|
|
||||||
chmod -R u+w static
|
|
||||||
mkdir static/data
|
|
||||||
${lib.concatStringsSep "\n" (
|
|
||||||
lib.mapAttrsToList (name: file: "ln -s ${file} static/data/options-${name}.json") options-files
|
|
||||||
)}
|
|
||||||
ln -s ${settings} config.yaml
|
|
||||||
${lib.getExe hugo} --noBuildLock -d $out
|
|
||||||
''
|
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB |
Loading…
Reference in a new issue