From de9509047e8ec350f67910a740e9356b66195e49 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Tue, 2 Jul 2024 01:29:55 +0530 Subject: [PATCH] enable github like alerts --- book.toml | 2 ++ default.nix | 3 ++- flake.lock | 6 +++--- flake.nix | 11 ++++++----- mdbook-alerts.nix | 23 +++++++++++++++++++++++ 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 mdbook-alerts.nix diff --git a/book.toml b/book.toml index 3b4775e..7561556 100644 --- a/book.toml +++ b/book.toml @@ -4,3 +4,5 @@ language = "en" multilingual = false src = "src" title = "/usr/share/doc" + +[preprocessor.alerts] diff --git a/default.nix b/default.nix index 4586b6d..a4edeff 100644 --- a/default.nix +++ b/default.nix @@ -1,12 +1,13 @@ { stdenvNoCC , mdbook +, mdbook-alerts , }: stdenvNoCC.mkDerivation { pname = "wiki"; version = "2023-12-04"; src = ./.; - buildInputs = [ mdbook ]; + buildInputs = [ mdbook mdbook-alerts ]; buildPhase = '' mdbook build ''; diff --git a/flake.lock b/flake.lock index 815cf09..e48adf1 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1705242415, - "narHash": "sha256-a8DRYrNrzTudvO7XHUPNJD89Wbf1ZZT0VbwCsPnHWaE=", + "lastModified": 1719826879, + "narHash": "sha256-xs7PlULe8O1SAcs/9e/HOjeUjBrU5FNtkAF/bSEcFto=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ea780f3de2d169f982564128804841500e85e373", + "rev": "b9014df496d5b68bf7c0145d0e9b0f529ce4f2a8", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 05408af..72d7e1e 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,8 @@ pkgs = import nixpkgs { inherit system; }; - package = pkgs.callPackage ./default.nix { }; + mdbook-alerts = pkgs.callPackage ./mdbook-alerts.nix { }; + package = pkgs.callPackage ./default.nix { inherit mdbook-alerts; }; app = pkgs.writeShellScriptBin "app" '' trap 'kill "''${child_pid}"; wait "''${child_pid}";' SIGINT SIGTERM ${pkgs.merecat}/bin/merecat -n -p 8080 ${package}/share/web & @@ -29,13 +30,13 @@ { formatter = pkgs.nixpkgs-fmt; devShells.default = pkgs.mkShell { - packages = with pkgs; [ - mdbook - tailwindcss-language-server + packages = [ + pkgs.mdbook + mdbook-alerts ]; }; packages = { - inherit app; + inherit app mdbook-alerts; default = package; }; } diff --git a/mdbook-alerts.nix b/mdbook-alerts.nix new file mode 100644 index 0000000..15db976 --- /dev/null +++ b/mdbook-alerts.nix @@ -0,0 +1,23 @@ +{ lib, fetchFromGitHub, rustPlatform }: + +rustPlatform.buildRustPackage rec { + pname = "mdbook-alerts"; + version = "0.5.2"; + + src = fetchFromGitHub { + owner = "lambdalisue"; + repo = "rs-mdbook-alerts"; + rev = "v${version}"; + hash = "sha256-YlCvsDdWuoajuXt2hOGx7jW+lmLeMOSQ809bG9ZBaBY="; + }; + + cargoHash = "sha256-OuZo8QTE5Z1991S5CEkfxlXghQbnalt1UGNs4KozmEk="; + + meta = with lib; { + description = "mdBook preprocessor to add GitHub Flavored Markdown's Alerts to your book"; + mainProgram = "mdbook-alerts"; + license = licenses.mit; + maintainers = with maintainers; [ adtya ]; + homepage = "https://github.com/lambdalisue/rs-mdbook-alerts"; + }; +}