= Configuring the Build
:page-nav_order: 1
:example-caption: Test

// SPDX-FileCopyrightText: 2022 Unikie
// SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is>
// SPDX-License-Identifier: GFDL-1.3-no-invariants-or-later OR CC-BY-SA-4.0

Some aspects of a Spectrum build can be customised using a build
configuration file.

By default, this configuration file should be called config.nix and located in
the root of the Spectrum source tree, but this can be overridden by setting
`spectrum-config` in the
https://nixos.org/manual/nix/stable/command-ref/env-common.html#env-NIX_PATH[NIX_PATH]
to the path of the configuration file.

The configuration file should contain an attribute set.  See
https://spectrum-os.org/git/spectrum/tree/lib/config.default.nix[lib/config.default.nix]
for supported configuration attributes and their default values.

To enable updates, you need to specify a version, an update URL, and an update signing key.
By default, the update URL is set to a .invalid domain and the update signing key is
an invalid key.  Therefore, updates will not work.  To enable updates, provide a valid key
and update server URL.

Spectrum uses https://www.freedesktop.org/software/systemd/man/latest/systemd-sysupdate.html[systemd-sysupdate],
so see the https://www.freedesktop.org/software/systemd/man/latest/sysupdate.d.html[sysupdate.d]
documentation for what you need to put on your server.  Building
https://spectrum-os.org/git/spectrum/tree/release/updates.nix[release/updates.nix] produces an
directory that is compatible with systemd-sysupdate, except that the signature
(`SHA256SUMS.sha256.asc`) is missing.

Updates are signed, so the worst a compromised update
server can do is fill up your user data partition.

.config.nix to build Spectrum with a https://nixos.org/manual/nixpkgs/unstable/#sec-overlays-definition[Nixpkgs overlay]
[example]
[source,nix]
----
{ default, ... }:

{
  pkgsArgs = default.pkgsArgs // {
    overlays = [
      (final: super: {
        weston = super.weston.overrideAttrs ({ patches ? [], ... }: {
          patches = patches ++ [
            path/to/weston.patch
          ];
        });
      })
    ] ++ default.pkgsArgs.overlays or [];
  };
}
----
