config.nix: add optional docPrefix

Makes it possible to render it in the NixOS manual,
as that one does not contain the Nixpkgs manual specific ones.
This commit is contained in:
jopejoe1
2026-04-23 12:34:11 +02:00
committed by Johannes Kirschbauer
parent cbcbede8e0
commit 2e8702164b
+13 -8
View File
@@ -6,9 +6,14 @@
# nix-build -A tests.config
#
{ config, lib, ... }:
{
config,
lib,
...
}@args:
let
docPrefix = args.docPrefix or "";
inherit (lib)
literalExpression
mapAttrsToList
@@ -115,13 +120,13 @@ let
gitConfig = mkOption {
type = types.attrsOf (types.attrsOf types.anything);
description = ''
The default [git configuration](https://git-scm.com/docs/git-config#_variables) for all [`pkgs.fetchgit`](#fetchgit) calls.
The default [git configuration](https://git-scm.com/docs/git-config#_variables) for all [`pkgs.fetchgit`](${docPrefix}#fetchgit) calls.
Among many other potential uses, this can be used to override URLs to point to local mirrors.
Changing this will not cause any rebuilds because `pkgs.fetchgit` produces a [fixed-output derivation](https://nix.dev/manual/nix/stable/glossary.html?highlight=fixed-output%20derivation#gloss-fixed-output-derivation).
To set the configuration file directly, use the [`gitConfigFile`](#opt-gitConfigFile) option instead.
To set the configuration file directly, use the [`gitConfigFile`](${docPrefix}#opt-gitConfigFile) option instead.
To set the configuration file for individual calls, use `fetchgit { gitConfigFile = "..."; }`.
'';
@@ -135,9 +140,9 @@ let
gitConfigFile = mkOption {
type = types.nullOr types.path;
description = ''
A path to a [git configuration](https://git-scm.com/docs/git-config#_variables) file, to be used for all [`pkgs.fetchgit`](#fetchgit) calls.
A path to a [git configuration](https://git-scm.com/docs/git-config#_variables) file, to be used for all [`pkgs.fetchgit`](${docPrefix}#fetchgit) calls.
This overrides the [`gitConfig`](#opt-gitConfig) option, see its documentation for more details.
This overrides the [`gitConfig`](${docPrefix}#opt-gitConfig) option, see its documentation for more details.
'';
default =
if config.gitConfig != { } then
@@ -155,7 +160,7 @@ let
For example, an override like `"registry.npmjs.org" = "my-mirror.local/registry.npmjs.org"` will replace a URL like `https://registry.npmjs.org/foo.tar.gz` with `https://my-mirror.local/registry.npmjs.org/foo.tar.gz`.
To set the string directly, see [`npmRegistryOverridesString`](#opt-npmRegistryOverridesString).
To set the string directly, see [`npmRegistryOverridesString`](${docPrefix}#opt-npmRegistryOverridesString).
'';
default = { };
example = {
@@ -174,7 +179,7 @@ let
description = ''
A string containing a string with a JSON representation of npm registry overrides for `fetchNpmDeps`.
This overrides the [`npmRegistryOverrides`](#opt-npmRegistryOverrides) option, see its documentation for more details.
This overrides the [`npmRegistryOverrides`](${docPrefix}#opt-npmRegistryOverrides) option, see its documentation for more details.
'';
default = builtins.toJSON config.npmRegistryOverrides;
};
@@ -412,7 +417,7 @@ let
type = types.listOf types.str;
default = [ "https://tarballs.nixos.org" ];
description = ''
The set of content-addressed/hashed mirror URLs used by [`pkgs.fetchurl`](#sec-pkgs-fetchers-fetchurl).
The set of content-addressed/hashed mirror URLs used by [`pkgs.fetchurl`](${docPrefix}#sec-pkgs-fetchers-fetchurl).
In case `pkgs.fetchurl` can't download from the given URLs,
it will try the hashed mirrors based on the expected output hash.