Skip to content

Commit

Permalink
survey: Export final overlay as pkgs. Fixes #39.
Browse files Browse the repository at this point in the history
It fixes problems with e.g. `-lsqlite` not finding its `.a` file
when the `static-stack2nix-builder` is used because that one uses just
`.pkgs` as exported from `survey`.

If that exported `.pkgs` doesn't have archive files for sqlite (which until
now it didn't have, becuase it just re-exported the `pkgs` from survey's import
list), then of course linking will fail.

Odd is that fixing this also triggers the
`zlib = issue_61682_throw "zlib" previous.zlib;` notice (see added comment);
I don't know why that is.
Commenting it out requires building a new GHC for the example with ghc 8.6.5 in
#39 (comment),
with these key changes:

    % nix-diff /nix/store/jp8cc8hy35hbvwx19pv5aa8fqvf1b7pn-ghc-8.6.5.drv /nix/store/kxkmvjn9xc7027a3x8ydxba5rck9hz82-ghc-8.6.5.drv
    - /nix/store/jp8cc8hy35hbvwx19pv5aa8fqvf1b7pn-ghc-8.6.5.drv:{out}
    + /nix/store/kxkmvjn9xc7027a3x8ydxba5rck9hz82-ghc-8.6.5.drv:{out}
    • The input named `D5123.diff` differs
      - /nix/store/7nd9wjx2qkjggw3d5jrk1w1aar7ydjcp-D5123.diff.drv:{out}
      + /nix/store/8qcr2ksi16h95kxwal75zpi9v6r6jmr4-D5123.diff.drv:{out}
      • The input named `curl-7.64.1` differs
        - /nix/store/wpaqwfz8gg6vfvc588cqc9ry358xv4ig-curl-7.64.1.drv:{dev}
        + /nix/store/rlj4m1xj45wrispidf7719gpf9j2gp4w-curl-7.64.1.drv:{dev}
        • The input named `libkrb5-1.17` differs
          - /nix/store/w3hv9rgwb4lhabksp2d9cnzcdwv1mks2-libkrb5-1.17.drv:{dev}
          + /nix/store/d3s9r6w9d1m072y7ykhyfwap2s6807sl-libkrb5-1.17.drv:{dev}
          • The input named `keyutils-1.6` differs
            - /nix/store/hc9f4ngpkw2qkf76c4qdzrr5y2dahav1-keyutils-1.6.drv:{dev}
            + /nix/store/47wjga8hqnfmvh7g87sbhihsjr00sh3n-keyutils-1.6.drv:{dev}
            • The environments do not match:
                + dontDisableStatic=1
          • The input named `openssl-1.0.2r` differs
            - /nix/store/f0y72fc905zn03p2jrbg64ppvbxw9kqz-openssl-1.0.2r.drv:{dev}
            + /nix/store/jh0dg4vi4zq15wqichppc7wjf20qbh1p-openssl-1.0.2r.drv:{dev}
            • The environments do not match:
                postInstall=''
                    ←# If we're building dyna←m←ic 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

                    m←kdir -p $bin
                    substituteInPlace $out/bin/c_rehash --replace /nix/store/8kl94wsr19xxsk676xi956nsmdpihybw-perl-5.28.2 /nix/store/8kl94wsr19xxsk676xi956nsmdpihybw-perl-5.28.2
                    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}
                ''

Important here: `dontDisableStatic=1` in `keyutils`, and the removal
of `.a`-removal for `openssl` (`←` is what's usually red for deletion in
`nix-diff`).
  • Loading branch information
nh2 committed Aug 9, 2019
1 parent 71d3aaa commit 9a3e919
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions survey/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,16 @@ let
patchelf = issue_61682_throw "patchelf" previous.patchelf;
pcre = issue_61682_throw "pcre" previous.pcre;
xz = issue_61682_throw "xz" previous.xz;
zlib = issue_61682_throw "zlib" previous.zlib;
# For unknown reason we can't do this check on `zlib`, because if we do, we get:
#
# while evaluating the attribute 'zlib_static' at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:498:5:
# while evaluating the attribute 'zlib.override' at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:525:5:
# while evaluating 'issue_61682_throw' at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:455:29, called from /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:525:12:
# If you see this, nixpkgs #61682 has been fixed and zlib should be overridden
#
# So somehow, the above `zlib_static` uses *this* `zlib`, even though
# the above uses `previous.zlib.override` and thus shouldn't see this one.
#zlib = issue_61682_throw "zlib" previous.zlib;

postgresql = (previous.postgresql.overrideAttrs (old: { dontDisableStatic = true; })).override {
# We need libpq, which does not need systemd,
Expand Down Expand Up @@ -854,13 +863,6 @@ let
];
}))).override { openblasCompat = final.openblasCompat; };

# TODO Find out why this is needed.
# Without this, the stack in `./static-stack` doesn't link,
# complaining `cannot find -lsqlite3`.
# `persistent-sqlite` should already be using `final.sqlite`,
# but apparently it's not.
persistent-sqlite = super.persistent-sqlite.override { sqlite = final.sqlite; };

# TODO For the below packages, it would be better if we could somehow make all users
# of postgresql-libpq link in openssl via pkgconfig.
postgresql-schema =
Expand Down Expand Up @@ -1121,7 +1123,10 @@ in
];

inherit normalPkgs;
inherit pkgs;
approachPkgs = pkgs;
# Export as `pkgs` our final overridden nixpkgs.
pkgs = pkgsWithStaticHaskellBinaries;

inherit lib;

inherit pkgsWithArchiveFiles;
Expand Down

0 comments on commit 9a3e919

Please sign in to comment.