$title$
+ $if(subtitle)$ +$subtitle$
+ $endif$ + $for(author)$ + + $endfor$ + $if(abstract)$ +diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5ea1a98..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "nix-modules"] - path = nix-modules - url = git@github.com:rasmus-kirk/nix-modules.git diff --git a/home-manager/deck/home.nix b/configurations/home-manager/deck/home.nix similarity index 100% rename from home-manager/deck/home.nix rename to configurations/home-manager/deck/home.nix diff --git a/home-manager/pi/home.nix b/configurations/home-manager/pi/home.nix similarity index 100% rename from home-manager/pi/home.nix rename to configurations/home-manager/pi/home.nix diff --git a/configurations/home-manager/work/home.nix b/configurations/home-manager/work/home.nix new file mode 100644 index 0000000..1cf63e1 --- /dev/null +++ b/configurations/home-manager/work/home.nix @@ -0,0 +1,330 @@ +# My home manager config +{ pkgs, config, ... }: +let + secretDir = "${config.home.homeDirectory}/.secret"; + configDir = "${config.home.homeDirectory}/.system-configuration"; + username = "user"; + machine = "work"; +in { + kirk = { + terminalTools.enable = true; + foot.enable = true; + fzf.enable = true; + git = { + enable = true; + userEmail = "mail@rasmuskirk.com"; + userName = "rasmus-kirk"; + }; + helix.enable = true; + homeManagerScripts = { enable = true; configDir = configDir; machine = machine; }; + jiten.enable = true; + scripts.enable = true; + joshuto.enable = true; + joshuto.enableZshIntegration = false; + kakoune.enable = true; + ssh = { enable = true; identityPath = "${secretDir}/id_ed25519"; }; + userDirs = { enable = true; autoSortDownloads = true; }; + zathura = { + enable = true; + darkmode = false; + }; + zsh.enable = true; + fonts.enable = true; + }; + + home.username = username; + home.homeDirectory = "/home/${username}"; + + home.stateVersion = "22.11"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + targets.genericLinux.enable = true; + + services.syncthing.enable = true; + + nix = { + package = pkgs.nix; + settings.experimental-features = [ "nix-command" "flakes" ]; + settings.trusted-users = [ + username + "@wheel" + ]; + }; + + programs.bash = { + enable = true; + profileExtra = '' + # Fix programs not showing up + export XDG_DATA_DIRS="$HOME/.nix-profile/share:$XDG_DATA_DIRS" + + export NIX_PATH=''${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels + ''; + + initExtra = "exec zsh"; + }; + + programs.yazi = let + mkYaziPlugin = name: pkgs.stdenv.mkDerivation { + name = name; + phases = [ "unpackPhase" "buildPhase" ]; + buildPhase = '' + mkdir -p "$out" + cp -r "${name}".yazi/* "$out" + ''; + src = pkgs.fetchgit { + rev = "5e65389d1308188e5a990059c06729e2edb18f8a"; + url = "https://github.com/yazi-rs/plugins.git"; + hash = "sha256-XHaQjudV9YSMm4vF7PQrKGJ078oVF1U1Du10zXEJ9I0="; + }; + }; + gruvbox-dark = pkgs.stdenv.mkDerivation { + name = "gruvbox-dark"; + phases = [ "unpackPhase" "buildPhase" ]; + buildPhase = "mkdir -p $out ; cp -r . $out"; + src = pkgs.fetchgit { + url = "https://github.com/bennyyip/gruvbox-dark.yazi.git"; + rev = "c204853de7a78bc99ea628e51857ce65506468db"; + hash = "sha256-NBco10MINyAJk1YWHwYUzvI9mnTJl9aYyDtQSTUP3Hs="; + }; + }; + in { + enable = true; + enableZshIntegration = true; + shellWrapperName = "j"; + initLua = '' + require("full-border"):setup() + require("git"):setup() + ''; + keymap = { + manager.prepend_keymap = [ + { on = "e"; run = "shell --interactive --block $EDITOR $0"; desc = "Edit file"; } + # Selection + { on = ";"; run = "escape --select"; desc = "Deselect all files"; } + { on = "?"; run = "help"; desc = "View help"; } + { + on = "%"; + run = "select_all --state=true"; + desc = "Select all files"; + } { + on = "J"; + run = [ "select --state=none" "arrow 1" ]; + desc = "Select down"; + } { + on = "K"; + run = [ "select --state=none" "arrow -1" ]; + desc = "Select up"; + } + # Plugins + { + on = "'"; + run = "plugin smart-filter"; + desc = "Smart filter"; + } { + on = [ "c" "m" ]; + run = "plugin chmod"; + desc = "Chmod on selected files"; + } { + on = "t"; + run = "plugin --sync hide-preview"; + desc = "Hide or show preview"; + } { + on = "T"; + run = "plugin --sync max-preview"; + desc = "Maximize or restore preview"; + } + # Goto + { + on = [ "g" "~" ]; + run = "cd ~"; + desc = "Goto home dir"; + } { + on = [ "g" "`" ]; + run = "cd /"; + desc = "Goto root directory"; + } { + on = [ "g" "e" ]; + run = "arrow 99999999999"; + desc = "Move cursor to bottom"; + } + # Bookmarks + { + on = [ "b" "u" ]; + run = "cd $XDG_DOWNLOAD_DIR"; + desc = "Goto bookmarked download directory"; + } { + on = [ "b" "b" ]; + run = "cd ~/media/books"; + desc = "Goto bookmarked books directory"; + } { + on = [ "b" "p" ]; + run = "cd ~/media/documents/programming"; + desc = "Goto bookmarked programming directory"; + } { + on = [ "b" "a" ]; + run = "cd ~/media/audio"; + desc = "Goto bookmarked audio directory"; + } { + on = [ "b" "a" ]; + run = "cd $XDG_VIDEOS_DIR"; + desc = "Goto bookmarked videos directory"; + } { + on = [ "b" "d" ]; + run = "cd $XDG_DOCUMENTS_DIR"; + desc = "Goto bookmarked download directory"; + } { + on = [ "b" "s" ]; + run = "cd ~/media/documents/study"; + desc = "Goto bookmarked study directory"; + } { + on = [ "b" "i" ]; + run = "cd $XDG_PICTURES_DIR"; + desc = "Goto bookmarked images directory"; + } + ]; + }; + settings = { + plugin.prepend_fetchers = [ + { + id = "git"; + name = "*/"; + run = "git"; + } { + id = "git"; + name = "*"; + run = "git"; + } + ]; + }; + flavors.gruvbox-dark = gruvbox-dark; + plugins = { + full-border = mkYaziPlugin "full-border"; + git = mkYaziPlugin "git"; + smart-filter = mkYaziPlugin "smart-filter"; + chmod = mkYaziPlugin "chmod"; + hide-preview = mkYaziPlugin "hide-preview"; + max-preview = mkYaziPlugin "max-preview"; + }; + theme.flavor.use = "gruvbox-dark"; + }; + + programs.emacs = { + enable = true; + extraConfig = '' + (use-package kakoune) + ''; + extraPackages = epkgs: [ epkgs.kakoune ]; + }; + + # TODO: Add to kirk-module + programs.mpv = { + enable = true; + bindings = { + UP = "add chapter 1"; + DOWN = "add chapter -1"; + ESC = "quit"; + ENTER = "cycle pause"; + f = "cycle fullscreen"; + h = "seek -5"; + j = "add chapter -1"; + k = "add chapter 1"; + l = "seek 5"; + + "Shift+LEFT" = "cycle sub down"; + "Shift+RIGHT" = "cycle sub"; + "Shift+UP" = "cycle audio"; + "Shift+DOWN" = "cycle audio down"; + + y = "add audio-delay 0.010"; + o = "add audio-delay -0.010"; + + i = ''cycle-values vf "sub,lavfi=negate" ""''; + S = "playlist-shuffle"; + + a = "ab-loop"; + + "Alt+r" = "playlist-shuffle"; + }; + scripts = with pkgs.mpvScripts; [ + # Load all files in directory to playlist, playing next alphabetically ordered file on playback end. + autoload + # Better UI + uosc + # Allows media playback buttons to work in mpv + mpris + # Thumbnail support, needs uosc to work + thumbfast + # Prevents screen sleep on gnome + inhibit-gnome + ]; + config = { + # TODO: wtf is the reason for this? It should not be necessary. WHY DOES IT WORK!? + vo = "x11"; + + alang = [ "jpn" "eng" ]; + slang = [ "eng" ]; + #extension.gif = { + # cache = "no"; + # no-pause = ""; + # loop-file = "yes"; + #}; + #extension.webm = { + # no-pause = ""; + # loop-file = "yes"; + #}; + }; + }; + + programs.zsh.profileExtra = '' + export PATH=$PATH:~/.cargo/bin:~/.local/bin + + # Yazi + export TERM=foot + + # Fix weird cargo concordium bug + export LD_LIBRARY_PATH="${pkgs.zlib}/lib:$LD_LIBRARY_PATH"; + + # Fix nix programs not showing up in gnome menus: + #export XDG_DATA_DIRS="$HOME/.nix-profile/share:$XDG_DATA_DIRS" + + export XCURSOR_THEME="Capitaine Cursors (Gruvbox)" + export XCURSOR_PATH="$XCURSOR_PATH":/usr/share/icons:~/.local/share/icons + ''; + + home.packages = with pkgs; [ + # Misc + gnome-tweaks + keepassxc + thunderbird + yarn + + # Browsers + librewolf + chromium + + # Media + qbittorrent + #mpv + + # Crytpo + monero-gui + + # Chat + slack + signal-desktop + + # Fonts + (nerdfonts.override { fonts = [ "FiraCode" ]; }) + fira-code + + # Document handling + texlive.combined.scheme-full + pandoc + inotify-tools + + # Misc Terminal Tools + wl-clipboard + yt-dlp + ]; +} diff --git a/nixos/deck/age/secrets.nix b/configurations/nixos/deck/age/secrets.nix similarity index 100% rename from nixos/deck/age/secrets.nix rename to configurations/nixos/deck/age/secrets.nix diff --git a/nixos/deck/age/user.age b/configurations/nixos/deck/age/user.age similarity index 100% rename from nixos/deck/age/user.age rename to configurations/nixos/deck/age/user.age diff --git a/nixos/deck/configuration.nix b/configurations/nixos/deck/configuration.nix similarity index 100% rename from nixos/deck/configuration.nix rename to configurations/nixos/deck/configuration.nix diff --git a/nixos/deck/hardware-configuration.nix b/configurations/nixos/deck/hardware-configuration.nix similarity index 100% rename from nixos/deck/hardware-configuration.nix rename to configurations/nixos/deck/hardware-configuration.nix diff --git a/nixos/pi/age/airvpn-wg-address.age b/configurations/nixos/pi/age/airvpn-wg-address.age similarity index 100% rename from nixos/pi/age/airvpn-wg-address.age rename to configurations/nixos/pi/age/airvpn-wg-address.age diff --git a/nixos/pi/age/airvpn-wg.age b/configurations/nixos/pi/age/airvpn-wg.age similarity index 100% rename from nixos/pi/age/airvpn-wg.age rename to configurations/nixos/pi/age/airvpn-wg.age diff --git a/nixos/pi/age/domain.age b/configurations/nixos/pi/age/domain.age similarity index 100% rename from nixos/pi/age/domain.age rename to configurations/nixos/pi/age/domain.age diff --git a/nixos/pi/age/mullvad.age b/configurations/nixos/pi/age/mullvad.age similarity index 100% rename from nixos/pi/age/mullvad.age rename to configurations/nixos/pi/age/mullvad.age diff --git a/nixos/pi/age/secrets.nix b/configurations/nixos/pi/age/secrets.nix similarity index 100% rename from nixos/pi/age/secrets.nix rename to configurations/nixos/pi/age/secrets.nix diff --git a/nixos/pi/age/user.age b/configurations/nixos/pi/age/user.age similarity index 100% rename from nixos/pi/age/user.age rename to configurations/nixos/pi/age/user.age diff --git a/nixos/pi/age/wifi.age b/configurations/nixos/pi/age/wifi.age similarity index 100% rename from nixos/pi/age/wifi.age rename to configurations/nixos/pi/age/wifi.age diff --git a/nixos/pi/configuration.nix b/configurations/nixos/pi/configuration.nix similarity index 100% rename from nixos/pi/configuration.nix rename to configurations/nixos/pi/configuration.nix diff --git a/nixos/pi/pubkeys/laptop.pub b/configurations/nixos/pi/pubkeys/laptop.pub similarity index 100% rename from nixos/pi/pubkeys/laptop.pub rename to configurations/nixos/pi/pubkeys/laptop.pub diff --git a/nixos/pi/pubkeys/steam-deck.pub b/configurations/nixos/pi/pubkeys/steam-deck.pub similarity index 100% rename from nixos/pi/pubkeys/steam-deck.pub rename to configurations/nixos/pi/pubkeys/steam-deck.pub diff --git a/nixos/pi/pubkeys/work.pub b/configurations/nixos/pi/pubkeys/work.pub similarity index 100% rename from nixos/pi/pubkeys/work.pub rename to configurations/nixos/pi/pubkeys/work.pub diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..516b716 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,4 @@ +This is the options documentation for my personal nix modules + +- **Docs for the home manager modules** can be found [here](./home.html) +- **Docs for the nixos modules** can be found [here](./nixos.html) diff --git a/docs/mkDocs.nix b/docs/mkDocs.nix new file mode 100644 index 0000000..0ab2f93 --- /dev/null +++ b/docs/mkDocs.nix @@ -0,0 +1,107 @@ +{ + lib, + pkgs, + nixosOptionsDoc, + inputs, + ... +}: let + # Make sure the used package is scrubbed to avoid actually + # instantiating derivations. + # evaluate our options + evalHome = lib.evalModules { + # TODO: understand why pkgs needs to be passed here + specialArgs = {inherit pkgs;}; + modules = [ + { + # disabled checking that all option definitions have matching declarations + config._module.check = false; + } + inputs.home-manager.nixosModules.default + ./home-manager + ]; + }; + # generate our docs + optionsDocHome = nixosOptionsDoc { + inherit (evalHome) options; + }; + + # Same for nixos + evalNixos = lib.evalModules { + specialArgs = {inherit pkgs;}; + modules = [ + { + config._module.check = false; + } + inputs.home-manager.nixosModules.default + ./nixos + #./nixos/servarr + #./nixos/nixosScripts + ]; + }; + optionsDocNixos = nixosOptionsDoc { + inherit (evalNixos) options; + }; +in pkgs.stdenv.mkDerivation { + name = "nixdocs2html"; + src = ./.; + buildInputs = with pkgs; [ pandoc ]; + phases = ["unpackPhase" "buildPhase"]; + buildPhase = '' + tmpdir=$(mktemp -d) + #tmpdir=$out/debug + mkdir -p $out + mkdir -p $tmpdir + cp -r docs $out + + buildpandoc () { + filepath="$1" + title="$2" + filename=$(basename -- "$filepath") + filename_no_ext="''${filename%.*}" + + pandoc \ + --standalone \ + --metadata title="$title" \ + --metadata date="$(date -u '+%Y-%m-%d - %H:%M:%S %Z')" \ + --highlight-style docs/pandoc/gruvbox.theme \ + --template docs/pandoc/template.html \ + --css docs/pandoc/style.css \ + --lua-filter docs/pandoc/lua/indent-code-blocks.lua \ + --lua-filter docs/pandoc/lua/anchor-links.lua \ + --lua-filter docs/pandoc/lua/code-default-to-nix.lua \ + --lua-filter docs/pandoc/lua/headers-lvl2-to-lvl3.lua \ + --lua-filter docs/pandoc/lua/remove-declared-by.lua \ + --lua-filter docs/pandoc/lua/inline-to-fenced-nix.lua \ + --lua-filter docs/pandoc/lua/remove-module-args.lua \ + -V lang=en \ + -V --mathjax \ + -f markdown+smart \ + -o $out/"$filename_no_ext".html \ + "$filepath" + } + + # Generate nixos md docs + cat ${optionsDocNixos.optionsCommonMark} > "$tmpdir"/nixos.md + # Generate home-manager md docs + cat ${optionsDocHome.optionsCommonMark} > "$tmpdir"/home.md + + buildpandoc "$tmpdir"/nixos.md "Nixos Modules - Options Documentation" + buildpandoc "$tmpdir"/home.md "Home Manager Modules - Options Documentation" + + pandoc \ + --standalone \ + --highlight-style docs/pandoc/gruvbox.theme \ + --metadata title="Kirk Modules - Option Documentation" \ + --metadata date="$(date -u '+%Y-%m-%d - %H:%M:%S %Z')" \ + --css /docs/pandoc/style.css \ + --template docs/pandoc/template.html \ + -V lang=en \ + -V --mathjax \ + -f markdown+smart \ + -o $out/index.html \ + docs/index.md + ''; + } + + + diff --git a/docs/pandoc/gruvbox.theme b/docs/pandoc/gruvbox.theme new file mode 100644 index 0000000..9a6d053 --- /dev/null +++ b/docs/pandoc/gruvbox.theme @@ -0,0 +1,225 @@ +{ + "text-color": "#282828", + "background-color": "#fbf1c7", + "line-number-color": "#3c3836", + "line-number-background-color": "#fbf1c7", + "text-styles": { + "Alert": { + "text-color": "#9d0006", + "background-color": null, + "bold": true, + "italic": false, + "underline": false + }, + "Annotation": { + "text-color": "#b16286", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Attribute": { + "text-color": "#076678", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "BaseN": { + "text-color": "#b57614", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "BuiltIn": { + "text-color": "#8f3f71", + "background-color": null, + "bold": true, + "italic": false, + "underline": false + }, + "Char": { + "text-color": "#98971a", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Comment": { + "text-color": "#7c6f64", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "CommentVar": { + "text-color": "#7c6f64", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Constant": { + "text-color": "#cc241d", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "ControlFlow": { + "text-color": "#282828", + "background-color": null, + "bold": true, + "italic": false, + "underline": false + }, + "DataType": { + "text-color": "#458588", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "DecVal": { + "text-color": "#458588", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Documentation": { + "text-color": "#98971a", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Error": { + "text-color": "#9d0006", + "background-color": null, + "bold": false, + "italic": false, + "underline": true + }, + "Extension": { + "text-color": "#458588", + "background-color": null, + "bold": true, + "italic": false, + "underline": false + }, + "Float": { + "text-color": "#b57614", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Function": { + "text-color": "#b16286", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Import": { + "text-color": "#d65d0e", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Information": { + "text-color": "#d65d0e", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Keyword": { + "text-color": "#282828", + "background-color": null, + "bold": true, + "italic": false, + "underline": false + }, + "Normal": { + "text-color": "#282828", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Operator": { + "text-color": "#282828", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Other": { + "text-color": "#79740e", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Preprocessor": { + "text-color": "#79740e", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "RegionMarker": { + "text-color": "#076678", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "SpecialChar": { + "text-color": "#79740e", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "SpecialString": { + "text-color": "#79740e", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "String": { + "text-color": "#98971a", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Variable": { + "text-color": "#076678", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "VerbatimString": { + "text-color": "#9d0006", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + }, + "Warning": { + "text-color": "#b57614", + "background-color": null, + "bold": false, + "italic": false, + "underline": false + } + } +} diff --git a/docs/pandoc/link.svg b/docs/pandoc/link.svg new file mode 100644 index 0000000..c66ac2d --- /dev/null +++ b/docs/pandoc/link.svg @@ -0,0 +1,5 @@ + + diff --git a/docs/pandoc/lua/anchor-links.lua b/docs/pandoc/lua/anchor-links.lua new file mode 100644 index 0000000..e133da0 --- /dev/null +++ b/docs/pandoc/lua/anchor-links.lua @@ -0,0 +1,15 @@ +-- Adds anchor links to headings with IDs. + +function Header (h) + if h.identifier ~= '' then + -- an empty link to this header + local anchor_link = pandoc.Link( + {}, -- content + '#' .. h.identifier, -- href + '', -- title + {class = 'anchor', ['aria-hidden'] = 'true'} -- attributes + ) + h.content:insert(1, anchor_link) + return h + end +end diff --git a/docs/pandoc/lua/code-default-to-nix.lua b/docs/pandoc/lua/code-default-to-nix.lua new file mode 100644 index 0000000..5743054 --- /dev/null +++ b/docs/pandoc/lua/code-default-to-nix.lua @@ -0,0 +1,10 @@ +-- Change each untagged codeblock in the document to a "nix" code block. + +function CodeBlock(block) + -- Check if the code block does not have a language specified. + if block.classes[1] == nil then + -- Set the language of the code block to "nix". + block.classes[1] = "nix" + end + return block +end diff --git a/docs/pandoc/lua/headers-lvl2-to-lvl3.lua b/docs/pandoc/lua/headers-lvl2-to-lvl3.lua new file mode 100644 index 0000000..ab5fdab --- /dev/null +++ b/docs/pandoc/lua/headers-lvl2-to-lvl3.lua @@ -0,0 +1,10 @@ +-- Changes all level 2 headers to level 3 + +function Header(elem) + -- Check if the header is of level 2 + if elem.level == 2 then + -- Change the header level to 3 + elem.level = 3 + end + return elem +end diff --git a/docs/pandoc/lua/indent-code-blocks.lua b/docs/pandoc/lua/indent-code-blocks.lua new file mode 100644 index 0000000..2ce9353 --- /dev/null +++ b/docs/pandoc/lua/indent-code-blocks.lua @@ -0,0 +1,39 @@ +-- pandoc_indent_nix_blocks.lua +-- This Pandoc Lua filter indents all lines in code blocks by 2 spaces +-- TODO: This indents _all_ code blocks, not just example and default... + +--if dump_debug then +-- local debug_file = io.open("pandoc_debug.log", "a") +--end +-- +--function debug(msg) +-- if debug_file then +-- debug_file:write(msg .. "\n") +-- end +--end + +function CodeBlock(block) + -- Check if the code block language is unmarked + if #block.classes == 0 then + -- Split the block text into lines + local lines = {} + for line in block.text:gmatch("[^\r\n]+") do + table.insert(lines, line) + end + + -- Indent each line by 2 spaces + for i, line in ipairs(lines) do + lines[i] = " " .. line + end + + -- Join the lines back together and update the block text + block.text = table.concat(lines, '\n') + + -- Return the modified block + return block + end +end + +return { + {CodeBlock = CodeBlock} +} diff --git a/docs/pandoc/lua/inline-to-fenced-nix.lua b/docs/pandoc/lua/inline-to-fenced-nix.lua new file mode 100644 index 0000000..9e4b470 --- /dev/null +++ b/docs/pandoc/lua/inline-to-fenced-nix.lua @@ -0,0 +1,31 @@ +-- Changes "Example" and "Default" section fenced code blocks into "nix" tagged code blocks + +function Para(elem) + -- Check if the first element of the paragraph is Emph (italic) + if #elem.content >= 1 and elem.content[1].t == "Emph" then + -- Convert the first element to plain text to check its content + local firstText = pandoc.utils.stringify(elem.content[1]) + local isExample = firstText:find("^Example:") + local isDefault = firstText:find("^Default:") + + -- Check if the text starts with "Declared by:" + if isExample or isDefault then + local newElems = {} + for i, el in ipairs(elem.content) do + if el.t == "Code" then + -- Convert inline code to fenced code block and add it to new elements + -- Note: This will be outside the paragraph due to block-level constraint + local addedSpaces = string.gsub(el.text, "^", " "); + table.insert(newElems, pandoc.CodeBlock(addedSpaces, pandoc.Attr("", {"nix"}))) + else + -- Keep other elements as inline, to be added to a new paragraph + table.insert(newElems, el) + end + end + -- Replace paragraph with new elements (mixing inline and block-level elements isn't directly possible, so this part needs rethinking) + return newElems + end + end + -- Otherwise, return the paragraph unmodified + return elem +end diff --git a/docs/pandoc/lua/remove-declared-by.lua b/docs/pandoc/lua/remove-declared-by.lua new file mode 100644 index 0000000..623e4c4 --- /dev/null +++ b/docs/pandoc/lua/remove-declared-by.lua @@ -0,0 +1,17 @@ +-- Removed "Declared by:" paragraphs. TODO: Make them link to the GH repo instead + +function Para(elem) + -- Check if the first element of the paragraph is Emph (italic) + if #elem.content >= 1 and elem.content[1].t == "Emph" then + -- Convert the first element to plain text to check its content + local firstText = pandoc.utils.stringify(elem.content[1]) + + -- Check if the text starts with "Declared by:" + if firstText:find("^Declared by:") then + -- Return an empty block to remove this paragraph + return {} + end + end + -- Otherwise, return the paragraph unmodified + return elem +end diff --git a/docs/pandoc/lua/remove-module-args.lua b/docs/pandoc/lua/remove-module-args.lua new file mode 100644 index 0000000..1cb4485 --- /dev/null +++ b/docs/pandoc/lua/remove-module-args.lua @@ -0,0 +1,47 @@ +-- Remove junk module.args section of the nix documentation + +-- This function checks if a string starts with a given start string +function starts_with(str, start) + return str:sub(1, #start) == start +end + +-- This recursive function traverses the AST and removes sections based on the header condition +function remove_sections(elements, condition) + local result = {} + local skip_level = nil -- Define skip_level outside the loop, initialized to nil + + for _, el in ipairs(elements) do + if el.t == "Header" then + -- Check if we are currently skipping sections and this header is of equal or higher level + if skip_level and el.level <= skip_level then + skip_level = nil -- Stop skipping sections + end + + -- If skip_level is nil, check if this header starts a new section to skip + if not skip_level and condition(el) then + skip_level = el.level -- Start skipping sections + else + table.insert(result, el) -- Add the header to results if not skipping + end + elseif not skip_level then + table.insert(result, el) -- Add non-header elements if not skipping + end + end + + return result +end + +-- The Pandoc filter function to apply our custom logic +function Pandoc(doc) + -- Define the condition function to be used for identifying sections to remove + local condition = function(header) + -- Assuming the header's actual text is in the 'content' array and in the first element + local header_text = pandoc.utils.stringify(header.content) + return starts_with(header_text, "_module.args") or starts_with(header_text, "home-manager") + end + + -- Apply the removal function to the document blocks + doc.blocks = remove_sections(doc.blocks, condition) + + return doc +end diff --git a/docs/pandoc/script.js b/docs/pandoc/script.js new file mode 100644 index 0000000..613e538 --- /dev/null +++ b/docs/pandoc/script.js @@ -0,0 +1,25 @@ +addEventListener('DOMContentLoaded', () => { + const fullpath = location.origin + location.pathname.replace(/\/$/, ""); + + document.querySelectorAll('nav a').forEach((el) => { + const url = new URL(el.href); + const fullurl = url.origin + url.pathname.replace(/\/$/, ""); + console.log("fullurl", fullurl); + console.log("fullpath", fullpath); + console.log("locationpathname", location.pathname); + console.log("urlpathname", url.pathname); + const onHome = fullpath === location.origin + const urlIsHome = fullurl === location.origin + console.log("onhome", onHome); + console.log("urlIsHome", urlIsHome); + console.log("") + + if (onHome && fullurl === fullpath) { + el.classList.add('active'); + } + // The startsWith is for subpages + else if (!urlIsHome && fullpath.startsWith(fullurl)) { + el.classList.add('active'); + } + }); +}); diff --git a/docs/pandoc/style.css b/docs/pandoc/style.css new file mode 100644 index 0000000..c7f451c --- /dev/null +++ b/docs/pandoc/style.css @@ -0,0 +1,461 @@ +/* + * I add this to html files generated with pandoc. + */ + +:root { + --bg: #fbf1c7; + --bgt: #fbf1c7; + --bge: #fbf8e4; + --bg0: #f9f5d7; + --fg0: #282828; + --ltred: #cc241d; + --ltgreen: #98971a; + --ltyellow: #d79921; + --ltblue: #458588; + --ltpurple: #b16286; + --ltaqua: #689da6; + --ltorange: #d65d0e; + --ltgrey: #7c6f64; + --dkred: #9d0006; + --dkgreen: #79740e; + --dkyellow: #b57614; + --dkblue: #076678; + --dkpurple: #8f3f71; + --dkaqua: #427b58; + --dkgrey: #3c3836; +} + +html { + /* font-size: 100%; */ + /* overflow-y: scroll; */ + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +body { + color: var(--fg0); + font-family: century_supra_a, Georgia, serif; + font-size: 16px; + line-height: 1.7; + background: var(--bge); + margin: 0; +} + +main { + min-height: 100vh; + position: relative; +} + +#header { + background-color: #066678; + padding: 0.3rem 0; + color: #faf8e4; + border-bottom: 1px solid #458587; + font-size: 2rem; +} + +nav { + color: #faf8e4; + background-color: #054c5a; +} + +nav .content { + display: flex; + padding: 0; +} + +nav a { + color: #458587; + text-decoration: none; + font-size: 1em; + padding: 0.15em 1em; +} + +nav a:visited { + color: #458587; +} + +nav a:hover { + background-color: var(--dkblue); + color: var(--bg); +} + +nav a.active { + background-color: #458587; + color: #faf8e4 !important; +} + +footer { + height: 2rem; + position: absolute; + bottom: 0; + width: 100%; + background-color: #03333b; + border-top: 0.5rem solid #458587; + color: #faf8e4; + display: flex; + font-size: 0.8rem; +} + +footer .content { + display: flex; + align-items: center; + gap: 1em; + height: 100%; +} + +.content { + margin: auto; + padding: 0 0.5rem; + max-width: 50rem; +} + +.content-wrap { + padding-bottom: 4rem; + overflow-wrap: break-word; +} + +a { + color: var(--ltblue); + text-decoration: none; +} + +a:visited { + color: var(--dkblue); +} + +a:hover { + color: var(--ltblue); +} + +a:active { + color: var(--ltblue); +} + +a:focus { + outline: thin dotted; +} + +a code { + text-decoration-line: underline; +} + +strong a { + text-decoration-line: underline; + color: var(--fg0); +} + +strong a:hover { + text-decoration-line: underline; + color: var(--fg0); +} + +strong a:visited { + text-decoration-line: underline; + color: var(--fg0); +} + +*::-moz-selection { + /* background: var(--ltred); */ + background: rgba(255, 255, 0, 0.3); + color: var(--fg0); +} + +*::selection { + background: rgba(255, 255, 0, 0.3); + color: var(--fg0); +} + +a::-moz-selection { + background: rgba(255, 255, 0, 0.3); + color: var(--ltblue); +} + +a::selection { + background: rgba(255, 255, 0, 0.3); + color: var(--ltblue); +} + +p { + margin: 1em 0; +} + +img { + max-width: 100%; +} + +h1, h2, h3, h4, h5, h6 { + color: var(--fg0); + line-height: 125%; + /* margin-top: 1em; */ + font-weight: normal; +} + +h4, h5, h6 { + font-weight: bold; +} + +h1 { + font-size: 2.25em; +} + +h2 { + font-size: 2em; +} + +h3 { + font-size: 1.5em; +} + +h4 { + font-size: 1.2em; +} + +h5 { + font-size: 1em; +} + +h6 { + font-size: 0.9em; +} + +blockquote { + color: var(--ltgrey); + margin: 0; + padding-left: 3em; + border-left: 0.5em var(--fg0) solid; +} + +hr { + display: block; + height: 2px; + border: 0; + border-top: 1px solid #aaa; + border-bottom: 1px solid #eee; + margin: 1em 0; + padding: 0; +} + +pre, code, kbd, samp { + color: var(--fg0); + font-family: monospace, monospace; + _font-family: 'courier new', monospace; + font-size: 0.98em; +} + +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +b, strong { + font-weight: bold; +} + +dfn { + font-style: italic; +} + +ins { + background: #ff9; + color: #000; + text-decoration: none; +} + +mark { + background: #ff0; + color: #000; + font-style: italic; + font-weight: bold; +} + +sub, sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +ul, ol { + margin: 1em 0; + padding: 0 0 0 2em; +} + +li p:last-child { + margin-bottom: 0; +} + +ul ul, ol ol { + margin: .3em 0; +} + +dl { + margin-bottom: 1em; +} + +dt { + font-weight: bold; + margin-bottom: .8em; +} + +dd { + margin: 0 0 .8em 2em; +} + +dd:last-child { + margin-bottom: 0; +} + +img { + border: 0; + -ms-interpolation-mode: bicubic; + vertical-align: middle; +} + +figure { + display: block; + text-align: center; + margin: 1em 0; +} + +figure img { + border: none; + margin: 0 auto; +} + +figcaption { + font-size: 0.8em; + font-style: italic; + margin: 0 0 .8em; +} + +table { + margin-bottom: 2em; + border-bottom: 1px solid #ddd; + border-right: 1px solid #ddd; + border-spacing: 0; + border-collapse: collapse; +} + +table th { + padding: .2em 1em; + background-color: #eee; + border-top: 1px solid #ddd; + border-left: 1px solid #ddd; +} + +table td { + padding: .2em 1em; + border-top: 1px solid #ddd; + border-left: 1px solid #ddd; + vertical-align: top; +} + +.author { + font-size: 1.2em; + text-align: center; +} + +@media print { + * { + background: transparent !important; + color: black !important; + filter: none !important; + -ms-filter: none !important; + } + + body { + font-size: 12pt; + } + + .content { + max-width: 100%; + } + + + a, a:visited { + text-decoration: underline; + } + + hr { + height: 1px; + border: 0; + border-bottom: 1px solid black; + } + + a[href]:after { + content: " (" attr(href) ")"; + } + + abbr[title]:after { + content: " (" attr(title) ")"; + } + + .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { + content: ""; + } + + pre, blockquote { + border: 1px solid #999; + padding-right: 1em; + page-break-inside: avoid; + } + + tr, img { + page-break-inside: avoid; + } + + img { + max-width: 100% !important; + } + + @page :left { + margin: 15mm 20mm 15mm 10mm; +} + + @page :right { + margin: 15mm 10mm 15mm 20mm; +} + + p, h2, h3 { + orphans: 3; + widows: 3; + } + + h2, h3 { + page-break-after: avoid; + } +} + +/* show the anchor links in headings if one hovers over the heading. */ +.anchor::before { + content: url("/docs/pandoc/link.svg"); + display: inline-block; + font-size: 1em; + left: -1.5em; + line-height: 1.5; + opacity: 0.15; + position: relative; + width: 0em; +} +.anchor:hover { + text-decoration: none; +} +h1:hover > .anchor::before, +h2:hover > .anchor::before, +h3:hover > .anchor::before, +h4:hover > .anchor::before, +h5:hover > .anchor::before, +h6:hover > .anchor::before { + opacity: 1; +} +/* end: heading anchor links */ diff --git a/docs/pandoc/template.html b/docs/pandoc/template.html new file mode 100644 index 0000000..60dc159 --- /dev/null +++ b/docs/pandoc/template.html @@ -0,0 +1,101 @@ + + + +
+ + + + $for(author-meta)$ + + $endfor$ + $if(date-meta)$ + + $endif$ + $if(keywords)$ + + $endif$ + $if(description-meta)$ + + $endif$ +$subtitle$
+ $endif$ + $for(author)$ + + $endfor$ + $if(abstract)$ +