NixOS modules: Difference between revisions
imported>Makefu No edit summary |
imported>Fadenb m Syntax highlighting |
||
Line 16: | Line 16: | ||
Modules are declared with the following syntax: | Modules are declared with the following syntax: | ||
< | <syntaxhighlight lang="nix"> | ||
{ | { | ||
imports = [ | imports = [ | ||
Line 30: | Line 30: | ||
}; | }; | ||
} | } | ||
</ | </syntaxhighlight> | ||
Another syntax exists for cases where no option declaration are necessary: | Another syntax exists for cases where no option declaration are necessary: | ||
< | <syntaxhighlight lang="nix"> | ||
{ | { | ||
require = [ | require = [ | ||
Line 42: | Line 42: | ||
# attribute set of option definitions. | # attribute set of option definitions. | ||
} | } | ||
</ | </syntaxhighlight> | ||
Both of the previous syntax can be refined with an attribute set argument added on top: | Both of the previous syntax can be refined with an attribute set argument added on top: | ||
< | <syntaxhighlight lang="nix"> | ||
{config, pkgs, ...}: | {config, pkgs, ...}: | ||
Line 52: | Line 52: | ||
# ... | # ... | ||
} | } | ||
</ | </syntaxhighlight> | ||
The following arguments can be retrieved from this attribute set: | The following arguments can be retrieved from this attribute set: | ||
Line 64: | Line 64: | ||
More computation or organisation can be necessary to enhance modules. In which case, you can add a <code>let .. in ..</code> statement between the argument and the attribute set. | More computation or organisation can be necessary to enhance modules. In which case, you can add a <code>let .. in ..</code> statement between the argument and the attribute set. | ||
< | <syntaxhighlight lang="nix"> | ||
{config, pkgs, ...}: | {config, pkgs, ...}: | ||
Line 74: | Line 74: | ||
# ... | # ... | ||
} | } | ||
</ | </syntaxhighlight> | ||
== References == | == References == |