Skip to content
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

Use horizon-platform and horizon-devtools at GHC 9.6.x #123

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

locallycompact
Copy link

@locallycompact locallycompact commented Feb 6, 2024

Proof of concept for using https://horizon-haskell.net/ instead of nixpkgs package set.

  • Working proof of concept on Linux
  • Working proof of concept on macOS
  • Linux & macOS horizon cache -> Use in GitHub Actions

@srid
Copy link
Owner

srid commented Feb 6, 2024

Testing this on macOS:

image
Full log ``` ❯ nix develop --show-trace error: … while calling the 'derivationStrict' builtin
     at /derivation-internal.nix:9:12:

        8|
        9|   strict = derivationStrict drvAttrs;
         |            ^
       10|

   … while evaluating derivation 'haskell-template'
     whose name attribute is located at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/stdenv/generic/make-derivation.nix:352:7

   … while evaluating attribute '__impureHostDeps' of derivation 'haskell-template'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/stdenv/generic/make-derivation.nix:491:7:

      490|       __propagatedSandboxProfile = unique (computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile ]);
      491|       __impureHostDeps = computedImpureHostDeps ++ computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps ++ __impureHostDeps ++ stdenv.__extraImpureHostDeps ++ [
         |       ^
      492|         "/dev/zero"

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/stdenv/generic/make-derivation.nix:330:5:

      329|   computedImpureHostDeps =
      330|     unique (concatMap (input: input.__propagatedImpureHostDeps or [])
         |     ^
      331|       (stdenv.extraNativeBuildInputs

   … while calling 'foldl''

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:139:5:

      138|     # The list to fold
      139|     list:
         |     ^
      140|

   … while calling anonymous lambda

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/stdenv/generic/make-derivation.nix:330:24:

      329|   computedImpureHostDeps =
      330|     unique (concatMap (input: input.__propagatedImpureHostDeps or [])
         |                        ^
      331|       (stdenv.extraNativeBuildInputs

   … while calling 'chooseDevOutputs'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/attrsets.nix:1146:5:

     1145|     # List of packages to pick `dev` outputs from
     1146|     drvs:
         |     ^
     1147|     builtins.map getDev drvs;

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/stdenv/generic/make-derivation.nix:293:51:

      292|       (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild))
      293|       (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs'))
         |                                                   ^
      294|       (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget))

   … while calling 'checkDependencyList''

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/stdenv/generic/make-derivation.nix:265:43:

      264|   checkDependencyList = checkDependencyList' [];
      265|   checkDependencyList' = positions: name: deps: flip imap1 deps (index: dep:
         |                                           ^
      266|     if isDerivation dep || dep == null || builtins.isString dep || builtins.isPath dep then dep

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/stdenv/generic/make-derivation.nix:265:49:

      264|   checkDependencyList = checkDependencyList' [];
      265|   checkDependencyList' = positions: name: deps: flip imap1 deps (index: dep:
         |                                                 ^
      266|     if isDerivation dep || dep == null || builtins.isString dep || builtins.isPath dep then dep

   … while calling 'flip'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/trivial.nix:148:16:

      147|   */
      148|   flip = f: a: b: f b a;
         |                ^
      149|

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/trivial.nix:148:19:

      147|   */
      148|   flip = f: a: b: f b a;
         |                   ^
      149|

   … while calling 'imap1'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:165:14:

      164|   */
      165|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
         |              ^
      166|

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/build-support/mkshell/default.nix:41:36:

       40|   buildInputs = mergeInputs "buildInputs";
       41|   nativeBuildInputs = packages ++ (mergeInputs "nativeBuildInputs");
         |                                    ^
       42|   propagatedBuildInputs = mergeInputs "propagatedBuildInputs";

   … while calling 'mergeInputs'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/build-support/mkshell/default.nix:17:17:

       16| let
       17|   mergeInputs = name:
         |                 ^
       18|     (attrs.${name} or [ ]) ++

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/pkgs/build-support/mkshell/default.nix:23:36:

       22|     # this leaves actual dependencies of the derivations in `inputsFrom`, but never the derivations themselves
       23|     (lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));
         |                                    ^
       24|

   … while calling 'flatten'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:186:13:

      185|   */
      186|   flatten = x:
         |             ^
      187|     if isList x

   … while calling anonymous lambda

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:188:21:

      187|     if isList x
      188|     then concatMap (y: flatten y) x
         |                     ^
      189|     else [x];

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:188:24:

      187|     if isList x
      188|     then concatMap (y: flatten y) x
         |                        ^
      189|     else [x];

   … while calling 'flatten'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:186:13:

      185|   */
      186|   flatten = x:
         |             ^
      187|     if isList x

   … while calling anonymous lambda

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:188:21:

      187|     if isList x
      188|     then concatMap (y: flatten y) x
         |                     ^
      189|     else [x];

   … from call site

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:188:24:

      187|     if isList x
      188|     then concatMap (y: flatten y) x
         |                        ^
      189|     else [x];

   … while calling 'flatten'

     at /nix/store/52nwmx07625ygk61mhzp02f407w498rl-source/lib/lists.nix:186:13:

      185|   */
      186|   flatten = x:
         |             ^
      187|     if isList x

   … while calling 'getOutput'

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/lib/attrsets.nix:1083:23:

     1082|   */
     1083|   getOutput = output: pkg:
         |                       ^
     1084|     if ! pkg ? outputSpecified || ! pkg.outputSpecified

   … while calling anonymous lambda

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/stdenv/generic/make-derivation.nix:289:13:

      288|       (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild))
      289|       (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs'))
         |             ^
      290|       (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget))

   … while calling anonymous lambda

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/lib/lists.nix:165:29:

      164|   */
      165|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
         |                             ^
      166|

   … from call site

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/lib/lists.nix:165:32:

      164|   */
      165|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
         |                                ^
      166|

   … while calling anonymous lambda

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/stdenv/generic/make-derivation.nix:261:73:

      260|   checkDependencyList = checkDependencyList' [];
      261|   checkDependencyList' = positions: name: deps: flip imap1 deps (index: dep:
         |                                                                         ^
      262|     if isDerivation dep || dep == null || builtins.isString dep || builtins.isPath dep then dep

   … from call site

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/stdenv/generic/make-derivation.nix:262:8:

      261|   checkDependencyList' = positions: name: deps: flip imap1 deps (index: dep:
      262|     if isDerivation dep || dep == null || builtins.isString dep || builtins.isPath dep then dep
         |        ^
      263|     else if isList dep then checkDependencyList' ([index] ++ positions) name dep

   … while calling 'isDerivation'

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/lib/attrsets.nix:780:5:

      779|     # Value to check.
      780|     value: value.type or null == "derivation";
         |     ^
      781|

   … from call site

     at /nix/store/lrmxkfadhlcrakza60w0mc8sc327a5qg-source/pkgs/development/haskell-modules/make-package-set.nix:94:56:

       93|       # Converts a returned function to a functor attribute set if necessary
       94|       ensureAttrs = v: if builtins.isFunction v then { __functor = _: v; } else v;
         |                                                        ^
       95|

   … while calling anonymous lambda

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/with-packages-wrapper.nix:19:1:

       18| #   (hpkgs: [ hpkgs.mtl hpkgs.lens ])
       19| selectPackages:
         | ^
       20|

   … from call site

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/with-packages-wrapper.nix:69:62:

       68|                       (pkg: [ pkg ] ++ lib.optionals installDocumentation [ (lib.getOutput "doc" pkg) ])
       69|                       (lib.filter (x: x ? isHaskellLibrary) (lib.closePropagation packages))
         |                                                              ^
       70|                   );

   … while calling 'closePropagationFast'

     at /nix/store/lrmxkfadhlcrakza60w0mc8sc327a5qg-source/lib/deprecated.nix:168:26:

      167|   # See https://github.com/NixOS/nixpkgs/pull/194391 for details.
      168|   closePropagationFast = list:
         |                          ^
      169|     builtins.map (x: x.val) (builtins.genericClosure {

   … from call site

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/with-packages-wrapper.nix:45:19:

       44|
       45|   packages      = selectPackages haskellPackages
         |                   ^
       46|                   ++ lib.optional withHoogle (hoogleWithPackages selectPackages);

   … while calling anonymous lambda

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/generic-builder.nix:747:32:

      746|
      747|         ghcEnv = withPackages (_:
         |                                ^
      748|           otherBuildInputsHaskell ++

   … while calling 'zipperCombinedPkgs'

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/make-package-set.nix:478:30:

      477|         # assuming new-style commands.
      478|         zipperCombinedPkgs = vals:
         |                              ^
      479|           pkgs.lib.concatMap

   … while calling anonymous lambda

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/make-package-set.nix:480:14:

      479|           pkgs.lib.concatMap
      480|             (drvList: pkgs.lib.filter isNotSelected drvList)
         |              ^
      481|             vals;

   … while calling 'isNotSelected'

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/make-package-set.nix:459:25:

      458|         #   => true
      459|         isNotSelected = input: pkgs.lib.all (p: input.outPath or null != p.outPath) selected;
         |                         ^
      460|

   … while calling anonymous lambda

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/development/haskell-modules/make-package-set.nix:459:46:

      458|         #   => true
      459|         isNotSelected = input: pkgs.lib.all (p: input.outPath or null != p.outPath) selected;
         |                                              ^
      460|

   … while evaluating derivation 'aeson-2.2.1.0'
     whose name attribute is located at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/stdenv/generic/make-derivation.nix:348:7

   … while evaluating attribute 'depsBuildBuild' of derivation 'aeson-2.2.1.0'

     at /nix/store/vqljs1ixabpdbfmq3llnlkj5dac1hq4c-source/pkgs/stdenv/generic/make-derivation.nix:391:7:

      390|
      391|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
         |       ^
      392|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;

   … while evaluating derivation 'ghc-9.8.1'
     whose name attribute is located at /nix/store/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source/pkgs/stdenv/generic/make-derivation.nix:348:7

   … while evaluating attribute 'preConfigure' of derivation 'ghc-9.8.1'

     at /nix/store/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source/pkgs/development/compilers/ghc/common-hadrian.nix:284:3:

      283|   # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
      284|   preConfigure = ''
         |   ^
      285|     for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do

   … from call site

     at /nix/store/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source/pkgs/development/compilers/ghc/common-hadrian.nix:314:8:

      313|     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
      314|   '' + lib.optionalString stdenv.isDarwin ''
         |        ^
      315|     export NIX_LDFLAGS+=" -no_dtrace_dof"

   … while calling 'optionalString'

     at /nix/store/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source/lib/strings.nix:257:5:

      256|     # String to return if condition is true
      257|     string: if cond then string else "";
         |     ^
      258|

   error: cannot coerce null to a string
</summary>

@locallycompact
Copy link
Author

How is that null? It's

  '' + lib.optionalString stdenv.isDarwin ''
    export NIX_LDFLAGS+=" -no_dtrace_dof"

    # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
    export XATTR=${lib.getBin xattr}/bin/xattr
  ''

@locallycompact
Copy link
Author

Actually can you check that's correct?

@locallycompact
Copy link
Author

The source to build ghc is here: https://gitlab.horizon-haskell.net/ghc/horizon-ghc

@srid
Copy link
Owner

srid commented Feb 6, 2024

xattr is set to null in buildGhc.nix?

image

@srid
Copy link
Owner

srid commented Feb 6, 2024

Actually yes, that's a strange error that optionalString is getting null as 2nd argument.

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@locallycompact
Copy link
Author

What should xattr be set to?

@srid

This comment was marked as resolved.

@srid srid changed the title Use horizon-platform and horizon-devtools at GHC 9.8.1 Use horizon-platform and horizon-devtools at GHC 9.6.x Feb 9, 2024
Copy link
Owner

@srid srid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great. Instead of merging this in this repo, I want to upstream this module somewhere and document it in https://community.flake.parts/haskell-flake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants