-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nix build #5298
Comments
@hamishmack added the default.nix and may be able to help. |
The problem is just with the default.nix file. |
I'm inclined to delete the default.nix file, since I don't know how to keep it up to date, and it's problematic if it's not kept up to date, since people will assume they can use it. |
👍 for deleting the
|
After using this command, I got this new nix file { mkDerivation, aeson, aeson-pretty, base, base64-bytestring
, binary, blaze-html, blaze-markup, bytestring, case-insensitive
, cmark-gfm, containers, criterion, data-default, deepseq, Diff
, directory, doctemplates, exceptions, executable-path, filepath
, Glob, haddock-library, hslua, hslua-module-text, HsYAML, HTTP
, http-client, http-client-tls, http-types, ipynb, JuicyPixels, mtl
, network, network-uri, pandoc-types, parsec, process, QuickCheck
, random, safe, SHA, skylighting, split, stdenv, syb, tagsoup
, tasty, tasty-golden, tasty-hunit, tasty-quickcheck, temporary
, texmath, text, time, unicode-transforms, unix
, unordered-containers, vector, weigh, xml, zip-archive, zlib
}:
mkDerivation {
pname = "pandoc";
version = "2.6.1";
src = ./.;
configureFlags = [ "-fhttps" "-f-trypandoc" ];
isLibrary = true;
isExecutable = true;
enableSeparateDataOutput = true;
libraryHaskellDepends = [
aeson aeson-pretty base base64-bytestring binary blaze-html
blaze-markup bytestring case-insensitive cmark-gfm containers
data-default deepseq directory doctemplates exceptions filepath
Glob haddock-library hslua hslua-module-text HsYAML HTTP
http-client http-client-tls http-types ipynb JuicyPixels mtl
network network-uri pandoc-types parsec process random safe SHA
skylighting split syb tagsoup temporary texmath text time
unicode-transforms unix unordered-containers vector xml zip-archive
zlib
];
executableHaskellDepends = [ base ];
testHaskellDepends = [
base base64-bytestring bytestring containers Diff directory
executable-path filepath Glob hslua pandoc-types process QuickCheck
tasty tasty-golden tasty-hunit tasty-quickcheck temporary text time
xml zip-archive
];
benchmarkHaskellDepends = [
base bytestring containers criterion mtl text time weigh
];
postInstall = ''
mkdir -p $out/share
mv $data/*/*/man $out/share/
'';
homepage = "https://pandoc.org";
description = "Conversion between markup formats";
license = stdenv.lib.licenses.gpl2;
} And have this error using nix-build
|
I've deleted the default.nix from the repository.
I'm sorry, I can't help with nix build issues,
but hopefully someone else following this thread can,
or you can ask on pandoc-discuss.
|
This is not necessarily true, especially if you use Having a |
|
Yes, but I was referring to the cabal2nix command that is used to generate a default.nix. My point was that |
What does it matter? The point is that it is a generated file and as such it should not be checked into the git repository because it can be derived automatically from the Cabal file. |
Actually it was not default.nix. Sorry, I should have pointed that out earlier. |
Yes.
But that will not allow you to override library dependencies to the exact version, or different source repo. Or specify non-Haskell dependencies (eg: latex). I once tried writing a default.nix to use pandoc 2.x as a library in my own Haskell project (nixpkgs only had 1.x at that time), which involved overriding a bunch of dependencies although I had given up on it.
Oh yes. I doubt a mere cabal2nix-generated default.nix is going to work for a non-trivial project like pandoc anyway. |
It is getting pretty close though. I think a lot of the things that were in the old default.nix are in the output of cabal2nix now. I did have a go a while back at updating it for use with a newer nixpkgs. Here is where I got to.... # This Nix file can be handy when working on the github version of pandoc.
#
# To build pandoc run:
# nix-build
# To run a nix shell with everything needed to build pandoc with cabal:
# nix-shell
# To build pandoc for use on Linux and macOS systems without Nix:
# nix-build -A patched
{ pkgs ?
import ((import <nixpkgs> {}).pkgs.fetchFromGitHub {
owner = "NixOS"; repo = "nixpkgs";
rev = "6450d8c5ca6f4a9de975897bccdebc15c68f1ec3";
sha256 = "1fyzihzkwyl0g0lpiq59d37waxqzr590z28b0jp5q85x3p68vp2r";
}) {} }:
let haskellPackages = pkgs.haskellPackages;
overrides = self: super: { };
source-overrides = {
pandoc-types = pkgs.fetchFromGitHub {
owner = "jgm";
repo = "pandoc-types";
rev = "177473c655a128b1d95e35b314c277a9d5e71427";
sha256 = "1v6qqvrzrl2z6zbagh78vfis6slvvscnnq3qkk4jn448gl0s4qs3";
};
};
filterHaskellSource = src:
builtins.filterSource (path: type:
pkgs.lib.all (i: i != baseNameOf path) [ ".git" "dist-newstyle" "cabal.project.local" "dist" ".stack-work" ".DS_Store" "default.nix" "result" ]
&& pkgs.lib.all (i: !(pkgs.lib.hasSuffix i path)) [ ".lkshf" ]
&& pkgs.lib.all (i: !(pkgs.lib.hasPrefix i path)) [ ".ghc.environment." ]
) src;
# Normal nix derivation
drv = (
haskellPackages.extend (
pkgs.lib.composeExtensions (
haskellPackages.packageSourceOverrides source-overrides
) overrides
)
).callCabal2nix "pandoc" (filterHaskellSource ./.) {};
# Like drv but with static linking for haskell libraries
static = pkgs.haskell.lib.justStaticExecutables (drv.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [
pkgs.zlib.static
haskellPackages.file-embed
];
configureFlags = [
"-fembed_data_files"
"--disable-executable-dynamic"
];
}));
# Patch binaries for use on macOS and linux systems without nix
# and bundle the required gmp and lua libraries
patched = pkgs.stdenv.mkDerivation {
name = "pandoc-patched";
buildInputs = [
static
pkgs.zip
pkgs.gnutar
];
unpackPhase = "true";
buildPhase = "true";
installPhase = if pkgs.stdenv.isDarwin
then ''
mkdir -p $out/bin
cp ${static}/bin/pandoc $out/bin
cp ${pkgs.gmp}/lib/libgmp.10.dylib $out/bin
cp ${pkgs.lua5_3}/lib/liblua.5.3.4.dylib $out/bin
chmod +w $out/bin/*
echo patching libgmp and liblua
install_name_tool -id "@executable_path/libgmp.10.dylib" "$out/bin/libgmp.10.dylib"
install_name_tool -id "@executable_path/liblua.5.3.4.dylib" "$out/bin/liblua.5.3.4.dylib"
for fn in $out/bin/*; do
echo patching $fn
install_name_tool -change "${pkgs.libiconv}/lib/libiconv.dylib" /usr/lib/libiconv.dylib "$fn"
install_name_tool -change "${pkgs.stdenv.libc}/lib/libSystem.B.dylib" /usr/lib/libSystem.B.dylib "$fn"
install_name_tool -change "${pkgs.gmp}/lib/libgmp.10.dylib" "@executable_path/libgmp.10.dylib" "$fn"
install_name_tool -change "${pkgs.lua5_3}/lib/liblua.5.3.4.dylib" "@executable_path/liblua.5.3.4.dylib" "$fn"
done
(cd $out/.. && zip -r $out/pandoc-macOS.zip `basename $out`/bin)
''
else ''
mkdir -p $out/bin
cp ${static}/bin/pandoc $out/bin
cp ${pkgs.gmp}/lib/libgmp.so* $out/bin
cp ${pkgs.lua5_3}/lib/liblua.so* $out/bin
chmod +w $out/bin/pandoc
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $out/bin/pandoc
patchelf --set-rpath '$ORIGIN' $out/bin/pandoc
(cd $out/.. && tar -czf $out/pandoc-linux.tar.gz `basename $out`/bin)
'';
};
in if pkgs.lib.inNixShell then drv.env else drv // { inherit static patched; } |
I managed to install the latest |
Depending on your use-case, you can use the default pandoc nix package: https://nixos.org/nixos/packages.html#pandoc-2, for example:
|
My use case is to use |
@srid I found your comment by googling, actually the version of pandoc is really outdated (2.14.02) and i need a simple derivation for a flake to compile a latest version (2.14.2 or newer) . Do you have this in stock ? thanks |
I am trying to build with the command
nix-build
but I am having this problem
building '/nix/store/xdc8nr2pkxx6w04r9cp5hlwwjqk2na40-cabal2nix-pandoc.drv'... installing error: anonymous function at /nix/store/c9gjkn3a7w7wbdl8ws9g7n1mrmx978mb-cabal2nix-pandoc/default.nix:1:1 called without required argument 'HsYAML', at /nix/store/y0g35y0zdf3pkyjhmv34h3h1nkifivs9-source/pkgs/development/haskell-modules/make-package-set.nix:88:27
The text was updated successfully, but these errors were encountered: