From 6f808dfe189bef874702e04f3d44b038a8fcb382 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 29 Jun 2020 09:38:17 -0400 Subject: refactor(xan): Simplify build infrastructure 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 Reviewed-by: BuildkiteCI --- users/glittershark/xanthous/default.nix | 24 ++++------------- users/glittershark/xanthous/hie.nix | 16 +++++++++++ users/glittershark/xanthous/hie.sh | 10 +++---- users/glittershark/xanthous/pkg.nix | 15 +++-------- users/glittershark/xanthous/shell.nix | 48 +++++++++++---------------------- 5 files changed, 42 insertions(+), 71 deletions(-) create mode 100644 users/glittershark/xanthous/hie.nix diff --git a/users/glittershark/xanthous/default.nix b/users/glittershark/xanthous/default.nix index c4260fe258..0b89a50afb 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 0000000000..c8b1d2b5f5 --- /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 4ea97997c7..223a432203 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 91de68ea32..fc303a3eda 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 b78844c0ee..491f0779f8 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; }) + ]; +} -- cgit 1.4.1