From 0f83871e52aab773d09ce24bc1e927cd09cf1d37 Mon Sep 17 00:00:00 2001 From: Oliver Charles Date: Mon, 1 Jul 2019 13:19:26 +0100 Subject: [PATCH 01/22] Bump nix-tools to latest master revision --- nix-tools/nix-tools-src.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix-tools/nix-tools-src.json b/nix-tools/nix-tools-src.json index 19c5b8f40a..00f5ac6612 100644 --- a/nix-tools/nix-tools-src.json +++ b/nix-tools/nix-tools-src.json @@ -1,7 +1,7 @@ { "url": "https://github.com/input-output-hk/nix-tools", - "rev": "69ca9bd0c1994f7bddb12bc1a99ac980e7365c14", + "rev": "bb5700d04f0ff2d1a3a7b3278121c1ec67898793", "date": "2019-05-23T11:35:17+08:00", - "sha256": "0f9ds6i4qni6xfgh8bq5kr469wr8j7a2zlb9l9g6gqy0y3hpihqm", + "sha256": "11q34s5hm76vb6r01h3r5ya9k9f4xqz2xdf958frhn6jb3jjihf6", "fetchSubmodules": false } From 8070c25f6ca7534eee413673cd4d787d5c8b57b8 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Wed, 27 Jan 2021 09:48:42 +0000 Subject: [PATCH 02/22] Add writeHieFiles --- builder/comp-builder.nix | 7 ++++++- modules/plan.nix | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/builder/comp-builder.nix b/builder/comp-builder.nix index cce4ba8866..27efa5a032 100644 --- a/builder/comp-builder.nix +++ b/builder/comp-builder.nix @@ -39,6 +39,7 @@ let self = # ghc's internal linker seems to be broken on x86. && !(stdenv.hostPlatform.isMusl && !stdenv.hostPlatform.isx86) , enableDeadCodeElimination ? component.enableDeadCodeElimination +, writeHieFiles ? component.writeHieFiles # Options for Haddock generation , doHaddock ? component.doHaddock # Enable haddock and hoogle generation @@ -180,6 +181,9 @@ let ++ lib.optionals useLLVM [ "--ghc-option=-fPIC" "--gcc-option=-fPIC" ] + ++ lib.optionals writeHieFiles [ + "--ghc-option=-fwrite-ide-info" "--ghc-option=-hiedir$hie" + ] ); setupGhcOptions = lib.optional (package.ghcOptions != null) '' --ghc${lib.optionalString (stdenv.hostPlatform.isGhcjs) "js"}-options="${package.ghcOptions}"''; @@ -314,7 +318,8 @@ let outputs = ["out" ] ++ (lib.optional enableSeparateDataOutput "data") - ++ (lib.optional keepSource "source"); + ++ (lib.optional keepSource "source") + ++ (lib.optional writeHieFiles "hie"); configurePhase = (lib.optionalString (!canCleanSource) '' diff --git a/modules/plan.nix b/modules/plan.nix index 857637392f..2c993dad0b 100644 --- a/modules/plan.nix +++ b/modules/plan.nix @@ -168,6 +168,12 @@ let default = (def.keepSource or false); description = "Keep component source in the store in a `source` output"; }; + + writeHieFiles = mkOption { + type = bool; + default = (def.writeHieFiles or false); + description = "Write component `.hie` in the store in a `hie` output"; + }; }; packageOptions = def: componentOptions def // { preUnpack = mkOption { From ee6148fc526658e5c6d6f8fab20816c2c5137fec Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Wed, 27 Jan 2021 11:30:47 +0000 Subject: [PATCH 03/22] Update modules/plan.nix Co-authored-by: Michael Peyton Jones --- modules/plan.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plan.nix b/modules/plan.nix index 2c993dad0b..0cfe71a026 100644 --- a/modules/plan.nix +++ b/modules/plan.nix @@ -172,7 +172,7 @@ let writeHieFiles = mkOption { type = bool; default = (def.writeHieFiles or false); - description = "Write component `.hie` in the store in a `hie` output"; + description = "Write component `.hie` files in the store in a `hie` output"; }; }; packageOptions = def: componentOptions def // { From 1e138c043fa031ef7c91de7f28519dfbc5a65324 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Wed, 27 Jan 2021 11:42:23 +0000 Subject: [PATCH 04/22] Move where the hie flags are specified --- builder/comp-builder.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/builder/comp-builder.nix b/builder/comp-builder.nix index 27efa5a032..c3f6d169e7 100644 --- a/builder/comp-builder.nix +++ b/builder/comp-builder.nix @@ -120,7 +120,15 @@ let [ "--prefix=$out" "${haskellLib.componentTarget componentId}" "$(cat ${configFiles}/configure-flags)" - ] ++ commonConfigureFlags); + ] ++ commonConfigureFlags + ++ # We don't specify this in 'commonConfigureFlags', as these are also + # used by haddock-builder.nix. If we do specify these options in + # commonConfigureFlags, then the haddock-builder will fail, because it + # sets its own outputs which *don't* include $hie + lib.optionals writeHieFiles [ + "--ghc-option=-fwrite-ide-info" "--ghc-option=-hiedir$hie" + ] + ); # From nixpkgs 20.09, the pkg-config exe has a prefix matching the ghc one pkgConfigHasPrefix = builtins.compareVersions lib.version "20.09pre" >= 0; @@ -181,9 +189,6 @@ let ++ lib.optionals useLLVM [ "--ghc-option=-fPIC" "--gcc-option=-fPIC" ] - ++ lib.optionals writeHieFiles [ - "--ghc-option=-fwrite-ide-info" "--ghc-option=-hiedir$hie" - ] ); setupGhcOptions = lib.optional (package.ghcOptions != null) '' --ghc${lib.optionalString (stdenv.hostPlatform.isGhcjs) "js"}-options="${package.ghcOptions}"''; From 94853afb8e806d4d980c3ca58c1e4c84ebf5816d Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Thu, 17 Jun 2021 16:26:27 +0100 Subject: [PATCH 05/22] Partially revert input-output-hk#843 --- lib/import-and-filter-project.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/import-and-filter-project.nix b/lib/import-and-filter-project.nix index 2b78f6733a..67dd1e2f8d 100644 --- a/lib/import-and-filter-project.nix +++ b/lib/import-and-filter-project.nix @@ -52,9 +52,7 @@ in project // { packageSrc = haskellLib.appendSubDir { src = srcRoot; inherit subDir; - includeSiblings = true; # Filtering sibling dirs of the package dir is done in the - # component builder so that relative paths can be used to - # reference project directories not in the package subDir. + includeSiblings = false; }; }; in oldPkg // { From e2abd5cd9d86d51df1e2fc6d0105f1e652ba0c96 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Thu, 17 Jun 2021 16:41:56 +0100 Subject: [PATCH 06/22] Check for doctest --- builder/comp-builder.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builder/comp-builder.nix b/builder/comp-builder.nix index dc2ab2711d..df420b7c90 100644 --- a/builder/comp-builder.nix +++ b/builder/comp-builder.nix @@ -28,7 +28,8 @@ let self = # (not just the one we are building). # Enable for tests in packages that use cabal-doctest. ( haskellLib.isTest componentId && - lib.any (x: x.identifier.name or "" == "cabal-doctest") package.setup-depends + lib.any (x: x.identifier.name or "" == "cabal-doctest") package.setup-depends && + lib.any (x: x.identifier.name or "" == "doctest") component.depends ) , allComponent # Used when `configureAllComponents` is set to get a suitable configuration. From c609e4e2b56deab0dae16cb15ee2e80f48e03db1 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Fri, 10 Sep 2021 17:08:29 +0100 Subject: [PATCH 07/22] Fix haskell-language-server --- overlays/hackage-quirks.nix | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/overlays/hackage-quirks.nix b/overlays/hackage-quirks.nix index 16d499da5a..c71edd9ac4 100644 --- a/overlays/hackage-quirks.nix +++ b/overlays/hackage-quirks.nix @@ -26,19 +26,6 @@ in { haskell-nix = prev.haskell-nix // { ]; }; - haskell-language-server = { - # Fixes for: - # * ghc-api-compat - cabalProject = '' - packages: . - source-repository-package - type: git - location: https://github.com/hsyl20/ghc-api-compat - tag: 8fee87eac97a538dbe81ff1ab18cff10f2f9fa15 - --sha256: sha256-byehvdxQxhNk5ZQUXeFHjAZpAze4Ct9261ro4c5acZk= - ''; - }; - hpack = { modules = [ { reinstallableLibGhc = true; } ]; }; From 3cb7ca738a40dcafc280930803c03565c565331b Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Fri, 18 Mar 2022 15:20:23 +0000 Subject: [PATCH 08/22] Revert "always clean the source, no matter what (#1403)" This reverts commit 1ca99326b2e71d8e52bb64f7a7831011abec2f09. --- flake.lock | 90 ------------------------------- flake.nix | 1 - lib/call-cabal-project-to-nix.nix | 22 ++++---- overlays/default.nix | 2 - overlays/hydra.nix | 5 -- scripts/check-hydra.nix | 3 +- 6 files changed, 13 insertions(+), 110 deletions(-) delete mode 100644 overlays/hydra.nix diff --git a/flake.lock b/flake.lock index 11d47b8cac..51b3cd6ca2 100644 --- a/flake.lock +++ b/flake.lock @@ -147,65 +147,6 @@ "type": "github" } }, - "hydra": { - "inputs": { - "nix": "nix", - "nixpkgs": [ - "hydra", - "nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1646878427, - "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=", - "owner": "NixOS", - "repo": "hydra", - "rev": "28b682b85b7efc5cf7974065792a1f22203a5927", - "type": "github" - }, - "original": { - "id": "hydra", - "type": "indirect" - } - }, - "lowdown-src": { - "flake": false, - "locked": { - "lastModified": 1633514407, - "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", - "owner": "kristapsdz", - "repo": "lowdown", - "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", - "type": "github" - }, - "original": { - "owner": "kristapsdz", - "repo": "lowdown", - "type": "github" - } - }, - "nix": { - "inputs": { - "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs", - "nixpkgs-regression": "nixpkgs-regression" - }, - "locked": { - "lastModified": 1643066034, - "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=", - "owner": "NixOS", - "repo": "nix", - "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "2.6.0", - "repo": "nix", - "type": "github" - } - }, "nix-tools": { "flake": false, "locked": { @@ -222,21 +163,6 @@ "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 1632864508, - "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-21.05-small", - "type": "indirect" - } - }, "nixpkgs-2003": { "locked": { "lastModified": 1620055814, @@ -285,21 +211,6 @@ "type": "github" } }, - "nixpkgs-regression": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "indirect" - } - }, "nixpkgs-unstable": { "locked": { "lastModified": 1644486793, @@ -344,7 +255,6 @@ "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hpc-coveralls": "hpc-coveralls", - "hydra": "hydra", "nix-tools": "nix-tools", "nixpkgs": [ "nixpkgs-unstable" diff --git a/flake.nix b/flake.nix index 9165746764..1a368b96a5 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,6 @@ nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; }; nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; - hydra.url = "hydra"; hackage = { url = "github:input-output-hk/hackage.nix"; flake = false; diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 2a4b670e37..5461486712 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -103,13 +103,15 @@ let ghc = ghc'; subDir' = src.origSubDir or ""; subDir = pkgs.lib.strings.removePrefix "/" subDir'; - - cleanedSource = haskellLib.cleanSourceWith { - name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; - src = src.origSrc or src; - filter = path: type: (!(src ? filter) || src.filter path type) && ( - type == "directory" || - pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }; + maybeCleanedSource = + if haskellLib.canCleanSource src + then (haskellLib.cleanSourceWith { + name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; + src = src.origSrc or src; + filter = path: type: (!(src ? filter) || src.filter path type) && ( + type == "directory" || + pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }) + else src.origSrc or src; # Using origSrcSubDir bypasses any cleanSourceWith so that it will work when # access to the store is restricted. If origSrc was already in the store @@ -471,17 +473,17 @@ let } '' tmp=$(mktemp -d) cd $tmp - # if cleanedSource is empty, this means it's a new + # if maybeCleanedSource is empty, this means it's a new # project where the files haven't been added to the git # repo yet. We fail early and provide a useful error # message to prevent headaches (#290). - if [ -z "$(ls -A ${cleanedSource})" ]; then + if [ -z "$(ls -A ${maybeCleanedSource})" ]; then echo "cleaned source is empty. Did you forget to 'git add -A'?" ${pkgs.lib.optionalString (__length fixedProject.sourceRepos == 0) '' exit 1 ''} else - cp -r ${cleanedSource}/* . + cp -r ${maybeCleanedSource}/* . fi chmod +w -R . # Decide what to do for each `package.yaml` file. diff --git a/overlays/default.nix b/overlays/default.nix index 92157724b3..6a37002324 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -10,7 +10,6 @@ let bootstrap = import ./bootstrap.nix; ghc = import ./ghc.nix; ghc-packages = import ./ghc-packages.nix; - hydra = import ./hydra.nix args; darwin = import ./darwin.nix; windows = import ./windows.nix; armv6l-linux = import ./armv6l-linux.nix; @@ -57,7 +56,6 @@ let gobject-introspection hix eval-packages - hydra # Restore nixpkgs haskell and haskellPackages (_: prev: { inherit (prev.haskell-nix-prev) haskell haskellPackages; }) ]; diff --git a/overlays/hydra.nix b/overlays/hydra.nix deleted file mode 100644 index 7ba918fd91..0000000000 --- a/overlays/hydra.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ sources, ...}: - -final: prev: { - hydra-unstable = sources.hydra.defaultPackage.${prev.system}; -} diff --git a/scripts/check-hydra.nix b/scripts/check-hydra.nix index 110c83cb82..4a56058aae 100644 --- a/scripts/check-hydra.nix +++ b/scripts/check-hydra.nix @@ -8,7 +8,6 @@ writeScript "check-hydra.sh" '' set -euo pipefail export PATH="${makeBinPath [ coreutils time gnutar gzip hydra-unstable jq gitMinimal ]}" - export NIX_PATH= echo '~~~ Evaluating release.nix with --arg ifdLevel '$1 command time --format '%e' -o eval-time.txt \ @@ -16,7 +15,7 @@ writeScript "check-hydra.sh" '' --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \ --arg supportedSystems '[ builtins.currentSystem ]' \ --arg ifdLevel $1 \ - -I $(realpath .) release.nix > eval.json + -I . release.nix > eval.json EVAL_EXIT_CODE="$?" if [ "$EVAL_EXIT_CODE" != 0 ] then From 29dbaa7fe31d0965b0d0e656bc573dab1989ba2f Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Fri, 25 Mar 2022 18:10:37 +0000 Subject: [PATCH 09/22] Revert "Revert "always clean the source, no matter what (#1403)"" This reverts commit 3cb7ca738a40dcafc280930803c03565c565331b. --- flake.lock | 90 +++++++++++++++++++++++++++++++ flake.nix | 1 + lib/call-cabal-project-to-nix.nix | 22 ++++---- overlays/default.nix | 2 + overlays/hydra.nix | 5 ++ scripts/check-hydra.nix | 3 +- 6 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 overlays/hydra.nix diff --git a/flake.lock b/flake.lock index 7f0b967f1c..9be43f7fe1 100644 --- a/flake.lock +++ b/flake.lock @@ -147,6 +147,65 @@ "type": "github" } }, + "hydra": { + "inputs": { + "nix": "nix", + "nixpkgs": [ + "hydra", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1646878427, + "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=", + "owner": "NixOS", + "repo": "hydra", + "rev": "28b682b85b7efc5cf7974065792a1f22203a5927", + "type": "github" + }, + "original": { + "id": "hydra", + "type": "indirect" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs", + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1643066034, + "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=", + "owner": "NixOS", + "repo": "nix", + "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "2.6.0", + "repo": "nix", + "type": "github" + } + }, "nix-tools": { "flake": false, "locked": { @@ -163,6 +222,21 @@ "type": "github" } }, + "nixpkgs": { + "locked": { + "lastModified": 1632864508, + "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.05-small", + "type": "indirect" + } + }, "nixpkgs-2003": { "locked": { "lastModified": 1620055814, @@ -211,6 +285,21 @@ "type": "github" } }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "indirect" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1644486793, @@ -255,6 +344,7 @@ "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hpc-coveralls": "hpc-coveralls", + "hydra": "hydra", "nix-tools": "nix-tools", "nixpkgs": [ "nixpkgs-unstable" diff --git a/flake.nix b/flake.nix index 1a368b96a5..9165746764 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,7 @@ nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; }; nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; + hydra.url = "hydra"; hackage = { url = "github:input-output-hk/hackage.nix"; flake = false; diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 5461486712..2a4b670e37 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -103,15 +103,13 @@ let ghc = ghc'; subDir' = src.origSubDir or ""; subDir = pkgs.lib.strings.removePrefix "/" subDir'; - maybeCleanedSource = - if haskellLib.canCleanSource src - then (haskellLib.cleanSourceWith { - name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; - src = src.origSrc or src; - filter = path: type: (!(src ? filter) || src.filter path type) && ( - type == "directory" || - pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }) - else src.origSrc or src; + + cleanedSource = haskellLib.cleanSourceWith { + name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; + src = src.origSrc or src; + filter = path: type: (!(src ? filter) || src.filter path type) && ( + type == "directory" || + pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }; # Using origSrcSubDir bypasses any cleanSourceWith so that it will work when # access to the store is restricted. If origSrc was already in the store @@ -473,17 +471,17 @@ let } '' tmp=$(mktemp -d) cd $tmp - # if maybeCleanedSource is empty, this means it's a new + # if cleanedSource is empty, this means it's a new # project where the files haven't been added to the git # repo yet. We fail early and provide a useful error # message to prevent headaches (#290). - if [ -z "$(ls -A ${maybeCleanedSource})" ]; then + if [ -z "$(ls -A ${cleanedSource})" ]; then echo "cleaned source is empty. Did you forget to 'git add -A'?" ${pkgs.lib.optionalString (__length fixedProject.sourceRepos == 0) '' exit 1 ''} else - cp -r ${maybeCleanedSource}/* . + cp -r ${cleanedSource}/* . fi chmod +w -R . # Decide what to do for each `package.yaml` file. diff --git a/overlays/default.nix b/overlays/default.nix index 6a37002324..92157724b3 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -10,6 +10,7 @@ let bootstrap = import ./bootstrap.nix; ghc = import ./ghc.nix; ghc-packages = import ./ghc-packages.nix; + hydra = import ./hydra.nix args; darwin = import ./darwin.nix; windows = import ./windows.nix; armv6l-linux = import ./armv6l-linux.nix; @@ -56,6 +57,7 @@ let gobject-introspection hix eval-packages + hydra # Restore nixpkgs haskell and haskellPackages (_: prev: { inherit (prev.haskell-nix-prev) haskell haskellPackages; }) ]; diff --git a/overlays/hydra.nix b/overlays/hydra.nix new file mode 100644 index 0000000000..7ba918fd91 --- /dev/null +++ b/overlays/hydra.nix @@ -0,0 +1,5 @@ +{ sources, ...}: + +final: prev: { + hydra-unstable = sources.hydra.defaultPackage.${prev.system}; +} diff --git a/scripts/check-hydra.nix b/scripts/check-hydra.nix index 4a56058aae..110c83cb82 100644 --- a/scripts/check-hydra.nix +++ b/scripts/check-hydra.nix @@ -8,6 +8,7 @@ writeScript "check-hydra.sh" '' set -euo pipefail export PATH="${makeBinPath [ coreutils time gnutar gzip hydra-unstable jq gitMinimal ]}" + export NIX_PATH= echo '~~~ Evaluating release.nix with --arg ifdLevel '$1 command time --format '%e' -o eval-time.txt \ @@ -15,7 +16,7 @@ writeScript "check-hydra.sh" '' --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \ --arg supportedSystems '[ builtins.currentSystem ]' \ --arg ifdLevel $1 \ - -I . release.nix > eval.json + -I $(realpath .) release.nix > eval.json EVAL_EXIT_CODE="$?" if [ "$EVAL_EXIT_CODE" != 0 ] then From 866e82bf2f0e2afad85f364f47c97b469697f5cc Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Fri, 25 Mar 2022 18:16:54 +0000 Subject: [PATCH 10/22] Revert "Remove `canCleanSource` (#1409)" This reverts commit a385241331a3b627da214a458372aa2bb339ccc8. --- build.nix | 6 +----- lib/call-stack-to-nix.nix | 21 ++++++++++++--------- lib/clean-cabal-component.nix | 4 ++-- lib/clean-source-with.nix | 12 ++++++++---- lib/default.nix | 27 ++++++++++++++++++++++----- lib/import-and-filter-project.nix | 13 ++++++++----- lib/stack-cache-generator.nix | 31 +++++++++++++++++-------------- overlays/hydra.nix | 4 ---- 8 files changed, 70 insertions(+), 48 deletions(-) diff --git a/build.nix b/build.nix index 5b035d567b..aefabb6ad3 100644 --- a/build.nix +++ b/build.nix @@ -68,11 +68,7 @@ in rec { ]; }; check-materialization-concurrency = pkgs.buildPackages.callPackage ./scripts/check-materialization-concurrency/check.nix {}; - check-path-support = pkgs.buildPackages.callPackage ./scripts/check-path-support.nix { - # TODO remove this when nixpkgs-2205 is released and used for `pkgs` - # check-path-support fails unless we have nix 2.4 or newer. - inherit (import haskellNix.sources.nixpkgs-unstable {}) nix; - }; + check-path-support = pkgs.buildPackages.callPackage ./scripts/check-path-support.nix {}; }; # These are pure parts of maintainer-script so they can be built by hydra diff --git a/lib/call-stack-to-nix.nix b/lib/call-stack-to-nix.nix index c193c28b80..d755d8c9c7 100644 --- a/lib/call-stack-to-nix.nix +++ b/lib/call-stack-to-nix.nix @@ -24,12 +24,15 @@ let subDir' = src.origSubDir or ""; subDir = pkgs.lib.strings.removePrefix "/" subDir'; - cleanedSource = (haskellLib.cleanSourceWith { - name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; - src = src.origSrc or src; - filter = path: type: (!(src ? filter) || src.filter path type) && ( - type == "directory" || - pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ stackYaml ".cabal" "package.yaml" ]); }); + maybeCleanedSource = + if haskellLib.canCleanSource src + then (haskellLib.cleanSourceWith { + name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; + src = src.origSrc or src; + filter = path: type: (!(src ? filter) || src.filter path type) && ( + type == "directory" || + pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ stackYaml ".cabal" "package.yaml" ]); }) + else src.origSrc or src; stackToNixArgs = builtins.concatStringsSep " " [ "--full" @@ -56,14 +59,14 @@ let mkdir -p $out${subDir'} SRC=$(mktemp -d) cd $SRC - # if cleanedSource is empty, this means it's a new + # if maybeCleanedSource is empty, this means it's a new # project where the files haven't been added to the git # repo yet. We fail early and provide a useful error # message to prevent headaches (#290). - if [ -z "$(ls -A ${cleanedSource})" ]; then + if [ -z "$(ls -A ${maybeCleanedSource})" ]; then echo "cleaned source is empty. Did you forget to 'git add -A'?"; exit 1; fi - lndir -silent "${cleanedSource}/." $SRC + lndir -silent "${maybeCleanedSource}/." $SRC ${pkgs.lib.optionalString (subDir != "") "cd ${subDir}"} ${ # If a resolver was fetched use the it instead of the original stack.yaml diff --git a/lib/clean-cabal-component.nix b/lib/clean-cabal-component.nix index d905a9d6fe..8d7c9303c8 100644 --- a/lib/clean-cabal-component.nix +++ b/lib/clean-cabal-component.nix @@ -1,6 +1,6 @@ # Use cleanSourceWith to filter just the files needed for a particular # component of the package -{ lib, cleanSourceWith }: package: component: componentName: src: +{ lib, cleanSourceWith, canCleanSource }: package: component: componentName: src: let srcStr' = src.origSrc or null; subDir = if src.origSubDir or "" == "" @@ -56,7 +56,7 @@ let then p else p + "/"; in - if srcStr' == null || package.detailLevel != "FullDetails" + if srcStr' == null || package.detailLevel != "FullDetails" || !canCleanSource src then src else let diff --git a/lib/clean-source-with.nix b/lib/clean-source-with.nix index f6cd946849..5f1a825646 100644 --- a/lib/clean-source-with.nix +++ b/lib/clean-source-with.nix @@ -2,10 +2,7 @@ # https://github.com/NixOS/nixpkgs/blob/1d9d31a0eb8e8358830528538a391df52f6a075a/lib/sources.nix#L41 # It adds a subDir argument in a way that allows descending into a subdirectory # to compose with cleaning the source with a filter. -{ lib }: -if lib.versionOlder builtins.nixVersion "2.4" -then throw "Nix version 2.4 or higher is required for Haskell.nix" -else rec { +{ lib }: rec { # Like `builtins.filterSource`, except it will compose with itself, # allowing you to chain multiple calls together without any @@ -116,4 +113,11 @@ else rec { _isLibCleanSourceWith = origSubDir == ""; name = name'; }; + + pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir); + + canCleanSource = src: + src ? _isLibCleanSourceWithEx + || src ? _isLibCleanSourceWith + || !(pathHasContext (toString src)); } diff --git a/lib/default.nix b/lib/default.nix index 83c07385cd..42073595f4 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -192,11 +192,11 @@ in { collectChecks' = collectChecks (_: true); # Replacement for lib.cleanSourceWith that has a subDir argument. - inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith; + inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource; # Use cleanSourceWith to filter just the files needed for a particular # component of a package - cleanCabalComponent = import ./clean-cabal-component.nix { inherit lib cleanSourceWith; }; + cleanCabalComponent = import ./clean-cabal-component.nix { inherit lib cleanSourceWith canCleanSource; }; # Clean git directory based on `git ls-files --recurse-submodules` cleanGit = import ./clean-git.nix { @@ -290,9 +290,26 @@ in { if subDir == "" then src else - haskellLib.cleanSourceWith { - inherit src subDir includeSiblings; - }; + if haskellLib.canCleanSource src + then haskellLib.cleanSourceWith { + inherit src subDir includeSiblings; + } + else let name = src.name or "source" + "-" + __replaceStrings ["/"] ["-"] subDir; + in if includeSiblings + then rec { + # Keep `src.origSrc` so it can be used to allow references + # to other parts of that root. + inherit name; + origSrc = src.origSrc or src; + origSubDir = src.origSubDir or "" + "/" + subDir; + outPath = origSrc + origSubDir; + } + else { + # We are not going to need other parts of `origSrc` if there + # was one and we can ignore it + inherit name; + outPath = src + "/" + subDir; + }; # Givin a `src` split it into a `root` path (based on `src.origSrc` if # present) and `subDir` (based on `src.origSubDir). The diff --git a/lib/import-and-filter-project.nix b/lib/import-and-filter-project.nix index 280e0bae4e..956ae372f6 100644 --- a/lib/import-and-filter-project.nix +++ b/lib/import-and-filter-project.nix @@ -6,11 +6,14 @@ let # Full source including possible relative paths form the # project directory. - srcRoot = haskellLib.cleanSourceWith { - name = if src ? name then "${src.name}-root" else "source-root"; - src = src.origSrc or src; - filter = src.filter or (_: _: true); - }; + srcRoot = + if haskellLib.canCleanSource src + then haskellLib.cleanSourceWith { + name = if src ? name then "${src.name}-root" else "source-root"; + src = src.origSrc or src; + filter = src.filter or (_: _: true); + } + else src.origSrc or src; # The sub directory containing the cabal.project or stack.yaml file projectSubDir' = src.origSubDir or ""; # With leading / projectSubDir = pkgs.lib.strings.removePrefix "/" projectSubDir'; # Without / diff --git a/lib/stack-cache-generator.nix b/lib/stack-cache-generator.nix index 4b07305933..6240d22115 100644 --- a/lib/stack-cache-generator.nix +++ b/lib/stack-cache-generator.nix @@ -30,22 +30,25 @@ let }) resolver fetchedResolver; # Filter just the stack yaml file and any resolver yaml file it points to. - maybeCleanedSource = haskellLib.cleanSourceWith { - inherit src; - filter = path: type: - let - origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src; - origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else ""; - relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path; + maybeCleanedSource = + if haskellLib.canCleanSource src + then haskellLib.cleanSourceWith { + inherit src; + filter = path: type: + let + origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src; + origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else ""; + relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path; - # checks if path1 is a parent directory for path2 - isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2; + # checks if path1 is a parent directory for path2 + isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2; - in - (relPath == stackYaml) - || (resolver != null && (relPath == resolver || isParent relPath resolver)) - ; - }; + in + (relPath == stackYaml) + || (resolver != null && (relPath == resolver || isParent relPath resolver)) + ; + } + else src; # All repos served via ssh or git protocols are usually private private = url: pkgs.lib.substring 0 4 url != "http"; diff --git a/overlays/hydra.nix b/overlays/hydra.nix index 4fd22044c3..7ba918fd91 100644 --- a/overlays/hydra.nix +++ b/overlays/hydra.nix @@ -1,8 +1,4 @@ { sources, ...}: -# This hydra overlay is required to circumvent problems with builtins.path -# in restricted eval mode. -# This can be removed once hydra in nixpkgs is based on a recent enough nix, -# which contains this fix: https://github.com/NixOS/nix/pull/5163 final: prev: { hydra-unstable = sources.hydra.defaultPackage.${prev.system}; From 8d836b0002083172b3282899178686b488d12dac Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Fri, 25 Mar 2022 18:17:08 +0000 Subject: [PATCH 11/22] Revert "always clean the source, no matter what (#1403)" This reverts commit 1ca99326b2e71d8e52bb64f7a7831011abec2f09. --- flake.lock | 90 ------------------------------- flake.nix | 1 - lib/call-cabal-project-to-nix.nix | 22 ++++---- overlays/default.nix | 2 - overlays/hydra.nix | 5 -- scripts/check-hydra.nix | 3 +- 6 files changed, 13 insertions(+), 110 deletions(-) delete mode 100644 overlays/hydra.nix diff --git a/flake.lock b/flake.lock index 8323c2afa7..7872616c0a 100644 --- a/flake.lock +++ b/flake.lock @@ -147,65 +147,6 @@ "type": "github" } }, - "hydra": { - "inputs": { - "nix": "nix", - "nixpkgs": [ - "hydra", - "nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1646878427, - "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=", - "owner": "NixOS", - "repo": "hydra", - "rev": "28b682b85b7efc5cf7974065792a1f22203a5927", - "type": "github" - }, - "original": { - "id": "hydra", - "type": "indirect" - } - }, - "lowdown-src": { - "flake": false, - "locked": { - "lastModified": 1633514407, - "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", - "owner": "kristapsdz", - "repo": "lowdown", - "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", - "type": "github" - }, - "original": { - "owner": "kristapsdz", - "repo": "lowdown", - "type": "github" - } - }, - "nix": { - "inputs": { - "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs", - "nixpkgs-regression": "nixpkgs-regression" - }, - "locked": { - "lastModified": 1643066034, - "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=", - "owner": "NixOS", - "repo": "nix", - "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "2.6.0", - "repo": "nix", - "type": "github" - } - }, "nix-tools": { "flake": false, "locked": { @@ -222,21 +163,6 @@ "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 1632864508, - "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-21.05-small", - "type": "indirect" - } - }, "nixpkgs-2003": { "locked": { "lastModified": 1620055814, @@ -285,21 +211,6 @@ "type": "github" } }, - "nixpkgs-regression": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "indirect" - } - }, "nixpkgs-unstable": { "locked": { "lastModified": 1644486793, @@ -344,7 +255,6 @@ "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hpc-coveralls": "hpc-coveralls", - "hydra": "hydra", "nix-tools": "nix-tools", "nixpkgs": [ "nixpkgs-unstable" diff --git a/flake.nix b/flake.nix index 9165746764..1a368b96a5 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,6 @@ nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; }; nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; - hydra.url = "hydra"; hackage = { url = "github:input-output-hk/hackage.nix"; flake = false; diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 2a4b670e37..5461486712 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -103,13 +103,15 @@ let ghc = ghc'; subDir' = src.origSubDir or ""; subDir = pkgs.lib.strings.removePrefix "/" subDir'; - - cleanedSource = haskellLib.cleanSourceWith { - name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; - src = src.origSrc or src; - filter = path: type: (!(src ? filter) || src.filter path type) && ( - type == "directory" || - pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }; + maybeCleanedSource = + if haskellLib.canCleanSource src + then (haskellLib.cleanSourceWith { + name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; + src = src.origSrc or src; + filter = path: type: (!(src ? filter) || src.filter path type) && ( + type == "directory" || + pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }) + else src.origSrc or src; # Using origSrcSubDir bypasses any cleanSourceWith so that it will work when # access to the store is restricted. If origSrc was already in the store @@ -471,17 +473,17 @@ let } '' tmp=$(mktemp -d) cd $tmp - # if cleanedSource is empty, this means it's a new + # if maybeCleanedSource is empty, this means it's a new # project where the files haven't been added to the git # repo yet. We fail early and provide a useful error # message to prevent headaches (#290). - if [ -z "$(ls -A ${cleanedSource})" ]; then + if [ -z "$(ls -A ${maybeCleanedSource})" ]; then echo "cleaned source is empty. Did you forget to 'git add -A'?" ${pkgs.lib.optionalString (__length fixedProject.sourceRepos == 0) '' exit 1 ''} else - cp -r ${cleanedSource}/* . + cp -r ${maybeCleanedSource}/* . fi chmod +w -R . # Decide what to do for each `package.yaml` file. diff --git a/overlays/default.nix b/overlays/default.nix index 92157724b3..6a37002324 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -10,7 +10,6 @@ let bootstrap = import ./bootstrap.nix; ghc = import ./ghc.nix; ghc-packages = import ./ghc-packages.nix; - hydra = import ./hydra.nix args; darwin = import ./darwin.nix; windows = import ./windows.nix; armv6l-linux = import ./armv6l-linux.nix; @@ -57,7 +56,6 @@ let gobject-introspection hix eval-packages - hydra # Restore nixpkgs haskell and haskellPackages (_: prev: { inherit (prev.haskell-nix-prev) haskell haskellPackages; }) ]; diff --git a/overlays/hydra.nix b/overlays/hydra.nix deleted file mode 100644 index 7ba918fd91..0000000000 --- a/overlays/hydra.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ sources, ...}: - -final: prev: { - hydra-unstable = sources.hydra.defaultPackage.${prev.system}; -} diff --git a/scripts/check-hydra.nix b/scripts/check-hydra.nix index 110c83cb82..4a56058aae 100644 --- a/scripts/check-hydra.nix +++ b/scripts/check-hydra.nix @@ -8,7 +8,6 @@ writeScript "check-hydra.sh" '' set -euo pipefail export PATH="${makeBinPath [ coreutils time gnutar gzip hydra-unstable jq gitMinimal ]}" - export NIX_PATH= echo '~~~ Evaluating release.nix with --arg ifdLevel '$1 command time --format '%e' -o eval-time.txt \ @@ -16,7 +15,7 @@ writeScript "check-hydra.sh" '' --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \ --arg supportedSystems '[ builtins.currentSystem ]' \ --arg ifdLevel $1 \ - -I $(realpath .) release.nix > eval.json + -I . release.nix > eval.json EVAL_EXIT_CODE="$?" if [ "$EVAL_EXIT_CODE" != 0 ] then From 855849c18cab25c144e5f9708678e188cc5c2a38 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Tue, 29 Mar 2022 08:50:02 +0100 Subject: [PATCH 12/22] Revert "Revert "always clean the source, no matter what (#1403)"" This reverts commit 8d836b0002083172b3282899178686b488d12dac. --- flake.lock | 90 +++++++++++++++++++++++++++++++ flake.nix | 1 + lib/call-cabal-project-to-nix.nix | 22 ++++---- overlays/default.nix | 2 + overlays/hydra.nix | 5 ++ scripts/check-hydra.nix | 3 +- 6 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 overlays/hydra.nix diff --git a/flake.lock b/flake.lock index 7872616c0a..8323c2afa7 100644 --- a/flake.lock +++ b/flake.lock @@ -147,6 +147,65 @@ "type": "github" } }, + "hydra": { + "inputs": { + "nix": "nix", + "nixpkgs": [ + "hydra", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1646878427, + "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=", + "owner": "NixOS", + "repo": "hydra", + "rev": "28b682b85b7efc5cf7974065792a1f22203a5927", + "type": "github" + }, + "original": { + "id": "hydra", + "type": "indirect" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs", + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1643066034, + "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=", + "owner": "NixOS", + "repo": "nix", + "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "2.6.0", + "repo": "nix", + "type": "github" + } + }, "nix-tools": { "flake": false, "locked": { @@ -163,6 +222,21 @@ "type": "github" } }, + "nixpkgs": { + "locked": { + "lastModified": 1632864508, + "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.05-small", + "type": "indirect" + } + }, "nixpkgs-2003": { "locked": { "lastModified": 1620055814, @@ -211,6 +285,21 @@ "type": "github" } }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "indirect" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1644486793, @@ -255,6 +344,7 @@ "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hpc-coveralls": "hpc-coveralls", + "hydra": "hydra", "nix-tools": "nix-tools", "nixpkgs": [ "nixpkgs-unstable" diff --git a/flake.nix b/flake.nix index 1a368b96a5..9165746764 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,7 @@ nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; }; nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; + hydra.url = "hydra"; hackage = { url = "github:input-output-hk/hackage.nix"; flake = false; diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 5461486712..2a4b670e37 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -103,15 +103,13 @@ let ghc = ghc'; subDir' = src.origSubDir or ""; subDir = pkgs.lib.strings.removePrefix "/" subDir'; - maybeCleanedSource = - if haskellLib.canCleanSource src - then (haskellLib.cleanSourceWith { - name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; - src = src.origSrc or src; - filter = path: type: (!(src ? filter) || src.filter path type) && ( - type == "directory" || - pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }) - else src.origSrc or src; + + cleanedSource = haskellLib.cleanSourceWith { + name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; + src = src.origSrc or src; + filter = path: type: (!(src ? filter) || src.filter path type) && ( + type == "directory" || + pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); }; # Using origSrcSubDir bypasses any cleanSourceWith so that it will work when # access to the store is restricted. If origSrc was already in the store @@ -473,17 +471,17 @@ let } '' tmp=$(mktemp -d) cd $tmp - # if maybeCleanedSource is empty, this means it's a new + # if cleanedSource is empty, this means it's a new # project where the files haven't been added to the git # repo yet. We fail early and provide a useful error # message to prevent headaches (#290). - if [ -z "$(ls -A ${maybeCleanedSource})" ]; then + if [ -z "$(ls -A ${cleanedSource})" ]; then echo "cleaned source is empty. Did you forget to 'git add -A'?" ${pkgs.lib.optionalString (__length fixedProject.sourceRepos == 0) '' exit 1 ''} else - cp -r ${maybeCleanedSource}/* . + cp -r ${cleanedSource}/* . fi chmod +w -R . # Decide what to do for each `package.yaml` file. diff --git a/overlays/default.nix b/overlays/default.nix index 6a37002324..92157724b3 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -10,6 +10,7 @@ let bootstrap = import ./bootstrap.nix; ghc = import ./ghc.nix; ghc-packages = import ./ghc-packages.nix; + hydra = import ./hydra.nix args; darwin = import ./darwin.nix; windows = import ./windows.nix; armv6l-linux = import ./armv6l-linux.nix; @@ -56,6 +57,7 @@ let gobject-introspection hix eval-packages + hydra # Restore nixpkgs haskell and haskellPackages (_: prev: { inherit (prev.haskell-nix-prev) haskell haskellPackages; }) ]; diff --git a/overlays/hydra.nix b/overlays/hydra.nix new file mode 100644 index 0000000000..7ba918fd91 --- /dev/null +++ b/overlays/hydra.nix @@ -0,0 +1,5 @@ +{ sources, ...}: + +final: prev: { + hydra-unstable = sources.hydra.defaultPackage.${prev.system}; +} diff --git a/scripts/check-hydra.nix b/scripts/check-hydra.nix index 4a56058aae..110c83cb82 100644 --- a/scripts/check-hydra.nix +++ b/scripts/check-hydra.nix @@ -8,6 +8,7 @@ writeScript "check-hydra.sh" '' set -euo pipefail export PATH="${makeBinPath [ coreutils time gnutar gzip hydra-unstable jq gitMinimal ]}" + export NIX_PATH= echo '~~~ Evaluating release.nix with --arg ifdLevel '$1 command time --format '%e' -o eval-time.txt \ @@ -15,7 +16,7 @@ writeScript "check-hydra.sh" '' --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \ --arg supportedSystems '[ builtins.currentSystem ]' \ --arg ifdLevel $1 \ - -I . release.nix > eval.json + -I $(realpath .) release.nix > eval.json EVAL_EXIT_CODE="$?" if [ "$EVAL_EXIT_CODE" != 0 ] then From 5aba1240bd7906a1284038e31549f3759a23f33f Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Tue, 29 Mar 2022 08:50:09 +0100 Subject: [PATCH 13/22] Revert "Revert "Remove `canCleanSource` (#1409)"" This reverts commit 866e82bf2f0e2afad85f364f47c97b469697f5cc. --- build.nix | 6 +++++- lib/call-stack-to-nix.nix | 21 +++++++++------------ lib/clean-cabal-component.nix | 4 ++-- lib/clean-source-with.nix | 12 ++++-------- lib/default.nix | 27 +++++---------------------- lib/import-and-filter-project.nix | 13 +++++-------- lib/stack-cache-generator.nix | 31 ++++++++++++++----------------- overlays/hydra.nix | 4 ++++ 8 files changed, 48 insertions(+), 70 deletions(-) diff --git a/build.nix b/build.nix index aefabb6ad3..5b035d567b 100644 --- a/build.nix +++ b/build.nix @@ -68,7 +68,11 @@ in rec { ]; }; check-materialization-concurrency = pkgs.buildPackages.callPackage ./scripts/check-materialization-concurrency/check.nix {}; - check-path-support = pkgs.buildPackages.callPackage ./scripts/check-path-support.nix {}; + check-path-support = pkgs.buildPackages.callPackage ./scripts/check-path-support.nix { + # TODO remove this when nixpkgs-2205 is released and used for `pkgs` + # check-path-support fails unless we have nix 2.4 or newer. + inherit (import haskellNix.sources.nixpkgs-unstable {}) nix; + }; }; # These are pure parts of maintainer-script so they can be built by hydra diff --git a/lib/call-stack-to-nix.nix b/lib/call-stack-to-nix.nix index d755d8c9c7..c193c28b80 100644 --- a/lib/call-stack-to-nix.nix +++ b/lib/call-stack-to-nix.nix @@ -24,15 +24,12 @@ let subDir' = src.origSubDir or ""; subDir = pkgs.lib.strings.removePrefix "/" subDir'; - maybeCleanedSource = - if haskellLib.canCleanSource src - then (haskellLib.cleanSourceWith { - name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; - src = src.origSrc or src; - filter = path: type: (!(src ? filter) || src.filter path type) && ( - type == "directory" || - pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ stackYaml ".cabal" "package.yaml" ]); }) - else src.origSrc or src; + cleanedSource = (haskellLib.cleanSourceWith { + name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files"; + src = src.origSrc or src; + filter = path: type: (!(src ? filter) || src.filter path type) && ( + type == "directory" || + pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ stackYaml ".cabal" "package.yaml" ]); }); stackToNixArgs = builtins.concatStringsSep " " [ "--full" @@ -59,14 +56,14 @@ let mkdir -p $out${subDir'} SRC=$(mktemp -d) cd $SRC - # if maybeCleanedSource is empty, this means it's a new + # if cleanedSource is empty, this means it's a new # project where the files haven't been added to the git # repo yet. We fail early and provide a useful error # message to prevent headaches (#290). - if [ -z "$(ls -A ${maybeCleanedSource})" ]; then + if [ -z "$(ls -A ${cleanedSource})" ]; then echo "cleaned source is empty. Did you forget to 'git add -A'?"; exit 1; fi - lndir -silent "${maybeCleanedSource}/." $SRC + lndir -silent "${cleanedSource}/." $SRC ${pkgs.lib.optionalString (subDir != "") "cd ${subDir}"} ${ # If a resolver was fetched use the it instead of the original stack.yaml diff --git a/lib/clean-cabal-component.nix b/lib/clean-cabal-component.nix index 8d7c9303c8..d905a9d6fe 100644 --- a/lib/clean-cabal-component.nix +++ b/lib/clean-cabal-component.nix @@ -1,6 +1,6 @@ # Use cleanSourceWith to filter just the files needed for a particular # component of the package -{ lib, cleanSourceWith, canCleanSource }: package: component: componentName: src: +{ lib, cleanSourceWith }: package: component: componentName: src: let srcStr' = src.origSrc or null; subDir = if src.origSubDir or "" == "" @@ -56,7 +56,7 @@ let then p else p + "/"; in - if srcStr' == null || package.detailLevel != "FullDetails" || !canCleanSource src + if srcStr' == null || package.detailLevel != "FullDetails" then src else let diff --git a/lib/clean-source-with.nix b/lib/clean-source-with.nix index 5f1a825646..f6cd946849 100644 --- a/lib/clean-source-with.nix +++ b/lib/clean-source-with.nix @@ -2,7 +2,10 @@ # https://github.com/NixOS/nixpkgs/blob/1d9d31a0eb8e8358830528538a391df52f6a075a/lib/sources.nix#L41 # It adds a subDir argument in a way that allows descending into a subdirectory # to compose with cleaning the source with a filter. -{ lib }: rec { +{ lib }: +if lib.versionOlder builtins.nixVersion "2.4" +then throw "Nix version 2.4 or higher is required for Haskell.nix" +else rec { # Like `builtins.filterSource`, except it will compose with itself, # allowing you to chain multiple calls together without any @@ -113,11 +116,4 @@ _isLibCleanSourceWith = origSubDir == ""; name = name'; }; - - pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir); - - canCleanSource = src: - src ? _isLibCleanSourceWithEx - || src ? _isLibCleanSourceWith - || !(pathHasContext (toString src)); } diff --git a/lib/default.nix b/lib/default.nix index 42073595f4..83c07385cd 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -192,11 +192,11 @@ in { collectChecks' = collectChecks (_: true); # Replacement for lib.cleanSourceWith that has a subDir argument. - inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource; + inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith; # Use cleanSourceWith to filter just the files needed for a particular # component of a package - cleanCabalComponent = import ./clean-cabal-component.nix { inherit lib cleanSourceWith canCleanSource; }; + cleanCabalComponent = import ./clean-cabal-component.nix { inherit lib cleanSourceWith; }; # Clean git directory based on `git ls-files --recurse-submodules` cleanGit = import ./clean-git.nix { @@ -290,26 +290,9 @@ in { if subDir == "" then src else - if haskellLib.canCleanSource src - then haskellLib.cleanSourceWith { - inherit src subDir includeSiblings; - } - else let name = src.name or "source" + "-" + __replaceStrings ["/"] ["-"] subDir; - in if includeSiblings - then rec { - # Keep `src.origSrc` so it can be used to allow references - # to other parts of that root. - inherit name; - origSrc = src.origSrc or src; - origSubDir = src.origSubDir or "" + "/" + subDir; - outPath = origSrc + origSubDir; - } - else { - # We are not going to need other parts of `origSrc` if there - # was one and we can ignore it - inherit name; - outPath = src + "/" + subDir; - }; + haskellLib.cleanSourceWith { + inherit src subDir includeSiblings; + }; # Givin a `src` split it into a `root` path (based on `src.origSrc` if # present) and `subDir` (based on `src.origSubDir). The diff --git a/lib/import-and-filter-project.nix b/lib/import-and-filter-project.nix index 956ae372f6..280e0bae4e 100644 --- a/lib/import-and-filter-project.nix +++ b/lib/import-and-filter-project.nix @@ -6,14 +6,11 @@ let # Full source including possible relative paths form the # project directory. - srcRoot = - if haskellLib.canCleanSource src - then haskellLib.cleanSourceWith { - name = if src ? name then "${src.name}-root" else "source-root"; - src = src.origSrc or src; - filter = src.filter or (_: _: true); - } - else src.origSrc or src; + srcRoot = haskellLib.cleanSourceWith { + name = if src ? name then "${src.name}-root" else "source-root"; + src = src.origSrc or src; + filter = src.filter or (_: _: true); + }; # The sub directory containing the cabal.project or stack.yaml file projectSubDir' = src.origSubDir or ""; # With leading / projectSubDir = pkgs.lib.strings.removePrefix "/" projectSubDir'; # Without / diff --git a/lib/stack-cache-generator.nix b/lib/stack-cache-generator.nix index 6240d22115..4b07305933 100644 --- a/lib/stack-cache-generator.nix +++ b/lib/stack-cache-generator.nix @@ -30,25 +30,22 @@ let }) resolver fetchedResolver; # Filter just the stack yaml file and any resolver yaml file it points to. - maybeCleanedSource = - if haskellLib.canCleanSource src - then haskellLib.cleanSourceWith { - inherit src; - filter = path: type: - let - origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src; - origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else ""; - relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path; + maybeCleanedSource = haskellLib.cleanSourceWith { + inherit src; + filter = path: type: + let + origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src; + origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else ""; + relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path; - # checks if path1 is a parent directory for path2 - isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2; + # checks if path1 is a parent directory for path2 + isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2; - in - (relPath == stackYaml) - || (resolver != null && (relPath == resolver || isParent relPath resolver)) - ; - } - else src; + in + (relPath == stackYaml) + || (resolver != null && (relPath == resolver || isParent relPath resolver)) + ; + }; # All repos served via ssh or git protocols are usually private private = url: pkgs.lib.substring 0 4 url != "http"; diff --git a/overlays/hydra.nix b/overlays/hydra.nix index 7ba918fd91..4fd22044c3 100644 --- a/overlays/hydra.nix +++ b/overlays/hydra.nix @@ -1,4 +1,8 @@ { sources, ...}: +# This hydra overlay is required to circumvent problems with builtins.path +# in restricted eval mode. +# This can be removed once hydra in nixpkgs is based on a recent enough nix, +# which contains this fix: https://github.com/NixOS/nix/pull/5163 final: prev: { hydra-unstable = sources.hydra.defaultPackage.${prev.system}; From 439d189c36746432375700f8d12e8a2f164be50c Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Tue, 28 Mar 2023 00:35:45 +1300 Subject: [PATCH 14/22] `index-state` was renamed `index-state-max` This was done as it no longer reflects the `index-state:` in the `cabal.project` it is the `index-state` passed into the project (if there was one) or the latest `hackage.nix` updates `index-state`. Fixes #1904 --- overlays/haskell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlays/haskell.nix b/overlays/haskell.nix index 4bfc509a47..1b99b2abbd 100644 --- a/overlays/haskell.nix +++ b/overlays/haskell.nix @@ -692,7 +692,7 @@ final: prev: { inherit (pkg-set.config) hsPkgs; inherit pkg-set; plan-nix = callProjectResults.projectNix; - inherit (callProjectResults) index-state; + inherit (callProjectResults) index-state-max; tool = final.buildPackages.haskell-nix.tool' evalPackages pkg-set.config.compiler.nix-name; tools = final.buildPackages.haskell-nix.tools' evalPackages pkg-set.config.compiler.nix-name; roots = final.haskell-nix.roots pkg-set.config.compiler.nix-name; From acf4326ce41eb3fda47f8641184297596075d006 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Wed, 3 May 2023 16:06:31 +0100 Subject: [PATCH 15/22] Another shell fix --- builder/ghc-for-component-wrapper.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/ghc-for-component-wrapper.nix b/builder/ghc-for-component-wrapper.nix index db964ad896..3ad518fad6 100644 --- a/builder/ghc-for-component-wrapper.nix +++ b/builder/ghc-for-component-wrapper.nix @@ -154,7 +154,7 @@ let inherit script targetPrefix; inherit (ghc) version meta; }; - propagatedBuildInputs = configFiles.libDeps; + # propagatedBuildInputs = configFiles.libDeps; nativeBuildInputs = [ghc]; } ('' mkdir -p $out/configFiles From 476181f2b50786273e5aecae310866d46e350740 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Wed, 3 May 2023 16:31:48 +0100 Subject: [PATCH 16/22] Try uniqueWithName --- builder/ghc-for-component-wrapper.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builder/ghc-for-component-wrapper.nix b/builder/ghc-for-component-wrapper.nix index 3ad518fad6..dd72b4b8dc 100644 --- a/builder/ghc-for-component-wrapper.nix +++ b/builder/ghc-for-component-wrapper.nix @@ -19,6 +19,11 @@ let ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc; + uniqueWithName = list: + lib.concatMap lib.unique ( + builtins.attrValues ( + builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") list)); + inherit (configFiles) targetPrefix ghcCommand ghcCommandCaps packageCfgDir; libDir = "$wrappedGhc/${configFiles.libDir}"; docDir = "$wrappedGhc/share/doc/ghc/html"; @@ -154,7 +159,7 @@ let inherit script targetPrefix; inherit (ghc) version meta; }; - # propagatedBuildInputs = configFiles.libDeps; + propagatedBuildInputs = uniqueWithName configFiles.libDeps; nativeBuildInputs = [ghc]; } ('' mkdir -p $out/configFiles From b445608b37dceb0b1340d31316b1ad2c5f1c563b Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Tue, 9 May 2023 15:27:02 +0100 Subject: [PATCH 17/22] Revert our custom workaround --- builder/ghc-for-component-wrapper.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/builder/ghc-for-component-wrapper.nix b/builder/ghc-for-component-wrapper.nix index dd72b4b8dc..db964ad896 100644 --- a/builder/ghc-for-component-wrapper.nix +++ b/builder/ghc-for-component-wrapper.nix @@ -19,11 +19,6 @@ let ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc; - uniqueWithName = list: - lib.concatMap lib.unique ( - builtins.attrValues ( - builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") list)); - inherit (configFiles) targetPrefix ghcCommand ghcCommandCaps packageCfgDir; libDir = "$wrappedGhc/${configFiles.libDir}"; docDir = "$wrappedGhc/share/doc/ghc/html"; @@ -159,7 +154,7 @@ let inherit script targetPrefix; inherit (ghc) version meta; }; - propagatedBuildInputs = uniqueWithName configFiles.libDeps; + propagatedBuildInputs = configFiles.libDeps; nativeBuildInputs = [ghc]; } ('' mkdir -p $out/configFiles From 4a3004b84616223952fb9a4026ebefb37ab0f419 Mon Sep 17 00:00:00 2001 From: Teo Camarasu Date: Fri, 31 Jan 2025 15:38:56 +0000 Subject: [PATCH 18/22] Fix hoogle module reference when pkgs.path isn't a Path --- builder/default.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/builder/default.nix b/builder/default.nix index 6a029e8964..fbba42663c 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -59,11 +59,7 @@ let hoogleLocal = let - # Use hoogle.nix from at least nixpkgs 22.05 - nixpkgs = if lib.versionAtLeast lib.trivial.release "22.05" - then pkgs.path - else pkgs.haskell-nix.sources.nixpkgs-2205; - nixpkgsHoogle = import (nixpkgs + /pkgs/development/haskell-modules/hoogle.nix); + nixpkgsHoogle = import "${pkgs.path}/pkgs/development/haskell-modules/hoogle.nix"; in { packages ? [], hoogle }: let haskellPackages = { From 03d8620377d5b3f5d4ab726c09fd8c33f93aafdb Mon Sep 17 00:00:00 2001 From: Teo Camarasu Date: Fri, 7 Feb 2025 11:43:46 +0000 Subject: [PATCH 19/22] disable sibling inclusion --- lib/load-cabal-plan.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/load-cabal-plan.nix b/lib/load-cabal-plan.nix index 5968ed2a48..6bf0b1bffb 100644 --- a/lib/load-cabal-plan.nix +++ b/lib/load-cabal-plan.nix @@ -159,7 +159,9 @@ in { if pkgs.lib.hasPrefix ".${callProjectResults.src.origSubDir or ""}/" (p.pkg-src.path + "/") then pkgs.lib.removePrefix ".${callProjectResults.src.origSubDir or ""}" p.pkg-src.path else throw "Unexpected path ${p.pkg-src.path} expected it to start with .${callProjectResults.src.origSubDir or ""}")))); - includeSiblings = true; # Filtering sibling dirs of the package dir is done in the + includeSiblings = false; # we disable this because it is extremely slow + + # Filtering sibling dirs of the package dir is done in the # component builder so that relative paths can be used to # reference project directories not in the package subDir. }; From b804592901dbfa9d882d53bcd5437f911bb2f7e5 Mon Sep 17 00:00:00 2001 From: Teo Camarasu Date: Wed, 19 Mar 2025 12:17:44 +0000 Subject: [PATCH 20/22] Improve remote store eval time This code used to put the .drv path into the string context for each package. That meant we had to query the store each time one of these was evaluated for the out path. This is pretty quick when using a non-remote store. But the latency with the remote store really slows us down. We should just calculate the outPath once instead, and use that throughout. --- lib/load-cabal-plan.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/load-cabal-plan.nix b/lib/load-cabal-plan.nix index 6bf0b1bffb..840a09779e 100644 --- a/lib/load-cabal-plan.nix +++ b/lib/load-cabal-plan.nix @@ -75,7 +75,9 @@ let buildable = true; } // lookupDependencies hsPkgs.pkgsBuildBuild (components.setup.depends or []) (components.setup.exe-depends or []); }; - nixFilesDir = callProjectResults.projectNix + callProjectResults.src.origSubDir or ""; + # We use unsafeDiscardStringContext to ensure that we don't query this derivation when importing + # each package. The cost can be very high when using a remote store, as we need to do a network call. + nixFilesDir = builtins.unsafeDiscardStringContext callProjectResults.projectNix.outPath + callProjectResults.src.origSubDir or ""; in { # This replaces the `plan-nix/default.nix` pkgs = (hackage: { From 1b8cf840a2c4459d01ca4f9796ec923c05ccf297 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Sun, 15 Jun 2025 16:15:05 +0100 Subject: [PATCH 21/22] Remove libhsakmt --- lib/pkgconf-nixpkgs-map.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgconf-nixpkgs-map.nix b/lib/pkgconf-nixpkgs-map.nix index dd0cd475f9..227884510f 100644 --- a/lib/pkgconf-nixpkgs-map.nix +++ b/lib/pkgconf-nixpkgs-map.nix @@ -5733,7 +5733,7 @@ pkgs: then [ pkgs.gdk_pixbuf ] else []; # rocm-thunk was replaced by rocmPackages.rocm-thunk in 23.11 - "libhsakmt" = [ pkgs.rocmPackages.rocm-thunk or pkgs.rocm-thunk ]; + # "libhsakmt" = [ pkgs.rocmPackages.rocm-thunk or pkgs.rocm-thunk ]; } // lib.optionalAttrs (pkgs ? libsigcxx12) { # libsigcxx12 was removed in 23.11 "sigc++-1.2" = [ "libsigcxx12" ]; From 9a3ae43181123e8100eb98346ad038ae4aafa264 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 22 May 2025 00:11:03 +1200 Subject: [PATCH 22/22] Fix #2365 missing pg_config (#2366) * Fix #2365 missing pg_config The `pg_config` executable was moved into its own derivation in `nixpkgs`. This fix includes that derivation if present when the `pg` library is requested. * Add comment --- lib/system-nixpkgs-map.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/system-nixpkgs-map.nix b/lib/system-nixpkgs-map.nix index af0cdcdddc..232102ea4a 100644 --- a/lib/system-nixpkgs-map.nix +++ b/lib/system-nixpkgs-map.nix @@ -17,6 +17,10 @@ let lndir ${pkgs.buildPackages.gcc.cc} $out '') ] else []; + # In newer versions of nixpkgs `pg_config` has been moved to its own derivation. + # Haskell libs that depend on the `pq` library (like `postgresql-libpq`) + # are likely to require `pg_config` to be in the `PATH` as well. + postgresqlLibs = [ postgresql ] ++ lib.optional (postgresql ? pg_config) postgresql.pg_config; in # -- linux { crypto = [ openssl ]; @@ -57,10 +61,10 @@ in bz2 = [ bzip2 ]; util = [ utillinux ]; magic = [ file ]; - pgcommon = [ postgresql ]; - pgport = [ postgresql] ; - pq = [ postgresql ]; - libpq = [ postgresql ]; + pgcommon = postgresqlLibs; + pgport = postgresqlLibs; + pq = postgresqlLibs; + libpq = postgresqlLibs; iconv = [ libiconv ]; lapack = [ liblapack ]; boost_atomic = [ boost ];