about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-06-29T13·38-0400
committerglittershark <grfn@gws.fyi>2020-07-03T14·41+0000
commit6f808dfe189bef874702e04f3d44b038a8fcb382 (patch)
treecdd8ace7c64c2bd560187e1cd5327fd86de4bdd3
parentc0922e49064b1789e3415fbef91ba680ed887882 (diff)
refactor(xan): Simplify build infrastructure r/1189
Simplify the build infrastructure for creating shells etc. for xanthous,
including relying more heavily on stuff exposed in Depot anyway, using
shellFor in the shell.nix, and using the haskell.nix branch of all-hies
for a significantly simpler build. At some point the all-hies stuff will
likely want to be promoted up to //third_party, but for now it's
experimental enough that I don't want to bother other people with it.

Change-Id: I43830de73830fdc07d48af9b87d7930f59599532
Reviewed-on: https://cl.tvl.fyi/c/depot/+/890
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: BuildkiteCI
-rw-r--r--users/glittershark/xanthous/default.nix24
-rw-r--r--users/glittershark/xanthous/hie.nix16
-rwxr-xr-xusers/glittershark/xanthous/hie.sh10
-rw-r--r--users/glittershark/xanthous/pkg.nix15
-rw-r--r--users/glittershark/xanthous/shell.nix48
5 files changed, 42 insertions, 71 deletions
diff --git a/users/glittershark/xanthous/default.nix b/users/glittershark/xanthous/default.nix
index c4260fe258b1..0b89a50afb9e 100644
--- a/users/glittershark/xanthous/default.nix
+++ b/users/glittershark/xanthous/default.nix
@@ -1,21 +1,7 @@
-{ nixpkgs ? import ./nixpkgs.nix {}
-, pkgs ? nixpkgs.pkgs
-, lib ? nixpkgs.lib
-, compiler ? "ghc865"
-, failOnWarnings ? false
+{ pkgs ? (import ../../../. {}).third_party
+, lib ? pkgs.lib
 , ...
 }:
-let
-  inherit (lib) id;
-  inherit (pkgs) fetchurl;
-  all-hies = import (fetchTarball {
-    url = "https://github.com/infinisil/all-hies/archive/4b6aab017cdf96a90641dc287437685675d598da.tar.gz";
-    sha256 = "0ap12mbzk97zmxk42fk8vqacyvpxk29r2wrnjqpx4m2w9g7gfdya";
-  }) {};
-  hie = all-hies.selection { selector = p: { inherit (p) ghc865; }; };
-  xanthous =
-    (if failOnWarnings then pkgs.haskell.lib.failOnAllWarnings else id)
-      ((pkgs.haskellPackages
-      # .extend (import ./haskell-overlay.nix { inherit pkgs; })
-    ).callPackage (import ./pkg.nix { inherit pkgs; }) {}); in
-xanthous // { inherit hie; }
+pkgs.haskell.lib.failOnAllWarnings (
+  pkgs.haskellPackages.callPackage (import ./pkg.nix { inherit pkgs; }) {}
+)
diff --git a/users/glittershark/xanthous/hie.nix b/users/glittershark/xanthous/hie.nix
new file mode 100644
index 000000000000..c8b1d2b5f538
--- /dev/null
+++ b/users/glittershark/xanthous/hie.nix
@@ -0,0 +1,16 @@
+{ pkgs ? (import ../../../. {}).third_party }:
+
+let
+  all-hies = (fetchTarball {
+    url = "https://github.com/infinisil/all-hies/archive/eff5d9a5e1a84150014095494331cf63e59923af.tar.gz";
+    sha256 = "19bws9fyjhgiikig86cri05fxz1wrz60n69zrigq5wzbyn4hwv9h";
+  });
+
+  sources = import "${all-hies}/sources.nix";
+  build = import "${all-hies}/build.nix";
+
+in (build {
+  glibcName = pkgs.glibc.name;
+  inherit sources;
+  ghcVersion = "8.8.3";
+}).combined
diff --git a/users/glittershark/xanthous/hie.sh b/users/glittershark/xanthous/hie.sh
index 4ea97997c778..223a432203b8 100755
--- a/users/glittershark/xanthous/hie.sh
+++ b/users/glittershark/xanthous/hie.sh
@@ -1,10 +1,6 @@
 #!/usr/bin/env bash
+set -euo pipefail
 
-cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
+cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1
 
-argv=( "$@"  )
-argv=( "${argv[@]/\'/\'\\\'\'}"  )
-argv=( "${argv[@]/#/\'}"  )
-argv=( "${argv[@]/%/\'}"  )
-
-exec nix-shell --pure --run "exec $(nix-build -o dist/nix/hie -A hie)/bin/hie ${argv[*]}"
+exec nix-shell --run "$(nix-build -o dist/bin/hie hie.nix)/bin/hie $*"
diff --git a/users/glittershark/xanthous/pkg.nix b/users/glittershark/xanthous/pkg.nix
index 91de68ea3216..fc303a3eda06 100644
--- a/users/glittershark/xanthous/pkg.nix
+++ b/users/glittershark/xanthous/pkg.nix
@@ -1,16 +1,7 @@
-{ pkgs ? import ./nixpkgs.nix {} }:
-let
-  inherit (builtins) filterSource elem not;
-  gitignoreSource = (import (pkgs.fetchFromGitHub {
-    owner = "hercules-ci";
-    repo = "gitignore";
-    rev = "f9e996052b5af4032fe6150bba4a6fe4f7b9d698";
-    sha256 = "0jrh5ghisaqdd0vldbywags20m2cxpkbbk5jjjmwaw0gr8nhsafv";
-    # date = 2019-09-18T15:15:15+02:00;
-  }) { inherit (pkgs) lib; }).gitignoreSource;
-in
+{ pkgs ? (import ../../../. {}).third_party }:
+
 import (pkgs.haskellPackages.haskellSrc2nix {
   name = "xanthous";
-  src = gitignoreSource ./.;
+  src = pkgs.gitignoreSource ./.;
   extraCabal2nixOptions = "--hpack";
 })
diff --git a/users/glittershark/xanthous/shell.nix b/users/glittershark/xanthous/shell.nix
index b78844c0eec6..491f0779f808 100644
--- a/users/glittershark/xanthous/shell.nix
+++ b/users/glittershark/xanthous/shell.nix
@@ -1,35 +1,17 @@
-{ nixpkgs ? import ./nixpkgs.nix {}
-, pkgs ? nixpkgs.pkgs
-, compiler ? "ghc865"
-, withHoogle ? true
-}:
-let
-  pkg = import ./pkg.nix { inherit pkgs; };
+{ pkgs ? (import ../../../. {}).third_party, ... }:
 
-  packageSet = (
-    if compiler == "default"
-    then pkgs.haskellPackages
-    else pkgs.haskell.packages.${compiler}
-  );
+(pkgs.haskellPackages.extend (pkgs.haskell.lib.packageSourceOverrides {
+  xanthous = pkgs.gitignoreSource ./.;
+})).shellFor {
+  packages = p: [p.xanthous];
+  withHoogle = true;
+  buildInputs = with pkgs.haskellPackages; [
+    cabal-install
+    ghc-prof-flamegraph
+    hp2pretty
+  ];
 
-  haskellPackages = (
-    if withHoogle
-    then packageSet.override {
-      overrides = (self: super: {
-        ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
-        ghcWithPackages = self.ghc.withPackages;
-      } // (import ../../../third_party/haskell_overlay { inherit pkgs; })
-        self super);
-    }
-    else packageSet
-  );
-
-  drv = pkgs.haskell.lib.doBenchmark (haskellPackages.callPackage pkg {});
-
-  inherit (pkgs.haskell.lib) addBuildTools;
-in
-(addBuildTools drv (with haskellPackages; [
-  cabal-install
-  ghc-prof-flamegraph
-  hp2pretty
-])).env
+  nativeBuildInputs = [
+    (import ./hie.nix { inherit pkgs; })
+  ];
+}