Using nix

TODO: nix is …​

Setup

MacOS Example

The following works as of nix version 2.7.0. The nix ecosystem is evolving rapidly, so
  1. Install the nix package manager.

  2. Configure nix by modifying and adding the following files

    /etc/nix/nix.conf
    build-users-group = nixbld
    experimental-features = nix-command flakes
    trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.dhall-lang.org:I9/H18WHd60olG5GsIjolp7CtepSgJmM2CsO813VTmM= dhall.cachix.org-1:8laGciue2JBwD49ICFtg+cIF8ddDaW7OFBjDb/dHEAo= nsstatdev-main-usae1-nix-cache-1:3qt3qqlXhyl2HGK8UE1Eh12NEmoyK8mx81uDWDAKPn4=
    substituters = https://cache.nixos.org/ https://hydra.iohk.io https://cache.dhall-lang.org https://dhall.cachix.org s3://nsstatdev-main-usae1-nix-cache
    post-build-hook = /etc/nix/upload-to-cache.sh
    /etc/nix/key.private

    Ask for the key on slack

    /etc/nix/upload-to-cache.sh
    #!/bin/sh
    
    set -eu
    set -f # disable globbing
    export IFS=' '
    
    echo "Signing paths" $OUT_PATHS
    nix store sign --key-file /etc/nix/key.private $OUT_PATHS
    echo "Uploading paths" $OUT_PATHS
    exec nix copy --to 's3://nsstatdev-main-usae1-nix-cache' $OUT_PATHS

    Set this script to executable:

    chmod +x /etc/nix/upload-to-cache.sh
  3. Test out nix: nix build nixpkgs#hello