badboy / mdbook-toc

A preprocessor for mdbook to add inline Table of Contents support.
Mozilla Public License 2.0
163 stars 20 forks source link

build: nix flake #47

Closed aljazerzen closed 1 year ago

aljazerzen commented 1 year ago

Add support for using this crate from a nix flake.

badboy commented 1 year ago

oh hey, first time I get nix stuff contributed to my work. Given that I recently started using it myself -> r+

aljazerzen commented 1 year ago

I needed this crate in a dev environment, but because it does not have enough usage it is not on nixpkgs. So I forked and open this PR. For anyone who would want to use it, this is an example flake:

{
  description = "My development environment";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
    mdbook-toc.url = "github:badboy/mdbook-toc";
  };

  outputs = { self, nixpkgs, flake-utils, mdbook-toc }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
      in
      {
        devShells.default = pkgs.mkShell {
          buildInputs = [
            mdbook
            mdbook-admonish
            mdbook-toc.defaultPackage.${system}
          ];
        };
      });
}