hapistrano/docs/NIX.md

62 lines
1.5 KiB
Markdown
Raw Normal View History

Reproducible development and test environments (#212) * Setting up Nix / Running the build using Nix * Delete other CI workflows (temporarily) * Add cabal update * Cache dependencies * Run tests * Add missing dependency required for testing * Add macos-latest runner * Exclude GHC 8.10 on macos-latest * Trying something with haskell.nix overlays * Trying to compile the project with an external flake * Pass --accept-flake-config flag * Install GHC package provided by haskell-nix * Pass --accept-flake-config and enable ubuntu-latest * Remove hello project * Update substituters * Test with ubuntu * Disable macos * Add stdenv.cc.cc.lib * Testing ghc90 running on ubuntu-latest * Install GMP dev * Remove .dev from gmp * Use propagatedBuildInputs * Install stdenv * Add --verbose=3 * Test ghc810 running on ubuntu-latest * Install libstdc++6 * Fix typo * Run nix-info * Add nix-path * List /usr/lib/x86_64-linux-gnu * Run cabal clean before cabal build * Run without cache * Turn on cache again * Run all builds * Run ghc90 on ubuntu-latest only * Install ghc from haskell on Linux and haskell-nix on Mac * Re-enable cache * Add labels to steps * Add scripts to run nix-shells * Install zsh * Exclude GHC 8.10 from macOS * Install zsh only on Linux * Minor refactoring * Merge nix workflow into build * Remove nix workflow * Update README file * Fix merge conflicts * Fix runs-on * Add cache.nixos.org config * Exclude ghc90 on macos-latest * Add note about GHC 9.0 running on macOS * Update flake.lock * Run GHC 9.0 (macOS) * Print GHC and cabal versions * Disable docker job (temp change) * Fix compilation issue * Refactor documentation * Re-enable docker job * Update comment in the .cabal file * Revert .cabal file changes * Extract nix content to a separate file * Extract nix content to a separate file * Update README file * Update TODO section * Remove .tmuxinator.yml * Remove table of content from the README file * Fix typo in command * Update Nix docs * Update restart instructions
2023-04-18 16:27:59 +03:00
# Nix
## Requirements
- Install [Nix](https://nixos.org/download.html)
- Enable Flakes [permanently](https://nixos.wiki/wiki/Flakes#Permanent)
**For macOS users**
Add the following lines to configuration file located at `/etc/nix/nix.conf`:
```
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.iog.io https://cache.nixos.org
```
Restart the `nix-daemon` service:
```
sudo launchctl stop org.nixos.nix-daemon
sudo launchctl start org.nixos.nix-daemon
```
If the following messages appear running the scripts detailed in the section
below, it means that the Nix is not able to talk with the cache, in which case
is recommended to go over the steps detailed in this section again:
```
warning: ignoring untrusted substituter 'https://cache.iog.io'
```
## Switching between different GHC versions
The `bin` directory, holds all available shells:
```
ls bin | grep ghc
```
To spawn a new shell with a pre-defined GHC version, choose one of the scripts
listed above and run the following command:
```sh
./bin/ghc90
```
Once inside the shell, verify the GHC version matches the script name:
```
ghc --version
```
After that, all commands detailed in the [Getting
Started](../README.md#getting-started) section should work the same.
Alternatively, to run a command without spawning a new shell use the `-c`
option:
```sh
./bin/ghc90 -c <command>
```