From f17af1f5ca9b6129f97ded80224714b241ad78e1 Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Tue, 16 Jul 2024 11:24:24 -0600 Subject: [PATCH 1/3] Document Nix cache configuration --- development.markdown | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/development.markdown b/development.markdown index 962a507c63..f16c52344e 100644 --- a/development.markdown +++ b/development.markdown @@ -113,6 +113,28 @@ Stack doesn't work deterministically in Windows due to mismatched expectations a ## Building with Nix +__NB__: It is important that the Unison Nix cache is trusted when building, otherwise you will likely end up building hundreds of packages, including GHC itself. + +The recommended way to do this is to add the public key and URL for the cache to your system’s Nix configuration. /etc/nix/nix.conf should have lines similar to +```conf +trusted-public-keys = unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k= +trusted-substituters = https://unison.cachix.org +``` +these lines could be prefixed with `extra-` and they may have additional entries besides the ones for our cache. + +This command should work if you don’t want to edit the file manually: +```shell +sudo sh -c 'echo "extra-trusted-public-keys = unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k= +extra-trusted-substituters = https://unison.cachix.org" >>/etc/nix/nix.conf' +``` +If you use NixOS, you may instead add this via your configuration.nix with +```nix +nix.settings.trusted-public-keys = ["unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k="]; +nix.settings.trusted-substituters = ["https://unison.cachix.org"]; +``` + +It is _not_ recommended to add your user to `trusted-users`. This _can_ make enabling flake configurations simpler (like the Unison Nix cache here), but [it is equivalent to giving that user root access (without need for sudo)](https://nix.dev/manual/nix/2.23/command-ref/conf-file.html#conf-trusted-users). + ## Building package components with nix ### Build the unison executable From ce9b1d8d4e99c6535c160981d525c9661c845fa5 Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Tue, 16 Jul 2024 11:51:49 -0600 Subject: [PATCH 2/3] Add docs for updating the Nix config after editing it --- development.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/development.markdown b/development.markdown index f16c52344e..a8cfee7bdf 100644 --- a/development.markdown +++ b/development.markdown @@ -127,11 +127,20 @@ This command should work if you don’t want to edit the file manually: sudo sh -c 'echo "extra-trusted-public-keys = unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k= extra-trusted-substituters = https://unison.cachix.org" >>/etc/nix/nix.conf' ``` +After updating /etc/nix/nix.conf, you need to restart the Nix daemon. To do this on +- Ubuntu: `sudo systemctl restart nix-daemon` +- MacOS: + ```shell + sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist + sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist + ``` + If you use NixOS, you may instead add this via your configuration.nix with ```nix nix.settings.trusted-public-keys = ["unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k="]; nix.settings.trusted-substituters = ["https://unison.cachix.org"]; ``` +and run `sudo nixos-rebuild switch` afterward. It is _not_ recommended to add your user to `trusted-users`. This _can_ make enabling flake configurations simpler (like the Unison Nix cache here), but [it is equivalent to giving that user root access (without need for sudo)](https://nix.dev/manual/nix/2.23/command-ref/conf-file.html#conf-trusted-users). From 734b6c44f6f93209adbdae0ec0edc948496d2198 Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Tue, 16 Jul 2024 12:23:10 -0600 Subject: [PATCH 3/3] Minor formatting cleanup So my editor stops fixing things for me. --- development.markdown | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/development.markdown b/development.markdown index a8cfee7bdf..afb70842ca 100644 --- a/development.markdown +++ b/development.markdown @@ -22,7 +22,7 @@ We use 0.5.0.1 of Ormolu and CI will add an extra commit, if needed, to autoform Also note that you can always wrap a comment around some code you don't want Ormolu to touch, using: -``` +```haskell {- ORMOLU_DISABLE -} dontFormatMe = do blah blah @@ -96,11 +96,13 @@ This codebase uses symlinks as a workaround for some inconveniences in the `here First you'll need to enable "Developer Mode" in your Windows settings. - See https://consumer.huawei.com/en/support/content/en-us15594140/ +> See https://consumer.huawei.com/en/support/content/en-us15594140/ Then you'll need to enable symlink support in your `git` configuration, e.g. - `git config core.symlinks true` +```shell +git config core.symlinks true +``` And then ask `git` to fix up your symlinks with `git checkout .` @@ -147,7 +149,7 @@ It is _not_ recommended to add your user to `trusted-users`. This _can_ make ena ## Building package components with nix ### Build the unison executable -``` +```shell nix build ``` @@ -156,7 +158,7 @@ This is specified with the normal `::` triple. Some examples: -``` +```shell nix build '.#component-unison-cli:lib:unison-cli' nix build '.#component-unison-syntax:test:syntax-tests' nix build '.#component-unison-cli:exe:transcripts' @@ -174,7 +176,7 @@ include: - ormolu - haskell-language-server -``` +```shell nix develop ``` @@ -184,7 +186,7 @@ versions of the compiler and other development tools. Additionally, all non-local haskell dependencies (including profiling dependencies) are provided in the nix shell. -``` +```shell nix develop '.#cabal-local' ``` @@ -194,17 +196,17 @@ versions of the compiler and other development tools. Additionally, all haskell dependencies of this package are provided by the nix shell (including profiling dependencies). -``` +```shell nix develop '.#cabal-' ``` for example: -``` +```shell nix develop '.#cabal-unison-cli' ``` or -``` +```shell nix develop '.#cabal-unison-parser-typechecker' ``` @@ -213,7 +215,7 @@ want to profile `unison-cli-main:exe:unison` then you could get into one of thes shells, cd into its directory, then run the program with profiling. -``` +```shell nix develop '.#cabal-unison-parser-typechecker' cd unison-cli cabal run --enable-profiling unison-cli-main:exe:unison -- +RTS -p