diff --git a/.envrc b/.envrc new file mode 100644 index 000000000000..8392d159f2e7 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2540f73002fa..1931c4e540e3 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,5 @@ .*sw? .DS_Store .stack-work +/.direnv +/result \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md index 52d06b05e6af..58500f21283d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -178,6 +178,16 @@ examples, see . Pandoc can be run through [GitLab CI/CD]. For some examples, see . +## Nix + +Pandoc can be built and run using Nix. First, [install Nix](https://nixos.asia/en/install), and then: + +```sh +nix run github:jgm/pandoc +``` + +To learn about basic Nix commands, see [this introduction](https://nixos.asia/en/nix-first). + ## Compiling from source If for some reason a binary package is not available for your diff --git a/cabal.project b/cabal.project index 61e546152b8e..a670f403ec01 100644 --- a/cabal.project +++ b/cabal.project @@ -1,7 +1,8 @@ -packages: . - pandoc-lua-engine - pandoc-server - pandoc-cli +packages: + . + pandoc-lua-engine + pandoc-server + pandoc-cli tests: True flags: +embed_data_files constraints: skylighting-format-blaze-html >= 0.1.1.2, diff --git a/flake.lock b/flake.lock index cb4c63efadbe..ca4bbd2e2e5c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,57 +1,196 @@ { "nodes": { - "flake-utils": { + "citeproc": { + "flake": false, + "locked": { + "lastModified": 1719250720, + "narHash": "sha256-aX1KgFPwnIeXaNp5Lvv92kcH5VKJxgV0cJctOslC9X4=", + "owner": "jgm", + "repo": "citeproc", + "rev": "1f7e44461f66226ef9a5ac7b921ca8194de018d2", + "type": "github" + }, + "original": { + "owner": "jgm", + "ref": "0.8.1.1", + "repo": "citeproc", + "type": "github" + } + }, + "commonmark-hs": { + "flake": false, + "locked": { + "lastModified": 1718676311, + "narHash": "sha256-kynnO6b1iWt89smA8CT1y1KM+mQyTJWQOa3QXme42Y4=", + "owner": "jgm", + "repo": "commonmark-hs", + "rev": "e3747fd282c806cd2f8e83226e85f1b83ee889c3", + "type": "github" + }, + "original": { + "owner": "jgm", + "ref": "master", + "repo": "commonmark-hs", + "type": "github" + } + }, + "djot": { + "flake": false, + "locked": { + "lastModified": 1719250929, + "narHash": "sha256-BhbRaLVN1we9LT0CAgqhLcfqtrpCJKrHMqs42eJ48NI=", + "owner": "jgm", + "repo": "djoths", + "rev": "fee9d20d28bc591600c778aae0d4789721a88b7b", + "type": "github" + }, + "original": { + "owner": "jgm", + "ref": "0.1.2.1", + "repo": "djoths", + "type": "github" + } + }, + "emojis": { + "flake": false, + "locked": { + "lastModified": 1718672116, + "narHash": "sha256-HEfX3wtqDmvOtCvuKGUdnU06FMkszuPrgmrrN+5aB/k=", + "owner": "jgm", + "repo": "emojis", + "rev": "a6d541378effde9bbb5ebae2ad8795153aaee40e", + "type": "github" + }, + "original": { + "owner": "jgm", + "ref": "0.1.4.1", + "repo": "emojis", + "type": "github" + } + }, + "flake-parts": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "type": "github" }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "lastModified": 1720020158, + "narHash": "sha256-MtatlRdAy7eWdgZI8JgW/OmY/aqF+SvRucqlsLHzX80=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "64bd0f328e5a424b65aafdde3901b64f4f390b0f", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "srid", + "repo": "haskell-flake", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1683594133, - "narHash": "sha256-iUhLhEAgOCnexSGDsYT2ouydis09uDoNzM7UC685XGE=", - "owner": "NixOS", + "lastModified": 1720058333, + "narHash": "sha256-gM2RCi5XkxmcsZ44pUkKIYBiBMfZ6u7MdcZcykmccrs=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "8d447c5626cfefb9b129d5b30103344377fe09bc", + "rev": "6842b061970bf96965d66fcc86a28e1f719aae95", "type": "github" }, "original": { - "owner": "NixOS", + "owner": "nixos", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1719876945, + "narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + } + }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "citeproc": "citeproc", + "commonmark-hs": "commonmark-hs", + "djot": "djot", + "emojis": "emojis", + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs", + "skylighting": "skylighting", + "typst-hs": "typst-hs", + "typst-symbols": "typst-symbols" + } + }, + "skylighting": { + "flake": false, + "locked": { + "lastModified": 1719207821, + "narHash": "sha256-QlObt8FVk8ZtEVS5SWA3iTbNjpTxRHCQVLIaEoEocsA=", + "owner": "jgm", + "repo": "skylighting", + "rev": "97f6539395c19b927f423b556043656c39e55622", + "type": "github" + }, + "original": { + "owner": "jgm", + "ref": "0.14.2", + "repo": "skylighting", + "type": "github" + } + }, + "typst-hs": { + "flake": false, + "locked": { + "lastModified": 1719678004, + "narHash": "sha256-75ReSRGiM9EY+xkdfH4I0ufyb6uJN8yCoJkJAex+MZo=", + "owner": "jgm", + "repo": "typst-hs", + "rev": "7e0e80548aae9f3d3059f0dae333e93c8d67f290", + "type": "github" + }, + "original": { + "owner": "jgm", + "ref": "main", + "repo": "typst-hs", + "type": "github" } }, - "systems": { + "typst-symbols": { + "flake": false, "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1710699100, + "narHash": "sha256-nX4KCjQsR5E35z2Dl/BykD1OcwkWj2F6FNvUJ4c0oHM=", + "owner": "jgm", + "repo": "typst-symbols", + "rev": "0e6f7a082bf76977a2bb0a76024e1cf9f9986837", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "jgm", + "ref": "0.1.6", + "repo": "typst-symbols", "type": "github" } } diff --git a/flake.nix b/flake.nix index 9e7908765adc..714d0d718c88 100644 --- a/flake.nix +++ b/flake.nix @@ -1,53 +1,104 @@ +# This flake is written using haskell-flake +# https://community.flake.parts/haskell-flake { - description = "Pandoc development"; - - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - inputs.flake-utils.url = "github:numtide/flake-utils"; - - outputs = inputs: - let - overlay = final: prev: { - haskell = prev.haskell // { - packageOverrides = hfinal: hprev: - prev.haskell.packageOverrides hfinal hprev // { - crypton-connection = final.fetchFromGitHub { - owner = "kazu-yamamoto"; - repo = "crypton-connection"; - rev = "5c064b911e7327a4d399fd9dd057663d0d0fb256"; - sha256 = "00j1nf9glbz0cnzd84vp08j9ybzjbm3b6gcamlqxxcjb31kllz4b"; - }; - pandoc = hfinal.callCabal2nix "pandoc" ./. { }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + + # Remember to run `nix flake lock` after adding or modifying flake inputs + # This will update the `flake.lock` file. + typst-hs.url = "github:jgm/typst-hs/main"; + typst-hs.flake = false; + typst-symbols.url = "github:jgm/typst-symbols/0.1.6"; + typst-symbols.flake = false; + citeproc.url = "github:jgm/citeproc/0.8.1.1"; + citeproc.flake = false; + commonmark-hs.url = "github:jgm/commonmark-hs/master"; + commonmark-hs.flake = false; + emojis.url = "github:jgm/emojis/0.1.4.1"; + emojis.flake = false; + skylighting.url = "github:jgm/skylighting/0.14.2"; + skylighting.flake = false; + djot.url = "github:jgm/djoths/0.1.2.1"; + djot.flake = false; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ inputs.haskell-flake.flakeModule ]; + + perSystem = { config, self', pkgs, ... }: { + haskellProjects.default = { + # Haskell package overrides. See https://community.flake.parts/haskell-flake/dependency + packages = { + # Source overrides + typst.source = inputs.typst-hs; + typst-symbols.source = inputs.typst-symbols; + citeproc.source = inputs.citeproc; + commonmark-extensions.source = inputs.commonmark-hs + /commonmark-extensions; + commonmark-pandoc.source = inputs.commonmark-hs + /commonmark-pandoc; + commonmark.source = inputs.commonmark-hs + /commonmark; + commonmark-cli.source = inputs.commonmark-hs + /commonmark-cli; + emojis.source = inputs.emojis; + djot.source = inputs.djot; + + # TODO: Move this to skylighting's flake, and import it here (as haskell-flake module) + skylighting.source = pkgs.runCommand "skylighting" {} '' + mkdir $out + cp -r ${inputs.skylighting} $out/root + chmod -R u+w $out + cd $out/root/skylighting + ${config.haskellProjects.default.outputs.finalPackages.skylighting-core}/bin/skylighting-extract ../skylighting-core/xml + rm ./changelog.md; cp ../changelog.md . + cd $out + mv root/skylighting/* . + rm -rf root + ''; + skylighting-core.source = inputs.skylighting + /skylighting-core; + skylighting-format-ansi.source = inputs.skylighting + /skylighting-format-ansi; + skylighting-format-blaze-html.source = inputs.skylighting + /skylighting-format-blaze-html; + skylighting-format-context.source = inputs.skylighting + /skylighting-format-context; + skylighting-format-latex.source = inputs.skylighting + /skylighting-format-latex; + + # Hackage overrides + texmath.source = "0.12.8.9"; + toml-parser.source = "2.0.0.0"; + tls.source = "2.0.5"; + }; + settings = { + skylighting-core = { + cabalFlags.executable = true; }; - }; - pandoc = final.haskell.lib.compose.justStaticExecutables final.haskellPackages.pandoc; - }; - perSystem = system: - let - pkgs = import inputs.nixpkgs { inherit system; overlays = [ overlay ]; }; - hspkgs = pkgs.haskellPackages; - in - { - devShell = hspkgs.shellFor { - withHoogle = true; - packages = p : [ - p.pandoc - ]; - buildInputs = [ - hspkgs.cabal-install - hspkgs.haskell-language-server - hspkgs.hlint - hspkgs.ghcid - hspkgs.ormolu - hspkgs.stylish-haskell - hspkgs.weeder - hspkgs.servant-server - hspkgs.hslua - pkgs.bashInteractive - ]; }; - defaultPackage = pkgs.pandoc; + + autoWire = [ "packages" "apps" "checks" ]; + + # Programs you want to make available in the shell. + # Default programs can be disabled by setting to 'null' + devShell.tools = hp: { + inherit (hp) hlint stylish-haskell; + }; + }; + + packages = { + # This enable us to `nix build` or `nix run` pandoc. + default = self'.packages.pandoc; + # Tip: Run `nix shell .#skylighting-core` to enter a devShell with this executable in PATH + skylighting-core = config.haskellProjects.default.outputs.finalPackages.skylighting-core; + }; + + devShells.default = pkgs.mkShell { + name = "pandoc"; + packages = with pkgs; [ + # Add custom packages here + bashInteractive + ]; + inputsFrom = [ + config.haskellProjects.default.outputs.devShell + ]; }; - in - { inherit overlay; } // - inputs.flake-utils.lib.eachDefaultSystem perSystem; + }; + }; } diff --git a/shell.nix b/shell.nix index 93af608fec1b..32d7cca92eb6 100644 --- a/shell.nix +++ b/shell.nix @@ -1,127 +1 @@ -{nixpkgs ? import {} }: -let - inherit (nixpkgs) pkgs; - inherit (pkgs) haskellPackages; - - haskellDeps = ps: with ps; [ - Diff - Glob - aeson - aeson-pretty - array - attoparsec - base - base64 - binary - blaze-html - blaze-markup - bytestring - case-insensitive - cassava - commonmark - citeproc - commonmark - commonmark-extensions - commonmark-pandoc -# connection - containers - data-default - deepseq - directory - doclayout - doctemplates - emojis - exceptions - file-embed - filepath - Glob - gridtables - haddock-library - hslua-aeson -# hslua-list - hslua-module-doclayout - hslua-module-path - hslua-module-system - hslua-module-text - hslua-module-version - http-client - http-client-tls - http-types - ipynb - jira-wiki-markup - JuicyPixels - lpeg - lua - lua-arbitrary - lpeg - mime-types - mtl - network - network-uri - Only - ordered-containers - pandoc-lua-marshal - pandoc-types - parsec - pretty - pretty-show - process - random - regex-tdfa - safe - scientific - servant-server - SHA - skylighting - skylighting-core - skylighting-format-latex -# skylighting-format-context - skylighting-format-blaze-html -# skylighting-format-ansi - split - syb - tagsoup - tasty - tasty-bench - tasty-golden - tasty-hunit - tasty-lua - tasty-quickcheck - temporary - texmath - text - text-conversions - time - unicode-collation - unicode-transforms - unix - wai - wai-app-static - wai-cors - wai-extra - warp - xml - xml-conduit - xml-types - yaml - zip-archive - zlib - ]; - - ghc = haskellPackages.ghcWithPackages haskellDeps; - - nixPackages = [ - pkgs.zlib - ghc - haskellPackages.ghcid - haskellPackages.haskell-language-server - haskellPackages.cabal2nix - haskellPackages.cabal-install - haskellPackages.hlint - haskellPackages.stylish-haskell - ]; -in -pkgs.stdenv.mkDerivation { - name = "env"; - buildInputs = nixPackages; -} +(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default \ No newline at end of file