This commit is contained in:
claymager 2021-06-28 06:47:47 -04:00 committed by GitHub
parent a6555549ee
commit 594cb0039c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 31 deletions

View File

@ -18,6 +18,4 @@ jobs:
- uses: cachix/install-nix-action@v12
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20210126_f15f0b8/install
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix flake check
- run: nix-build -A checks.x86_64-linux

View File

@ -34,8 +34,8 @@ of `make` in the following steps.
### 1: Set installation target directory
- Change the `PREFIX` in `config.mk` to the absolute path of your chosen installation destination. The default is to install in
`$HOME/.idris2`
- Change the `PREFIX` in `config.mk` to the absolute path of your chosen
installation destination. The default is to install in `$HOME/.idris2`
If you have an existing Idris 2, go to Step 3. Otherwise, read on...
@ -81,7 +81,9 @@ that everything has worked correctly. Assuming that `idris2` is in your
`PATH`.
- `make clean` -- to make sure you're building everything with the new version
- `make all && make install` -- OR `make all IDRIS2_BOOT='idris2 --codegen racket' && make install` if using Racket.
- `make all && make install` -- OR
`make all IDRIS2_BOOT='idris2 --codegen racket' && make install`
if using Racket.
### 5: Running tests
@ -121,6 +123,7 @@ eval "$(idris2 --bash-completion-script idris2)"
You can also add it to your `.bashrc` file.
#### For ZSH Users
From within ZSH, run the following commands:
```sh
@ -151,8 +154,8 @@ brew install idris2
### Installing from nix
If you are a [nix](https://nixos.org/features.html) user you can install Idris 2 together with all the requirements
by running the following command:
If you are a [nix](https://nixos.org/features.html) user you can install Idris
2 together with all the requirements by running the following command:
```sh
nix-env -i idris2
@ -160,7 +163,8 @@ nix-env -i idris2
### Install from nix flakes
If you are a [nix flakes](https://nixos.wiki/wiki/Flakes) user you can install Idris 2 together with all the requirements by running the following command:
If you are a [nix flakes](https://nixos.wiki/wiki/Flakes) user you can install
Idris 2 together with all the requirements by running the following command:
```sh
nix profile install github:idris-lang/Idris2
@ -170,8 +174,9 @@ nix profile install github:idris-lang/Idris2
### Run on emacs using nix flakes
If you are a [nix flakes](https://nixos.wiki/wiki/Flakes) user you can run Idris 2 in emacs by running the following command:
If you are a [nix flakes](https://nixos.wiki/wiki/Flakes) user you can run
Idris 2 in emacs by running the following command:
```sh
nix run idris-lang/Idris2#emacs-with-idris idrisCode.idr
nix run github:idris-lang/Idris2#emacs-with-idris idrisCode.idr
```

View File

@ -1,3 +1,3 @@
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = builtins.fetchGit ./.;
src = ./.;
}).defaultNix

View File

@ -9,6 +9,7 @@
, racket
, gambit
, nodejs
, zsh
}:
# Uses scheme to bootstrap the build of idris2
@ -19,7 +20,8 @@ stdenv.mkDerivation rec {
src = ../.;
strictDeps = true;
nativeBuildInputs = [ makeWrapper clang chez ];
nativeBuildInputs = [ makeWrapper clang chez ]
++ lib.optional stdenv.isDarwin [ zsh ];
buildInputs = [ chez gmp ];
prePatch = ''
@ -38,39 +40,34 @@ stdenv.mkDerivation rec {
# TODO: Move this into its own derivation, such that this can be changed
# without having to recompile idris2 every time.
postInstall = let
includedLibs = [ "base" "contrib" "network" "prelude" "test" ];
name = "${pname}-${version}";
packagePaths = builtins.map (l: "$out/${name}/${l}-${version}") includedLibs;
additionalIdris2Paths = builtins.concatStringsSep ":" packagePaths;
globalLibraries = [ "\\$HOME/.nix-profile/lib/${name}" "/run/current-system/sw/lib/${name}" ];
globalLibraries = [
"\\$HOME/.nix-profile/lib/${name}"
"/run/current-system/sw/lib/${name}"
"$out/${name}"
];
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;
in ''
# Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH
rm $out/bin/idris2
# Move actual idris2 binary
# The only thing we need from idris2_app is the actual binary
mv $out/bin/idris2_app/idris2.so $out/bin/idris2
# After moving the binary, there is nothing left in idris2_app that isn't
# either contained in lib/ or is useless to us.
rm $out/bin/idris2_app/*
rmdir $out/bin/idris2_app
# idris2 needs to find scheme at runtime to compile
# idris2 installs packages with --install into the path given by PREFIX.
# Since PREFIX is in nix-store, it is immutable so --install does not work.
# If the user redefines PREFIX to be able to install packages, idris2 will
# not find the libraries and packages since all paths are relative to
# PREFIX by default.
# We explicitly make all paths to point to nix-store, such that they are
# independent of what IDRIS2_PREFIX is. This allows the user to redefine
# IDRIS2_PREFIX and use --install as expected.
# idris2 installs packages with --install into the path given by
# IDRIS2_PREFIX. We set that to a default of ~/.idris2, to mirror the
# behaviour of the standard Makefile install.
# TODO: Make support libraries their own derivation such that
# overriding LD_LIBRARY_PATH is unnecessary
# TODO: Maybe set IDRIS2_PREFIX to the users home directory
wrapProgram "$out/bin/idris2" \
--set-default CHEZ "${chez}/bin/scheme" \
--set-default IDRIS2_PREFIX "~/.idris2" \
--suffix IDRIS2_LIBS ':' "$out/${name}/lib" \
--suffix IDRIS2_DATA ':' "$out/${name}/support" \
--suffix IDRIS2_PATH ':' "${additionalIdris2Paths}" \
--run "export IDRIS2_PACKAGE_PATH=\$IDRIS2_PACKAGE_PATH:${globalLibrariesPath}" \
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}" \
--suffix LD_LIBRARY_PATH ':' "$out/${name}/lib"
'';
}