diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 73a9d50c18..7bade64d53 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,25 +11,27 @@ variables: CABAL_INSTALL_VERSION: 3.8.1.0 -.windows_matrix: &windows_matrix +.matrix: &matrix matrix: - GHC_VERSION: 8.10.7 CABAL_PROJECT: cabal.project - GHC_VERSION: 9.0.2 CABAL_PROJECT: cabal.project - - GHC_VERSION: 9.2.3 - CABAL_PROJECT: cabal.project - GHC_VERSION: 9.2.4 CABAL_PROJECT: cabal.project - - GHC_VERSION: 9.4.1 + - GHC_VERSION: 9.2.5 CABAL_PROJECT: cabal.project - GHC_VERSION: 9.4.2 CABAL_PROJECT: cabal.project + - GHC_VERSION: 9.4.3 + CABAL_PROJECT: cabal.project workflow: rules: - if: $CI_COMMIT_TAG when: always + - if: $CI_PIPELINE_SOURCE == "web" + when: always - when: never .artifacts: @@ -47,6 +49,7 @@ workflow: .build: extends: .artifacts:short stage: build + parallel: *matrix script: - bash .gitlab/ci.sh @@ -75,6 +78,16 @@ workflow: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" +.x86_64-linux-ubuntu18.04: + tags: + - x86_64-linux + image: "ubuntu:18.04" + +.x86_64-linux-ubuntu20.04: + tags: + - x86_64-linux + image: "ubuntu:20.04" + .x86_64-linux-centos7: tags: - x86_64-linux @@ -163,6 +176,84 @@ test-armv7-linux-deb10: - sudo apt install -y tree +########################### +# x86_64 linux ubuntu18.04 +########################### + +build-x86_64-linux-ubuntu18.04: + extends: + - .build + - .x86_64-linux-ubuntu18.04 + before_script: + - apt update + - apt install -y build-essential curl libffi-dev libffi6 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 zlib1g-dev patchelf tree + variables: + ADD_CABAL_ARGS: "--enable-split-sections" + +tar-x86_64-linux-ubuntu18.04: + extends: + - .artifacts + - .x86_64-linux-ubuntu18.04 + stage: tar + needs: ["build-x86_64-linux-ubuntu18.04"] + script: + - ./.gitlab/tar.sh + variables: + TARBALL_ARCHIVE_SUFFIX: x86_64-ubuntu18.04-linux + TARBALL_EXT: tar.xz + before_script: + - apt update + - apt install -y make tar xz-utils curl + +test-x86_64-linux-ubuntu18.04: + extends: + - .test + - .x86_64-linux-ubuntu18.04 + needs: ["tar-x86_64-linux-ubuntu18.04"] + before_script: + - apt update + - apt install -y tree patchelf make curl build-essential + + +########################### +# x86_64 linux ubuntu20.04 +########################### + +build-x86_64-linux-ubuntu20.04: + extends: + - .build + - .x86_64-linux-ubuntu20.04 + before_script: + - apt update + - apt install -y build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 zlib1g-dev patchelf tree + variables: + ADD_CABAL_ARGS: "--enable-split-sections" + +tar-x86_64-linux-ubuntu20.04: + extends: + - .artifacts + - .x86_64-linux-ubuntu20.04 + stage: tar + needs: ["build-x86_64-linux-ubuntu20.04"] + script: + - ./.gitlab/tar.sh + variables: + TARBALL_ARCHIVE_SUFFIX: x86_64-ubuntu20.04-linux + TARBALL_EXT: tar.xz + before_script: + - apt update + - apt install -y make tar xz-utils curl + +test-x86_64-linux-ubuntu20.04: + extends: + - .test + - .x86_64-linux-ubuntu20.04 + needs: ["tar-x86_64-linux-ubuntu20.04"] + before_script: + - apt update + - apt install -y tree patchelf make curl build-essential + + ###################### # x86_64 linux deb10 ###################### @@ -418,46 +509,35 @@ test-x86_64-freebsd13: build-x86_64-darwin: extends: .build tags: - - x86_64-darwin + - x86_64-darwin-m1 variables: ADD_CABAL_ARGS: "" - before_script: - - /bin/bash ./.gitlab/brew.sh autoconf automake coreutils make tree + NIX_SYSTEM: x86_64-darwin script: | - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" /bin/bash ./.gitlab/ci.sh - after_script: - - rm -Rf /private/tmp/.brew_tmp tar-x86_64-darwin: extends: .artifacts stage: tar needs: ["build-x86_64-darwin"] tags: - - x86_64-darwin - before_script: - - /bin/bash ./.gitlab/brew.sh autoconf automake coreutils make tree + - x86_64-darwin-m1 script: | - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" /bin/bash ./.gitlab/tar.sh - after_script: - - rm -Rf /private/tmp/.brew_tmp variables: TARBALL_ARCHIVE_SUFFIX: x86_64-apple-darwin TARBALL_EXT: tar.xz + NIX_SYSTEM: x86_64-darwin test-x86_64-darwin: extends: .test needs: ["tar-x86_64-darwin"] tags: - - x86_64-darwin - before_script: - - /bin/bash ./.gitlab/brew.sh make tree + - x86_64-darwin-m1 script: | - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" /bin/bash .gitlab/test.sh - after_script: - - rm -Rf /private/tmp/.brew_tmp + variables: + NIX_SYSTEM: x86_64-darwin ###################### @@ -465,26 +545,16 @@ test-x86_64-darwin: ###################### build-aarch64-darwin: - extends: .artifacts:short + extends: .build stage: build tags: - aarch64-darwin-m1 - before_script: - - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 - - arch -arm64 /bin/bash ./.gitlab/brew.sh llvm autoconf automake coreutils make tree script: | - export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" - export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang - export CXX=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang++ - export LD=ld - export AR=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ar - export RANLIB=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ranlib arch -arm64 /bin/bash ./.gitlab/ci.sh - after_script: - - rm -Rf /private/tmp/.brew_tmp variables: MACOSX_DEPLOYMENT_TARGET: "10.7" ADD_CABAL_ARGS: "" + NIX_SYSTEM: aarch64-darwin tar-aarch64-darwin: extends: .artifacts @@ -497,20 +567,17 @@ tar-aarch64-darwin: variables: TARBALL_ARCHIVE_SUFFIX: aarch64-apple-darwin TARBALL_EXT: tar.xz + NIX_SYSTEM: aarch64-darwin test-aarch64-darwin: extends: .test needs: ["tar-aarch64-darwin"] tags: - aarch64-darwin-m1 - before_script: - - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 - - arch -arm64 /bin/bash ./.gitlab/brew.sh make tree script: | - export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" arch -arm64 /bin/bash ./.gitlab/test.sh - after_script: - - rm -Rf /private/tmp/.brew_tmp + variables: + NIX_SYSTEM: aarch64-darwin ###################### @@ -521,7 +588,6 @@ build-x86_64-windows: extends: .build tags: - new-x86_64-windows - parallel: *windows_matrix script: - $env:CHERE_INVOKING = "yes" - bash '-lc' "ADD_CABAL_ARGS=$env:ADD_CABAL_ARGS GHC_VERSION=$env:GHC_VERSION CABAL_INSTALL_VERSION=$CABAL_INSTALL_VERSION .gitlab/ci.sh" diff --git a/.gitlab/brew.sh b/.gitlab/brew.sh deleted file mode 100644 index de769632e6..0000000000 --- a/.gitlab/brew.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -Eeuxo pipefail - -# Install brew locally in the project dir. Packages will also be installed here. -[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew -export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" - -# make sure to not pollute the machine with temp files etc -mkdir -p $CI_PROJECT_DIR/.brew_cache -export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache -mkdir -p $CI_PROJECT_DIR/.brew_logs -export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs -mkdir -p /private/tmp/.brew_tmp -export HOMEBREW_TEMP=/private/tmp/.brew_tmp - -# update and install packages -brew update -brew install ${1+"$@"} diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh index 751b09c7ea..0d784e6464 100755 --- a/.gitlab/ci.sh +++ b/.gitlab/ci.sh @@ -3,6 +3,7 @@ set -Eeuxo pipefail source "$CI_PROJECT_DIR/.gitlab/common.sh" +source "$CI_PROJECT_DIR/.gitlab/setup.sh" export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain" export CABAL_DIR="$CI_PROJECT_DIR/cabal" @@ -11,12 +12,12 @@ EXE_EXTENSION="" case "$(uname)" in MSYS_*|MINGW*) export CABAL_DIR="$(cygpath -w "$CABAL_DIR")" - GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin" - EXE_EXTENSION=".exe" + GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin" + EXE_EXTENSION=".exe" + ;; + *) + GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin" ;; - *) - GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin" - ;; esac mkdir -p "$CABAL_DIR" @@ -27,64 +28,66 @@ export BOOTSTRAP_HASKELL_NONINTERACTIVE=1 export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VERSION:-recommended}" export BOOTSTRAP_HASKELL_CABAL_VERSION="$CABAL_INSTALL_VERSION" export BOOTSTRAP_HASKELL_VERBOSE=1 +export BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes # for some reason the subshell doesn't pick up the arm64 environment on darwin # and starts installing x86_64 GHC case "$(uname -s)" in - "Darwin"|"darwin") - case "$(/usr/bin/arch)" in - aarch64|arm64|armv8l) - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash - ;; - *) - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh - ;; - esac - ;; - *) - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh - ;; + "Darwin"|"darwin") + case "$(/usr/bin/arch)" in + aarch64|arm64|armv8l) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash + export C_INCLUDE_PATH="`xcrun --show-sdk-path`/usr/include/ffi" + ;; + *) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh + ;; + esac + ;; + *) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh + ;; esac case "$(uname)" in MSYS_*|MINGW*) - # workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/21196 - # export PATH="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin:${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/usr/bin:$PATH" - # ls ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin - # cp ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin/libgcc_s_seh-1.dll ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/bin - # cp ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin/libwinpthread-1.dll ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/bin - ghc --info - # Shorten binary names - sed -i.bak -e 's/haskell-language-server/hls/g' \ - -e 's/haskell_language_server/hls/g' \ - haskell-language-server.cabal $CABAL_PROJECT - sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ - src/**/*.hs exe/*.hs + # workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/21196 + # export PATH="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin:${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/usr/bin:$PATH" + # ls ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin + # cp ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin/libgcc_s_seh-1.dll ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/bin + # cp ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/mingw/bin/libwinpthread-1.dll ${GHCUP_INSTALL_BASE_PREFIX}/ghcup/ghc/${GHC_VERSION}/bin + ghc --info + # Shorten binary names + sed -i.bak -e 's/haskell-language-server/hls/g' \ + -e 's/haskell_language_server/hls/g' \ + haskell-language-server.cabal $CABAL_PROJECT + sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ + src/**/*.hs exe/*.hs - args=( - -O2 - -w "ghc-$GHC_VERSION" - --project-file "$CABAL_PROJECT" - --disable-profiling - --disable-tests - --enable-executable-stripping - ${ADD_CABAL_ARGS} - ) + args=( + -O2 + -w "ghc-$GHC_VERSION" + --project-file "$CABAL_PROJECT" + --disable-profiling + --disable-tests + --enable-executable-stripping + ${ADD_CABAL_ARGS} + ) - run cabal v2-build ${args[@]} exe:hls exe:hls-wrapper + run cabal v2-build ${args[@]} exe:hls exe:hls-wrapper - mkdir "$CI_PROJECT_DIR/out" + mkdir "$CI_PROJECT_DIR/out" - cp "$(cabal list-bin -v0 ${args[@]} exe:hls)" "$CI_PROJECT_DIR/out/haskell-language-server-${GHC_VERSION}"$EXE_EXTENSION - cp "$(cabal list-bin -v0 ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper"$EXE_EXTENSION + cp "$(cabal list-bin -v0 ${args[@]} exe:hls)" "$CI_PROJECT_DIR/out/haskell-language-server-${GHC_VERSION}"$EXE_EXTENSION + cp "$(cabal list-bin -v0 ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper"$EXE_EXTENSION ;; - *) - sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project - emake --version - emake GHCUP=ghcup hls - emake GHCUP=ghcup bindist - rm -rf out/*.*.* + *) + sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project + emake --version + emake GHCUP=ghcup hls-ghc + emake GHCUP=ghcup bindist-ghc + rm -rf out/*.*.* ;; esac diff --git a/.gitlab/darwin/nix/sources.json b/.gitlab/darwin/nix/sources.json new file mode 100644 index 0000000000..a6ff5dc415 --- /dev/null +++ b/.gitlab/darwin/nix/sources.json @@ -0,0 +1,26 @@ +{ + "niv": { + "branch": "master", + "description": "Easy dependency management for Nix projects", + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070", + "sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx", + "type": "tarball", + "url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "wip/ghc-8.10.7-darwin", + "description": "Nix Packages collection", + "homepage": "", + "owner": "bgamari", + "repo": "nixpkgs", + "rev": "37c60356e3f83c708a78a96fdd914b5ffc1f551c", + "sha256": "0i5j7nwk4ky0fg4agla3aznadpxz0jyrdwp2q92hyxidra987syn", + "type": "tarball", + "url": "https://github.com/bgamari/nixpkgs/archive/37c60356e3f83c708a78a96fdd914b5ffc1f551c.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/.gitlab/darwin/nix/sources.nix b/.gitlab/darwin/nix/sources.nix new file mode 100644 index 0000000000..1938409ddd --- /dev/null +++ b/.gitlab/darwin/nix/sources.nix @@ -0,0 +1,174 @@ +# This file has been generated by Niv. + +let + + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; name = name'; } + else + pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + + fetch_tarball = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + else + pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + + fetch_git = name: spec: + let + ref = + if spec ? ref then spec.ref else + if spec ? branch then "refs/heads/${spec.branch}" else + if spec ? tag then "refs/tags/${spec.tag}" else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + in + builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; + + fetch_local = spec: spec.path; + + fetch_builtin-tarball = name: throw + ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; + + fetch_builtin-url = name: throw + ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; + + # + # Various helpers + # + + # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 + sanitizeName = name: + ( + concatMapStrings (s: if builtins.isList s then "-" else s) + ( + builtins.split "[^[:alnum:]+._?=-]+" + ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + ) + ); + + # The set of packages used when specs are fetched using non-builtins. + mkPkgs = sources: system: + let + sourcesNixpkgs = + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; + hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; + hasThisAsNixpkgsPath = == ./.; + in + if builtins.hasAttr "nixpkgs" sources + then sourcesNixpkgs + else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + import {} + else + abort + '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + # The actual fetching function. + fetch = pkgs: name: spec: + + if ! builtins.hasAttr "type" spec then + abort "ERROR: niv spec ${name} does not have a 'type' attribute" + else if spec.type == "file" then fetch_file pkgs name spec + else if spec.type == "tarball" then fetch_tarball pkgs name spec + else if spec.type == "git" then fetch_git name spec + else if spec.type == "local" then fetch_local spec + else if spec.type == "builtin-tarball" then fetch_builtin-tarball name + else if spec.type == "builtin-url" then fetch_builtin-url name + else + abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + + # If the environment variable NIV_OVERRIDE_${name} is set, then use + # the path directly as opposed to the fetched source. + replace = name: drv: + let + saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; + ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; + in + if ersatz == "" then drv else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + + # Ports of functions for older nix versions + + # a Nix version of mapAttrs if the built-in doesn't exist + mapAttrs = builtins.mapAttrs or ( + f: set: with builtins; + listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) + ); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 + range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 + stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); + concatMapStrings = f: list: concatStrings (map f list); + concatStrings = builtins.concatStringsSep ""; + + # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 + optionalAttrs = cond: as: if cond then as else {}; + + # fetchTarball version that is compatible between all the versions of Nix + builtins_fetchTarball = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchTarball; + in + if lessThan nixVersion "1.12" then + fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + else + fetchTarball attrs; + + # fetchurl version that is compatible between all the versions of Nix + builtins_fetchurl = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchurl; + in + if lessThan nixVersion "1.12" then + fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + else + fetchurl attrs; + + # Create the final "sources" from the config + mkSources = config: + mapAttrs ( + name: spec: + if builtins.hasAttr "outPath" spec + then abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) config.sources; + + # The "config" used by the fetchers + mkConfig = + { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null + , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) + , system ? builtins.currentSystem + , pkgs ? mkPkgs sources system + }: rec { + # The sources, i.e. the attribute set of spec name to spec + inherit sources; + + # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers + inherit pkgs; + }; + +in +mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/.gitlab/darwin/toolchain.nix b/.gitlab/darwin/toolchain.nix new file mode 100644 index 0000000000..2c65f92b3c --- /dev/null +++ b/.gitlab/darwin/toolchain.nix @@ -0,0 +1,34 @@ +{ system }: + +let + sources = import ./nix/sources.nix; + nixpkgsSrc = sources.nixpkgs; + pkgs = import nixpkgsSrc { inherit system; }; +in + +let + hsPkgs = pkgs.haskellPackages; + alex = hsPkgs.alex; + happy = hsPkgs.happy; + targetTriple = pkgs.stdenv.targetPlatform.config; + + llvm = pkgs.llvm_11; +in +pkgs.writeTextFile { + name = "toolchain"; + text = '' + export PATH + PATH="${pkgs.autoconf}/bin:$PATH" + PATH="${pkgs.automake}/bin:$PATH" + PATH="${pkgs.tree}/bin:$PATH" + export HAPPY="${happy}/bin/happy" + export ALEX="${alex}/bin/alex" + export LLC="${llvm}/bin/llc" + export OPT="${llvm}/bin/opt" + export SPHINXBUILD="${pkgs.python3Packages.sphinx}/bin/sphinx-build" + export CABAL_INSTALL="${pkgs.cabal-install}/bin/cabal" + export CABAL="$CABAL_INSTALL" + + sdk_path="$(xcrun --sdk macosx --show-sdk-path)" + ''; +} diff --git a/.gitlab/setup.sh b/.gitlab/setup.sh new file mode 100644 index 0000000000..ec4402edc4 --- /dev/null +++ b/.gitlab/setup.sh @@ -0,0 +1,11 @@ +case "$(uname -s)" in + "Darwin"|"darwin") + nix build -f $CI_PROJECT_DIR/.gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + cat toolchain.sh + source toolchain.sh + unset MACOSX_DEPLOYMENT_TARGET + # Precautious since we want to use ghc from ghcup + unset GHC + ;; +esac + diff --git a/.gitlab/tar.sh b/.gitlab/tar.sh index 7e6754fad3..65ee943890 100755 --- a/.gitlab/tar.sh +++ b/.gitlab/tar.sh @@ -3,22 +3,25 @@ set -Eeuxo pipefail source "$CI_PROJECT_DIR/.gitlab/common.sh" +source "$CI_PROJECT_DIR/.gitlab/setup.sh" -ls -la out/ # create tarball/zip -TARBALL_PREFIX="haskell-language-server" case "${TARBALL_EXT}" in zip) + TARBALL_PREFIX="haskell-language-server" HLS_VERSION="$("$CI_PROJECT_DIR/out/haskell-language-server-8.10.7" --numeric-version)" cd out/ zip "${TARBALL_PREFIX}-${HLS_VERSION}-${TARBALL_ARCHIVE_SUFFIX}.zip" haskell-language-server-* find . -type f ! -name '*.zip' -delete ;; tar.xz) + ls -la out/ + ls -la out/bindist/ + ls -la out/bindist/*/ emake --version - HLS_VERSION="$(emake -s -C out/bindist/haskell-language-server-* version)" - emake TARBALL="${TARBALL_PREFIX}-${HLS_VERSION}-${TARBALL_ARCHIVE_SUFFIX}.tar.xz" bindist-tar + emake bindist + emake bindist-tar rm -rf out/bindist ;; *) diff --git a/.gitlab/test.sh b/.gitlab/test.sh index 6c6ef0a51f..3c866c4983 100644 --- a/.gitlab/test.sh +++ b/.gitlab/test.sh @@ -3,6 +3,7 @@ set -Eeuxo pipefail source "$CI_PROJECT_DIR/.gitlab/common.sh" +source "$CI_PROJECT_DIR/.gitlab/setup.sh" export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain" export CABAL_DIR="$CI_PROJECT_DIR/cabal" diff --git a/GNUmakefile b/GNUmakefile index f26c9b4b20..3fc906f335 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -11,9 +11,10 @@ UNAME := $(shell uname) ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) GHC_VERSION ?= +TARBALL_ARCHIVE_SUFFIX ?= HLS_VERSION := $(shell grep '^version:' haskell-language-server.cabal | awk '{ print $$2 }') -TARBALL ?= haskell-language-server-$(HLS_VERSION).tar.xz +TARBALL ?= haskell-language-server-$(HLS_VERSION)-$(TARBALL_ARCHIVE_SUFFIX).tar.xz CHMOD := chmod CHMOD_X := $(CHMOD) 755 @@ -65,29 +66,15 @@ define set_rpath $(if $(filter Darwin,$(UNAME)), $(INSTALL_NAME_TOOL) -add_rpath "@executable_path/$(1)" "$(2)", $(PATCHELF) --force-rpath --set-rpath "\$$ORIGIN/$(1)" "$(2)") endef -hls: bindist/ghcs - for ghc in $(shell [ -e "bindist/ghcs-`uname -o`" ] && cat "bindist/ghcs-`uname -o`" || cat "bindist/ghcs") ; do \ - $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` && \ - $(GHCUP) -v gc -p -s -c && \ - $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc && \ - $(GHCUP) -v rm ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ - done - hls-ghc: $(MKDIR_P) out/ @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi - @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi - $(CABAL_INSTALL) --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_INSTALL_ARGS) --installdir="$(ROOT_DIR)/out/$(GHC_VERSION)" exe:haskell-language-server exe:haskell-language-server-wrapper + @if test -z "$(CABAL_PROJECT)" ; then echo >&2 "CABAL_PROJECT is not set" ; false ; fi + $(CABAL_INSTALL) --project-file="$(CABAL_PROJECT)" -w "ghc-$(GHC_VERSION)" $(CABAL_INSTALL_ARGS) --installdir="$(ROOT_DIR)/out/$(GHC_VERSION)" exe:haskell-language-server exe:haskell-language-server-wrapper $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server" $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper" bindist: - for ghc in $(shell [ -e "bindist/ghcs-`uname`" ] && cat "bindist/ghcs-`uname`" || cat "bindist/ghcs") ; do \ - $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` && \ - $(GHCUP) -v gc -p -s -c && \ - $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc && \ - $(GHCUP) -v rm ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ - done $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ bindist/GNUmakefile.in > "$(BINDIST_OUT_DIR)/GNUmakefile" $(INSTALL_D) "$(BINDIST_OUT_DIR)/scripts/" @@ -125,4 +112,4 @@ clean: clean-all: $(RM_RF) out/* $(STORE_DIR) -.PHONY: hls hls-ghc bindist bindist-ghc bindist-tar clean clean-all install-ghcs +.PHONY: hls-ghc bindist bindist-ghc bindist-tar clean clean-all install-ghcs version diff --git a/bindist/ghcs b/bindist/ghcs deleted file mode 100644 index 17e3ffea1c..0000000000 --- a/bindist/ghcs +++ /dev/null @@ -1,6 +0,0 @@ -8.10.7,cabal.project -9.0.2,cabal.project -9.2.3,cabal.project -9.2.4,cabal.project -9.4.1,cabal.project -9.4.2,cabal.project diff --git a/bindist/ghcs-FreeBSD b/bindist/ghcs-FreeBSD deleted file mode 100644 index a1b4b6e0bf..0000000000 --- a/bindist/ghcs-FreeBSD +++ /dev/null @@ -1,2 +0,0 @@ -8.10.7,cabal.project -9.0.2,cabal.project diff --git a/bindist/ghcs-Msys b/bindist/ghcs-Msys deleted file mode 100644 index 17e3ffea1c..0000000000 --- a/bindist/ghcs-Msys +++ /dev/null @@ -1,6 +0,0 @@ -8.10.7,cabal.project -9.0.2,cabal.project -9.2.3,cabal.project -9.2.4,cabal.project -9.4.1,cabal.project -9.4.2,cabal.project diff --git a/cabal.project b/cabal.project index bad4eda52e..4040bae566 100644 --- a/cabal.project +++ b/cabal.project @@ -51,6 +51,7 @@ package * write-ghc-environment-files: never + index-state: 2022-12-13T21:00:15Z constraints: