Skip to content

Commit

Permalink
WIP: Show how overrideScope breaks darcs due to overridden dependen…
Browse files Browse the repository at this point in the history
…cies disapperaring.

The problem becomes apparent when you toggle between the two lines below
`# Breaks darcs linking`.

`nix-diff` shows what the issue is (full output below):

The usage of `overrideScope` results in all the flags I've passed to
`curl`'s dependencies (such as `dontDisableStatic=1`) to be undone.

I have no idea why this is.

Full `nix-diff` output:

		% nix-diff /nix/store/xhd65dan5hxab1r7dcc6za5xv82pniia-darcs-2.14.1.drv /nix/store/xwm9qnd17xv8gspgc3xv2mwvy7nmazck-darcs-2.14.1.drv
		- /nix/store/xhd65dan5hxab1r7dcc6za5xv82pniia-darcs-2.14.1.drv:{out}
		+ /nix/store/xwm9qnd17xv8gspgc3xv2mwvy7nmazck-darcs-2.14.1.drv:{out}
		• The input named `curl-7.60.0` differs
		  - /nix/store/j78l98i1b9w2a134yd5c178lvajm2201-curl-7.60.0.drv:{dev}
		  + /nix/store/v8fihhqs71mj8brrq2id88f3cg998raz-curl-7.60.0.drv:{dev}
		  • The set of input names do not match:
		      - krb5-1.15.2
		      + libkrb5-1.15.2
		  • The input named `libssh2-1.8.0` differs
		    - /nix/store/5fhvqzj4xrpgfyksfnxyizy2xyaxn1js-libssh2-1.8.0.drv:{dev,out}
		    + /nix/store/chm7lbwwqi3lr0hrdsa3p6fmxg1i2lfi-libssh2-1.8.0.drv:{dev,out}
		    • The environments do not match:
		        - dontDisableStatic=1
		  • The input named `nghttp2-1.32.0` differs
		    - /nix/store/8aqc6x7cn21didf8361mql66czgkcrqb-nghttp2-1.32.0.drv:{dev}
		    + /nix/store/g4vlczym1nyr5y2qp1ay8g4ghi6gxrwd-nghttp2-1.32.0.drv:{dev}
		    • The environments do not match:
		        - dontDisableStatic=1
		  • The input named `openssl-1.0.2o` differs
		    - /nix/store/dn68nfi0rw1sz00b1jh1yc4j3pqzyay0-openssl-1.0.2o.drv:{dev}
		    + /nix/store/42s7f2mx7pjv16sw2f4s1qxz0fpjhhfh-openssl-1.0.2o.drv:{dev}
		    • The environments do not match:
		        postInstall=''
		            # If we're building dynamic libraries, then don't install static
		            # libraries.
		            if [ -n "$(echo $out/lib/*.so $out/lib/*.dylib $out/lib/*.dll)" ]; then
		                rm "$out/lib/"*.a
		            fi

		            mkdir -p $bin
		            mv $out/bin $bin/

		            mkdir $dev
		            mv $out/include $dev/

		            # remove dependency on Perl at runtime
		            rm -r $out/etc/ssl/misc

		            rmdir $out/etc/ssl/{certs,private}

		        ''
		  • The set of inputs named `zlib-1.2.11` do not match
		• The input named `sandi-0.4.2` differs
		  - /nix/store/x0x9ls6kg80cwqvsn7pxn1xbq8awdcyi-sandi-0.4.2.drv:{out}
		  + /nix/store/rlg3gmhal51m5mk2dn478by8wb4z2bin-sandi-0.4.2.drv:{out}
		  • The input named `conduit-1.3.0.3` differs
		    - /nix/store/bb5z28i8xmsd67aq032cmy53i8m8ndnr-conduit-1.3.0.3.drv:{out}
		    + /nix/store/ngpirmshgqh4m0k9zdh7n92lbpwf25a4-conduit-1.3.0.3.drv:{out}
		    • The input named `mono-traversable-1.0.8.1` differs
		      - /nix/store/id8sm6zljzvvlrxkral36afayi053w2v-mono-traversable-1.0.8.1.drv:{out}
		      + /nix/store/6jk92lzb52cjmf3f462hw6wn3md2lkif-mono-traversable-1.0.8.1.drv:{out}
		      • The input named `foldl-1.4.2` differs
		        - /nix/store/v014xp2j0yym430qh75b1dzcpfpi75f9-foldl-1.4.2.drv:{out}
		        + /nix/store/01dkg7ziaplid88l9hgjni7jdqy9asfl-foldl-1.4.2.drv:{out}
		        • The input named `comonad-5.0.4` differs
		          - /nix/store/jpj8n4343hwx5gcp9m6jsyhxvv4nxdzr-comonad-5.0.4.drv:{out}
		          + /nix/store/ihlbjd75y0axibq3wbq0fqqn2pskdcny-comonad-5.0.4.drv:{out}
		          • The set of input names do not match:
		              + Cabal-2.2.0.1
		          • The input named `cabal-doctest-1.0.6` differs
		            - /nix/store/gsmaszkyrlf5fpafcyza11ww2gbs2ihf-cabal-doctest-1.0.6.drv:{out}
		            + /nix/store/5g92pm5gmpgip7b7frv3yvxw68d9m59l-cabal-doctest-1.0.6.drv:{out}
		            • The set of input names do not match:
		                + Cabal-2.2.0.1
		            • The environments do not match:
		                propagatedBuildInputs=''
		                     /nix/store/23h7pm6p9lq8walbf6dlw7kmgg0wiwn1-Cabal-2.2.0.1
		                ''
		          • The input named `distributive-0.5.3` differs
		            - /nix/store/gzzygh7v8wdzdrkhc1fj85ric0xgnpp6-distributive-0.5.3.drv:{out}
		            + /nix/store/0aijd9lf2122zwlbj7ci25a1wq1chlqw-distributive-0.5.3.drv:{out}
		            • The set of input names do not match:
		                + Cabal-2.2.0.1
		            • The input named `cabal-doctest-1.0.6` differs
		              • These two derivations have already been compared
		            • The input named `doctest-0.16.0` differs
		              - /nix/store/3vjlc6wcv7cv0100k10fb6c30kkwh0nh-doctest-0.16.0.drv:{out}
		              + /nix/store/rl7y48cz7wadl99w077lfy3bcglj2n9c-doctest-0.16.0.drv:{out}
		              • The input named `ghc-paths-0.1.0.9` differs
		                - /nix/store/bc1lbhhvfay6n0dxsxzizckdzi1cr84y-ghc-paths-0.1.0.9.drv:{out}
		                + /nix/store/9ksqaiaz5zw158drynmj4whx3xkav6jm-ghc-paths-0.1.0.9.drv:{out}
		                • The set of input names do not match:
		                    + Cabal-2.2.0.1
		                • The environments do not match:
		                    nativeBuildInputs=''
		                        /nix/store/hfi080vzqqzfip6bd6x4cxc2jgj56xn3-ghc-8.4.3 /nix/store/1bimh3fn2dshxfz1y11clwalh9mls2lm-remove-references-to  /nix/store/23h7pm6p9lq8walbf6dlw7kmgg0wiwn1-Cabal-2.2.0.1
		                    ''
		          • The input named `doctest-0.16.0` differs
		            • These two derivations have already been compared
		        • The input named `profunctors-5.2.2` differs
		          - /nix/store/g4093ba1sp261kwa0markzylds31mhl6-profunctors-5.2.2.drv:{out}
		          + /nix/store/3d7rmxwm16ldw1jqyawkj0s52yy3r4r3-profunctors-5.2.2.drv:{out}
		          • The input named `bifunctors-5.5.3` differs
		            - /nix/store/mx3gds4si7yhh0z338d57x1qw6d3g91h-bifunctors-5.5.3.drv:{out}
		            + /nix/store/86jj9b16jac8f9sq60k4lam18svz63i4-bifunctors-5.5.3.drv:{out}
		            • The input named `comonad-5.0.4` differs
		              • These two derivations have already been compared
		          • The input named `comonad-5.0.4` differs
		            • These two derivations have already been compared
		          • The input named `distributive-0.5.3` differs
		            • These two derivations have already been compared
		        • The input named `semigroupoids-5.2.2` differs
		          - /nix/store/b08g46h9qa0nivkqpni86langljbspmw-semigroupoids-5.2.2.drv:{out}
		          + /nix/store/a6k468mg65f5lqbgmhyj34jhaabzn5pc-semigroupoids-5.2.2.drv:{out}
		          • The set of input names do not match:
		              + Cabal-2.2.0.1
		          • The input named `bifunctors-5.5.3` differs
		            • These two derivations have already been compared
		          • The input named `cabal-doctest-1.0.6` differs
		            • These two derivations have already been compared
		          • The input named `comonad-5.0.4` differs
		            • These two derivations have already been compared
		          • The input named `distributive-0.5.3` differs
		            • These two derivations have already been compared
		          • The input named `doctest-0.16.0` differs
		            • These two derivations have already been compared
		  • The input named `tasty-th-0.1.7` differs
		    - /nix/store/1ashvv2g7822ghg4xfcb62c8hz6a8y2d-tasty-th-0.1.7.drv:{out}
		    + /nix/store/202k3v7bfsmz8mm23naaz5ghkbiha79z-tasty-th-0.1.7.drv:{out}
		    • The input named `haskell-src-exts-1.20.2` differs
		      - /nix/store/saw1rvnavgv95fcwdp7sy7br19yb1ahj-haskell-src-exts-1.20.2.drv:{out}
		      + /nix/store/832sy2xlcvbmzkgrgwwp806w19cz3caq-haskell-src-exts-1.20.2.drv:{out}
		      • The input named `happy-1.19.9` differs
		        - /nix/store/nw7bv6465wxw9bwai0095px8v7iw24x0-happy-1.19.9.drv:{out}
		        + /nix/store/dkz92anrzyfpiyknfyq489q5nq0b3920-happy-1.19.9.drv:{out}
		        • The set of input names do not match:
		            + Cabal-2.2.0.1
		        • The environments do not match:
		            nativeBuildInputs=''
		                /nix/store/hfi080vzqqzfip6bd6x4cxc2jgj56xn3-ghc-8.4.3 /nix/store/1bimh3fn2dshxfz1y11clwalh9mls2lm-remove-references-to  /nix/store/23h7pm6p9lq8walbf6dlw7kmgg0wiwn1-Cabal-2.2.0.1
		            ''
		• The input named `zip-archive-0.3.3` differs
		  - /nix/store/5za06z20xfv7alab6m28qg3rb3qir8bl-zip-archive-0.3.3.drv:{out}
		  + /nix/store/40d9ls91yajs93racv6vk6xnfzkak3k6-zip-archive-0.3.3.drv:{out}
		  • The set of input names do not match:
		      + Cabal-2.2.0.1
		  • The environments do not match:
		      nativeBuildInputs=''
		          /nix/store/hfi080vzqqzfip6bd6x4cxc2jgj56xn3-ghc-8.4.3 /nix/store/1bimh3fn2dshxfz1y11clwalh9mls2lm-remove-references-to  /nix/store/23h7pm6p9lq8walbf6dlw7kmgg0wiwn1-Cabal-2.2.0.1 /nix/store/kvv5hdfrmiil2gpdv8nringixd1x8las-unzip-6.0
		      ''
  • Loading branch information
