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

docs: update readme with nix cache info #1091

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,23 @@ We are building the features of Firebase using enterprise-grade, open source pro
[![New Sponsor](https://user-images.githubusercontent.com/10214025/90518111-e74bbb00-e198-11ea-8f88-c9e3c1aa4b5b.png)](https://github.com/sponsors/supabase)


## Experimental Nix Packaging of resources
## Nix Packaging of resources

There is a `/nix` folder in this repo, plus a `flake.nix` and `flake.lock` that facilitate using the Nix package management system to package supabase/postgres, and all of our extensions and wrappers. A user will need nix installed on their machine. As of 4/1/2024 the package set only builds on target machines (`x86_64-linux` and `aarch64-linux`), however work is under way to also support building and using directly on `aarch64-darwin` (macOs). As of 4/1/2024, versions of packages and extensions are synced from `/ansible/vars.yml` via a utility that can be run by executing `nix run .#sync-exts-versions` (you must have nix installed and be on the supported `x86_64-linux` and `aarch64-linux` for this command to work). The short term goal is to sync these versions as they are updated by our infrastructure and postgres teams, then to see the nix packaged versions build successfully in parallel over time, along with tests of the nix packaged versions passing.
There is a `/nix` folder in this repo, plus a `flake.nix` and `flake.lock` that facilitate using the Nix package management system to package supabase/postgres, and all of our extensions and wrappers. A user will need nix installed on their machine.

The supabase/postgres repo will continue to source it's dependencies from ansible for the short term, while we stabilize this nix build.
The package set builds on target machines (`x86_64-linux` and `aarch64-linux`) with an accompanying nix cache, however work is under way to also support building and using directly on `aarch64-darwin` (macOs). Currently, `aarch64-daarwin` will build and run, but the cache is not yet automatically updated on each PR submission to this repo.

Forthcoming PR's will include: integrating the nix work into our ansible/packer builds, building natively on aarch64-darwin (macOs), more testing
### Nix Binary Cache Configuration

To update our nix.conf to support the binary caches used by supabase:

1. open `/etc/nix/nix.conf`
2. Add the following lines

```
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
```
3. save changes to the `/etc/nix/nix.conf` file
Copy link
Member

@steve-chavez steve-chavez Aug 6, 2024

Choose a reason for hiding this comment

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

Editing this didn't work for me (nix show-config didn't show the updated values even after restarting nix daemon), but editing .config/nix/nix.conf worked. IMO it should be mentioned too.

4. On **linux**, run `sudo systemctl restart nix-daemon.service` on **macOS** run: `sudo launchctl stop org.nixos.nix-daemon` and `sudo launchctl start org.nixos.nix-daemon`
5. verify by running nix config show | grep 'substituters\|trusted-public-keys'
Copy link
Member

Choose a reason for hiding this comment

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

On my machine nix show-config is available but not nix config show. Maybe put it here as an alternative?

Using:

nix --version
nix (Nix) 2.17.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes, you do need to have experimental features for enabled in nix.conf

experimental-features = nix-command flakes

or when running the command --experimental-features 'nix-command flakes'

Copy link
Contributor Author

@samrose samrose Aug 6, 2024

Choose a reason for hiding this comment

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

or you can just use nix show-config I'll update the README with this info

Loading