Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix: refactor with flakes #1827

Merged
merged 19 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ['default']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch protection rules need to be updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

os: [ubuntu-latest, macOS-latest]

steps:
Expand All @@ -33,13 +32,21 @@ jobs:
with:
submodules: true
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: cachix/install-nix-action@v12
uses: cachix/install-nix-action@v13
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: cachix/cachix-action@v8
with:
name: haskell-language-server
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: nix-shell --argstr compiler ${{ matrix.ghc }} --run "cabal update && cabal build"
run: nix build
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: nix develop --profile dev && cachix push haskell-language-server dev
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ test/testdata/**/hie.yaml
# ghcide-bench
*.identifierPosition
/bench/example

# nix
result
result-doc
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ background](https://neilmitchell.blogspot.com/2020/01/one-haskell-ide-to-rule-th
- [Using Cabal](#using-cabal)
- [Using Stack](#using-stack)
- [Using Nix](#using-nix)
- [Flakes support](#flakes-support)
- [Introduction tutorial](#introduction-tutorial)
- [Test your hacked HLS in your editor](#test-your-hacked-hls-in-your-editor)
- [Adding support for a new editor](#adding-support-for-a-new-editor)
Expand Down Expand Up @@ -807,8 +808,27 @@ $ cabal update
$ cabal build
```

##### Flakes support

If you are using nix 2.4 style command (enabled by `experimental-features = nix-command`),
you can use `nix develop` instead of `nix-shell` to enter the development shell. To enter the shell with specific GHC versions:
berberman marked this conversation as resolved.
Show resolved Hide resolved

* `nix develop` or `nix develop .#haskell-language-server-dev` - default GHC version
* `nix develop .#haskell-language-server-8104-dev` - GHC 8.10.4
* `nix develop .#haskell-language-server-884-dev` - GHC 8.8.4
* `nix develop .#haskell-language-server-901-dev` - GHC 9.0.1

If you are looking for a Nix expression to create haskell-language-server binaries, see https://github.com/haskell/haskell-language-server/issues/122

To create binaries:

* `nix build` or `nix build .#haskell-language-server` - default GHC version
* `nix build .#haskell-language-server-8104` - GHC 8.10.4
* `nix build .#haskell-language-server-884` - GHC 8.8.4
* `nix build .#haskell-language-server-901` - GHC 9.0.1

GHC 8.6.5 is not supported here because `nixpkgs-unstable` no longer maintains the corresponding packages set.

#### Introduction tutorial

Pepeiborra [wrote an tutorial](https://github.com/pepeiborra/hls-tutorial) on writing a plugin in HLS.
Expand Down
11 changes: 11 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is the compt layer of flakes: https://github.com/edolstra/flake-compat
# See flake.nix for details
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).defaultNix
101 changes: 101 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.