nh2 committed Jul 21, 2018
1 parent 927604a commit 52416d2
Showing 1 changed file with 38 additions and 26 deletions.
64 changes: 38 additions & 26 deletions survey/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ let
(pkgs.haskell.lib.overrideCabal pkg (drv: {
passthru.broken = drv.broken or false;
})).broken;
# isBroken = pkg: pkg.meta.broken or false;

# Function that for a given Haskell package tells us if any of
# its dependencies is marked as `broken`.
Expand Down Expand Up @@ -164,12 +165,19 @@ let

Cabal_patched = normalHaskellPackages.callCabal2nix "Cabal" Cabal_patched_Cabal_subdir {};

useFixedCabal = drv: pkgs.haskell.lib.overrideCabal drv (old: {
setupHaskellDepends = (if old ? setupHaskellDepends then old.setupHaskellDepends else []) ++ [ Cabal_patched ];
addFixedCabalDeps = drv: pkgs.haskell.lib.overrideCabal drv (old: {
setupHaskellDepends = (old.setupHaskellDepends or []) ++ [ Cabal_patched ];
# TODO Check if this is necessary
libraryHaskellDepends = (if old ? libraryHaskellDepends then old.libraryHaskellDepends else []) ++ [ Cabal_patched ];
# libraryHaskellDepends = (old.libraryHaskellDepends or []) ++ [ Cabal_patched ];
libraryHaskellDepends = (old.libraryHaskellDepends or []) ++ [ Cabal_patched ];
});

# TODO comment
# See https://github.com/NixOS/nixpkgs/issues/43849#issuecomment-406615173
useFixedCabalRecursively = drv: ((addFixedCabalDeps drv).overrideScope (self: super: {
Cabal = Cabal_patched;
}));


# Overriding system libraries that don't provide static libs
# (`.a` files) by default
Expand Down Expand Up @@ -230,30 +238,25 @@ let
persistent-sqlite = super.persistent-sqlite.override { sqlite = sqlite_static; };
lzma = super.lzma.override { lzma = lzma_static; };

# If we `useFixedCabal` on stack, we also need to use the
# it on hpack and hackage-security because otherwise
# stack depends on 2 different versions of Cabal.
hpack = useFixedCabal super.hpack;
hackage-security = useFixedCabal super.hackage-security;

# See https://github.com/hslua/hslua/issues/67
# It's not clear if it's safe to disable this as key functionality may be broken
hslua = dontCheck super.hslua;

hsyslog = useFixedCabal super.hsyslog;
# For packages which depend on Cabal-the-library, either directly or via
# their dependencies (and each either themselves, or via their Setup.hs),
# we have to `useFixedCabalRecursively` to ensure they and everything
# below them sees the same version of Cabal.

# Depends on Cabal directly
# stack = useFixedCabalRecursively super.stack;
# Depends on `cabal-doctest` which depends on Cabal
# hsyslog = useFixedCabalRecursively super.hsyslog;

# Without this, when compiling `hsyslog`, GHC sees 2 Cabal
# libraries, the unfixed one provided by cabal-doctest
# (which is GHC's global unfixed one), and the fixed one as declared
# for `hsyslog` through statify.
# GHC does NOT issue a warning in that case, but just silently
# picks the one from the global package database (the one
# cabal-doctest would want), instead of the one from our
# `useFixedCabal` one which is given on the command line at
# https://github.com/NixOS/nixpkgs/blob/e7e5aaa0b9/pkgs/development/haskell-modules/generic-builder.nix#L330
cabal-doctest = useFixedCabal super.cabal-doctest;

darcs = appendConfigureFlag (super.darcs.override { curl = curl_static; }) [
# TODO remove
"-O0"

# Ugly alert: We use `--start-group` to work around the fact that
# the linker processes `-l` flags in the order they are given,
# so order matters, see
Expand All @@ -268,6 +271,10 @@ let
# have the boolean arguments that determine it in `passthru`.
# TODO Even better, propagate these flags from curl somehow.

# TODO Much easier, we can do it with `pkgconfig`:
# overrideCabal to add `pkgconfig` as a dependency, and
# pass the pkgconfig flag to darcs's cabal configure

# Note: This is the order in which linking would work even if
# `--start-group` wasn't given.
"--ld-option=-lgssapi_krb5"
Expand All @@ -285,13 +292,17 @@ let


postgresql-libpq = super.postgresql-libpq.override { postgresql = postgresql_static; };

});

});

