You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Introduction to Denix Configurations (Flakes) {#introduction}
2
+
The `delib.configurations` function is used to create lists of `nixosConfigurations` and `homeConfigurations` for flakes.
3
+
4
+
In addition to all hosts, it also adds combinations of each host with every **non-`inheritanceOnly`** rice, which allows for quickly switching between rice configurations without editing the code. For example, if the "desktop" host is set to use the "light" rice, executing the following command:
will use the "desktop" host with the "light" rice. However, if you need to quickly switch to another rice, for example, "dark" you can run the following command:
In this case, the host remains "desktop", but the rice changes to "dark".
17
+
18
+
It is important to note that when switching rice in this way, only the value of the `${myConfigName}.rice` option changes, while the value of `${myConfigName}.hosts.${hostName}.rice` remains the same.
19
+
20
+
## Principle of Configuration List Generation {#principle}
21
+
The configuration list is generated based on the following principle:
22
+
23
+
-`{hostName}` - where `hostName` is the name of any host.
24
+
-`{hostName}-{riceName}` - where `hostName` is the name of any host, and `riceName` is the name of any rice where `inheritanceOnly` is `false`.
25
+
26
+
If `isHomeManager` from the [function arguments](/configurations/structure#function-arguments) is equal to `true`, then a prefix of `{homeManagerUser}@` is added to all configurations in the list.
27
+
28
+
## Example {#example}
29
+
An example of a flake's `outputs` for `nixosConfigurations` and `homeConfigurations`:
-`myconfigName` (string): the category for all Denix module options, hosts, and rices. Default is `myconfig`; changes are not recommended.
5
+
-`denixLibName` (string): the name of the Denix library in `specialArgs` (`{denixLibName, ...}: denixLibName.module { ... }`). Default is `delib`; changes are not recommended.
6
+
-`homeManagerNixpkgs` (nixpkgs): used in the `pkgs` attribute of the `home-manager.lib.homeManagerConfiguration` function in the format: `homeManagerNixpkgs.legacyPackages.${host :: homeManagerSystem}`. By default, it takes `nixpkgs` from the flake.
7
+
-`homeManagerUser` (string): the username, used in `home-manager.users.${homeManagerUser}` and for generating the Home Manager configuration list.
8
+
-`isHomeManager` (boolean): indicates whether to create a configuration list for Home Manager or for NixOS.
9
+
-`paths` (listOf string): paths to be imported; add hosts, rices, and modules here. Default is `[]`.
10
+
-`exclude` (listOf string): paths to be excluded from importing. Default is `[]`.
11
+
-`recursive` (boolean): determines whether to recursively search for paths to import. Default is `true`.
12
+
-`specialArgs` (attrset): `specialArgs` to be passed to `lib.nixosSystem` and `home-manager.lib.homeManagerConfiguration`. Default is `{}`.
13
+
-**EXPERIMENTAL**`extraModules` (list): default is `[]`.
14
+
-**EXPERIMENTAL**`mkConfigurationsSystemExtraModule` (attrset): a module used in the internal NixOS configuration that receives the list of hosts and rices to generate the configuration list. Default is `{nixpkgs.hostPlatform = "x86_64-linux";}`.
Copy file name to clipboardExpand all lines: docs/src/modules/structure.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Structure {#structure}
2
-
This section uses the variables `myconfigName`, `isHomeManager`, and `homeManagerUser`, so it's recommended to first review the corresponding subsection: [delib.system Function Arguments](/TODO).
2
+
This section uses the variables `myconfigName`, `isHomeManager`, and `homeManagerUser`, so it's recommended to first review the corresponding subsection: [delib.configurations Function Arguments](/configurations/structure#function-arguments).
3
3
4
4
## Function Arguments {#function-arguments}
5
5
-`name`{#function-arguments-name}: string. It is recommended that it matches the parent path of the module's `enable` option, such as `"programs.example"`, since the `cfg` argument depends on this path.
Copy file name to clipboardExpand all lines: docs/src/rices/introduction.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The term "rice" in slang refers to system settings, usually related to appearanc
6
6
However, rices are not mandatory: to avoid using them, simply do not add the options `${myconfigName}.rices` and `${myconfigName}.rice`, and do not use the `delib.rice` function.
7
7
8
8
## Inheritance {#inheritance}
9
-
A rice can inherit all configurations of another rice via the `inherits` attribute. Additionally, you can set `inheritanceOnly = true;`, which will hide the rice from being generated in [`delib.system`](/TODO), leaving it only for inheritance.
9
+
A rice can inherit all configurations of another rice via the `inherits` attribute. Additionally, you can set `inheritanceOnly = true;`, which will hide the rice from being generated in [`delib.configurations`](/configurations/introduction), leaving it only for inheritance.
10
10
11
11
Example of three rices, where the first two inherit all configurations from the "rounded" rice:
Copy file name to clipboardExpand all lines: docs/src/rices/structure.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
## Function Arguments {#function-arguments}
4
4
-`name`: a string representing the rice name.
5
5
-`inherits`: a list of strings - the names of rices whose configurations will be inherited by the current rice.
6
-
-`inheritanceOnly`: a boolean value that determines whether this rice will be added to the [list of systems generated for each host and rice](/TODO), or if it is only used for inheritance.
6
+
-`inheritanceOnly`: a boolean value that determines whether this rice will be added to the [list of systems generated for each host and rice](/configurations/introduction), or if it is only used for inheritance.
7
7
-`myconfig`: sets its value to `config.${myconfigName}` if `config.${myconfigName}.rice` matches the current rice.
8
8
-`nixos`: sets its value to `config` if `isHomeManager` is `false` and `config.${myconfigName}.rice` matches the current rice.
9
9
-`home`: sets its value to `config` if `isHomeManager` is `true` and `config.${myconfigName}.rice` matches the current rice. Otherwise, if `config.${myconfigName}.rice` matches the current rice, sets its value to `config.home-manager.users.${homeManagerUser}`.
# Введение в конфигурации Denix (флейки) {#introduction}
2
+
Функция `delib.configurations` используется для создания списков `nixosConfigurations` и `homeConfigurations` для флейков.
3
+
4
+
Помимо всех хостов, она также добавляет комбинации каждого хоста с каждым **не `inheritanceOnly`** райсом, что позволяет быстро переключаться между райсами без редактирования кода. Например, если у хоста "desktop" задан райс "light", то при выполнении следующей команды:
будет использован хост "desktop" с райсом "light". Однако, если необходимо быстро переключиться на другой райс, например, на "dark", можно выполнить следующую команду:
В этом случае хост останется "desktop", но райс изменится на "dark".
17
+
18
+
Важно отметить, что при смене райса таким образом меняется только значение опции `${myConfigName}.rice`, при этом значение `${myconfigName}.hosts.${hostName}.rice` остаётся прежним.
19
+
20
+
## Принцип генерации списка конфигураций {#principle}
21
+
Список конфигураций генерируется по следующему принципу:
22
+
23
+
-`{hostName}` - где `hostName` - имя любого хоста.
24
+
-`{hostName}-{riceName}` - где `hostName` - имя любого хоста, а `riceName` - имя любого райса, у которого `inheritanceOnly` равно `false`.
25
+
26
+
Если `isHomeManager` из [аргументов функции](/ru/configurations/structure#function-arguments) равен `true`, то ко всем конфигурациям в списке добавляется префикс` {homeManagerUser}@`.
27
+
28
+
## Пример {#example}
29
+
Пример `outputs` флейка для `nixosConfigurations` и `homeConfigurations`:
-`myconfigName` (string): категория для всех опций модулей Denix, хостов и райсов. По умолчанию `myconfig`; изменять не рекомендуется.
5
+
-`denixLibName` (string): имя библиотеки Denix в `specialArgs` (`{denixLibName, ...}: denixLibName.module { ... }`). По умолчанию `delib`; изменять не рекомендуется.
6
+
-`homeManagerNixpkgs` (nixpkgs): используется в атрибуте `pkgs` функции `home-manager.lib.homeManagerConfiguration` в формате: `homeManagerNixpkgs.legacyPackages.${host :: homeManagerSystem}`. По умолчанию берется `nixpkgs` из флейка.
7
+
-`homeManagerUser` (string): имя пользователя, используется в `home-manager.users.${homeManagerUser}` и для генерации списка конфигураций Home Manager.
8
+
-`isHomeManager` (boolean): указывает, создавать ли список конфигураций для Home Manager или для NixOS.
9
+
-`paths` (listOf string): пути, которые будут импортированы; добавьте сюда хосты, райсы и модули. По умолчанию `[]`.
10
+
-`exclude` (listOf string): пути, которые будут исключены из импортирования. По умолчанию `[]`.
11
+
-`recursive` (boolean): определяет, следует ли рекурсивно искать пути для импортирования. По умолчанию `true`.
12
+
-`specialArgs` (attrset): `specialArgs`, которые будут переданы в `lib.nixosSystem` и `home-manager.lib.homeManagerConfiguration`. По умолчанию `{}`.
13
+
-**EXPERIMENTAL**`extraModules` (list): по умолчанию `[]`.
14
+
-**EXPERIMENTAL**`mkConfigurationsSystemExtraModule` (attrset): модуль, используемый во внутренней конфигурации NixOS, который получает список хостов и райсов для генерации списка конфигураций. По умолчанию `{nixpkgs.hostPlatform = "x86_64-linux";}`.
Copy file name to clipboardExpand all lines: docs/src/ru/modules/structure.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Структура {#structure}
2
-
В этом разделе будут использованы переменные `myconfigName`, `isHomeManager` и `homeManagerUser`, поэтому рекомендуется предварительно ознакомиться с соответствующим подразделом: [Аргументы delib.system](/TODO).
2
+
В этом разделе будут использованы переменные `myconfigName`, `isHomeManager` и `homeManagerUser`, поэтому рекомендуется предварительно ознакомиться с соответствующим подразделом: [Аргументы delib.configurations](/ru/configurations/structure#function-arguments).
3
3
4
4
## Аргументы функции {#function-arguments}
5
5
-`name`{#function-arguments-name}: строка. Рекомендуется, чтобы она совпадала с родительским путём опции `enable` модуля, например, `"programs.example"`, так как передаваемый аргумент `cfg` зависит именно от этого пути.
Copy file name to clipboardExpand all lines: docs/src/ru/rices/introduction.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
При этом райсы не являются обязательными - если вы не хотите их использовать, просто не добавляйте опции `${myconfigName}.rices` и `${myconfigName}.rice`, а также не вызывайте функцию `delib.rice`.
7
7
8
8
## Наследование {#inheritance}
9
-
Райс может наследовать все конфигурации другого райса через атрибут `inherits`. Кроме того, можно установить `inheritanceOnly = true;`, чтобы скрыть райс от генерации в [`delib.system`](/TODO), оставив его только для наследования.
9
+
Райс может наследовать все конфигурации другого райса через атрибут `inherits`. Кроме того, можно установить `inheritanceOnly = true;`, чтобы скрыть райс от генерации в [`delib.configurations`](/ru/configurations/introduction), оставив его только для наследования.
10
10
11
11
Пример трех райсов, где первые два наследуют все конфигурации райса "rounded":
0 commit comments