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:


<pre>
<syntaxhighlight lang="nix">
{
{
   imports = [
   imports = [
Line 30: Line 30:
   };
   };
}
}
</pre>
</syntaxhighlight>


Another syntax exists for cases where no option declaration are necessary:
Another syntax exists for cases where no option declaration are necessary:


<pre>
<syntaxhighlight lang="nix">
{
{
   require = [
   require = [
Line 42: Line 42:
   # attribute set of option definitions.
   # attribute set of option definitions.
}
}
</pre>
</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:


<pre>
<syntaxhighlight lang="nix">
{config, pkgs, ...}:
{config, pkgs, ...}:


Line 52: Line 52:
   # ...
   # ...
}
}
</pre>
</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.


<pre>
<syntaxhighlight lang="nix">
{config, pkgs, ...}:
{config, pkgs, ...}:


Line 74: Line 74:
   # ...
   # ...
}
}
</pre>
</syntaxhighlight>


== References ==
== References ==