Skip to Content
GuidesUse Determinate with nix-darwin

Use Determinate with nix-darwin

If you don’t yet have a nix-darwin configuration, we recommend creating one using one of Determinate Nix’s flake templates:

Generate a nix-darwin configuration using Nix
nix flake init --template "https://flakehub.com/f/DeterminateSystems/flake-templates/0#nix-darwin"

Follow the instructions in the welcome text to get started.

You can use nix-darwin with Determinate without issue provided that you enable Determinate Nix to handle your Nix configuration. There are two ways to do this:

Disable Nix configuration

flake.nix
{ inputs.nix-darwin.url = "https://flakehub.com/f/nix-darwin/nix-darwin/0"; darwinConfigurations.my-system-aarch64-darwin = nix-darwin.lib.darwinSystem { system = "aarch64-darwin"; modules = [ ({ ... }: { # Let Determinate Nix handle Nix configuration nix.enable = false; }) ]; }; }

Use the determinate module

If you use the determinate nix-darwin module, setting determinateNix.enable = true disables nix-darwin’s built-in Nix configuration for you:

flake.nix
{ inputs = { determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/3"; nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0"; nix-darwin = { url = "https://flakehub.com/f/nix-darwin/nix-darwin/0"; inputs.nixpkgs.follows = "nixpkgs"; }; }; darwinConfigurations.my-system-aarch64-darwin = nix-darwin.lib.darwinSystem { system = "aarch64-darwin"; modules = [ inputs.determinate.darwinModules.default ({ ... }: { # Enable the Determinate Nix module determinateNix.enable = true; }) ]; }; }

The determinate module also enables you to configure the Determinate Nix CLI and Determinate Nixd.

In releases of the determinate module prior to 3.15.2, you provided Determinate-Nix-specific configurations using the determinate-nix attribute. In 3.15.2, that has changed to determinateNix, as in the example above. We’ll continue to support the determinate-nix attribute for the next few releases but we recommend making the switch as soon as possible.

Configure the Determinate Nix CLI

You can supply custom Determinate Nix configuration, such as values for trusted-substituters and trusted-public-keys and others, using the /etc/nix/nix.custom.conf file. To set that custom configuration using nix-darwin, you can use the determinateNix.customSettings attribute. Here’s an example:

flake.nix
{ inputs = { determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/3"; nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0"; nix-darwin = { url = "https://flakehub.com/f/nix-darwin/nix-darwin/0"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { determinate, nixpkgs, ... }: { darwinConfigurations."my-username-aarch64-darwin" = inputs.nix-darwin.lib.darwinSystem { inherit system; modules = [ inputs.determinate.darwinModules.default ({ ... }: { determinateNix = { enable = true; # ensure compatibility between nix-darwin and Determinate # Custom settings written to /etc/nix/nix.custom.conf customSettings = { flake-registry = "/etc/nix/flake-registry.json"; }; }; }) ]; }; }; }

Configure Determinate Nixd

You can supply custom configuration for Determinate Nixd using the /etc/determinate/config.json file. To set that custom configuration using nix-darwin, you can use the determinateNix.determinateNixd attribute. Here’s an example:

flake.nix
{ inputs = { determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/3"; nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0"; nix-darwin = { url = "https://flakehub.com/f/nix-darwin/nix-darwin/0"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { determinate, nixpkgs, ... }: { darwinConfigurations."my-username-aarch64-darwin" = inputs.nix-darwin.lib.darwinSystem { inherit system; modules = [ inputs.determinate.darwinModules.default ({ ... }: { determinateNix = { enable = true; # ensure compatibility between nix-darwin and Determinate # Custom settings written to /etc/determinate/config.json determinateNixd = { garbageCollector.strategy = "disabled"; authentication.additionalNetrcSources = [ "/path/to/custom/netrc" ]; }; }; }) ]; }; }; }
Last updated on