From c12d3ccdac51b10d81118dbfeaf8f8de301a645e Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Mon, 22 Mar 2021 14:04:52 -0400
Subject: [PATCH] ci: Ensure that only a single nixpkgs is used

Previously ghc-artefact-nix would end up using a different nixpkgs from
the rest of the build. I believe this ended up bringing in multiple
incompatible glibcs.
---
 .gitlab-ci.yml           |  7 +++----
 ci/ghc-from-artifact.nix | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)
 create mode 100644 ci/ghc-from-artifact.nix

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 71193b8b..a8466955 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -110,10 +110,9 @@ build-9.0:
     - nix run -f ./ci -c curl -L "$GHC_TARBALL" > ghc.tar.xz
     - |
       nix build \
-      -f https://github.com/mpickering/ghc-artefact-nix/archive/master.tar.gz \
-      --arg url ./ghc.tar.xz \
-      --out-link ghc \
-      ghcHEAD
+      -f ci/ghc-from-artifact.nix \
+      --arg ghcTarball ./ghc.tar.xz \
+      --out-link ghc
     - export GHC=`pwd`/ghc/bin/ghc
     - rm -Rf $HOME/.cabal/packages/local ci/run
       # Build CI executable
diff --git a/ci/ghc-from-artifact.nix b/ci/ghc-from-artifact.nix
new file mode 100644
index 00000000..2357bb98
--- /dev/null
+++ b/ci/ghc-from-artifact.nix
@@ -0,0 +1,21 @@
+let
+  sources = import ./nix/sources.nix;
+  nixpkgs = import sources.nixpkgs {};
+in
+
+{ ghcTarball }:
+let
+  nixpkgsSrc = sources.nixpkgs;
+  ghc-artefact-nix =
+    let
+      src = nixpkgs.fetchFromGitHub {
+        owner = "mpickering";
+        repo = "ghc-artefact-nix";
+        rev = "5da00a2f9411f15a7e0cbacc0ad94ff4ffa195d7";
+        sha256 = "sha256:1ab2hc893vlsclddqyvw3yrhg33sn7pjckl2v8yi67d2jwc9zygn";
+      };
+    in import src {
+      url = ghcTarball;
+      nixpkgsSrc = sources.nixpkgs;
+    };
+in ghc-artefact-nix.ghcHEAD
-- 
GitLab