statify = drv: with pkgs.haskell.lib; pkgs.lib.foldl appendConfigureFlag (disableLibraryProfiling (disableSharedExecutables (useFixedCabal drv))) [
# Breaks darcs linking
statify = drv: with pkgs.haskell.lib; pkgs.lib.foldl appendConfigureFlag (disableLibraryProfiling (disableSharedExecutables (useFixedCabalRecursively drv))) [
# Works with darcs
# statify = drv: with pkgs.haskell.lib; pkgs.lib.foldl appendConfigureFlag (disableLibraryProfiling (disableSharedExecutables (addFixedCabalDeps drv))) [
# "--ghc-option=-fPIC"
"--enable-executable-static" # requires `useFixedCabal`
"--enable-executable-static" # requires `useFixedCabalRecursively`
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
# TODO These probably shouldn't be here but only for packages that actually need them
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
Expand Down Expand Up @@ -323,16 +334,17 @@ in
rec {
working = {
inherit (haskellPackages)
hello
stack
hello # Minimal dependencies
stack # Many dependencies
hlint
ShellCheck
cabal-install
bench
dhall
cachix
darcs
pandoc
darcs # Has native dependencies (`libcurl` and its dependencies)
pandoc # Depends on Lua
hsyslog # Small example of handling https://github.com/NixOS/nixpkgs/issues/43849 correctly
;
};

Expand Down

0 comments on commit 52416d2

Please sign in to comment.