patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 660a2427447fd9851e60e955da6bd1a5d71cfdac 2595 bytes (raw)
name: lib/config.nix 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>

let
  customConfigPath = builtins.tryEval <spectrum-config>;
in

{ config ?
  if customConfigPath.success then import customConfigPath.value
  else if builtins.pathExists ../config.nix then import ../config.nix
  else {}
}:

let
  default = import ../lib/config.default.nix;

  callConfig = config: if builtins.typeOf config == "lambda" then config {
    inherit default;
  } else config;
  finalConfig = default // callConfig config;

  # Only allow unreserved characters, : (for port numbers), /, and %-encoding.
  # The rest of the code is allowed to assume that these are the only characters
  # in the update URL.
  # Do not use [:alnum:] or [:hexdigit:] as they depend on the locale in POSIX.
  # Query strings and fragment identifiers break appending
  # /SHA256SUMS and /SHA256SUMS.gpg to a URL.
  # [, ], {, and } would cause globbing in curl.
  url-regex = "^https?://([ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:./~-]|%[ABCDEFabcdef0123456789]{2})+$";
  update-url = finalConfig.update-url;

  # Only allow a numeric version for now.
  number_re = "(0|[1-9][0-9]{0,2})";
  version_re = "^(${number_re}\\.){2}${number_re}$";
in
  if !builtins.isString update-url then
    builtins.abort "Update URL must be a string, not ${builtins.typeOf update-url}"
  else if builtins.match "^https?://.*" update-url == null then
    builtins.abort "Update URL ${builtins.toJSON update-url} has unsupported scheme (not https:// or http://) or is invalid"
  else if builtins.match url-regex update-url == null then
    builtins.abort "Update URL ${builtins.toJSON update-url} has forbidden characters"
  else if builtins.substring (builtins.stringLength update-url - 1) 1 update-url == "/" then
    builtins.abort "Update URL ${builtins.toJSON update-url} must not end with /"
  else if !builtins.isString finalConfig.version then
    builtins.abort "Version must be a string, not ${builtins.typeOf finalConfig.version}"
  else if builtins.match version_re finalConfig.version == null then
    builtins.abort "Version ${builtins.toJSON finalConfig.version} is invalid"
  else if !builtins.isPath finalConfig.update-signing-key then
    builtins.abort "Update verification key file is of type ${builtins.typeOf finalConfig.update-signing-key}, not path"
  else
    finalConfig // {
      update-signing-key = builtins.path {
        name = "signing-key";
        path = finalConfig.update-signing-key;
      };
    }

debug log:

solving 660a2427447fd9851e60e955da6bd1a5d71cfdac ...
found 660a2427447fd9851e60e955da6bd1a5d71cfdac in https://inbox.spectrum-os.org/spectrum-devel/20251112-updates-v2-8-88d96bf81b79@gmail.com/
found 5b6b95013734202b7e2e01d5ffce313080658006 in https://inbox.spectrum-os.org/spectrum-devel/20251112-updates-v2-6-88d96bf81b79@gmail.com/
found 01bcfa2bb2d5c412e212f5a60d9032e89c8a7442 in https://inbox.spectrum-os.org/spectrum-devel/20251112-updates-v2-4-88d96bf81b79@gmail.com/
found e437cdbe9aa22dd0f9c8d7052ac331c8fccf6ce6 in https://spectrum-os.org/git/spectrum
preparing index
index prepared:
100644 e437cdbe9aa22dd0f9c8d7052ac331c8fccf6ce6	lib/config.nix

applying [1/3] https://inbox.spectrum-os.org/spectrum-devel/20251112-updates-v2-4-88d96bf81b79@gmail.com/
diff --git a/lib/config.nix b/lib/config.nix
index e437cdbe9aa22dd0f9c8d7052ac331c8fccf6ce6..01bcfa2bb2d5c412e212f5a60d9032e89c8a7442 100644


applying [2/3] https://inbox.spectrum-os.org/spectrum-devel/20251112-updates-v2-6-88d96bf81b79@gmail.com/
diff --git a/lib/config.nix b/lib/config.nix
index 01bcfa2bb2d5c412e212f5a60d9032e89c8a7442..5b6b95013734202b7e2e01d5ffce313080658006 100644


applying [3/3] https://inbox.spectrum-os.org/spectrum-devel/20251112-updates-v2-8-88d96bf81b79@gmail.com/
diff --git a/lib/config.nix b/lib/config.nix
index 5b6b95013734202b7e2e01d5ffce313080658006..660a2427447fd9851e60e955da6bd1a5d71cfdac 100644

Checking patch lib/config.nix...
Applied patch lib/config.nix cleanly.
Checking patch lib/config.nix...
Applied patch lib/config.nix cleanly.
Checking patch lib/config.nix...
Applied patch lib/config.nix cleanly.

index at:
100644 660a2427447fd9851e60e955da6bd1a5d71cfdac	lib/config.nix

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).