NixOS:config argument: Difference between revisions

imported>Fadenb
No edit summary
Raf (talk | contribs)
m changed instances of pkgs.lib to more commonly available lib
 
(2 intermediate revisions by 2 users not shown)
Line 6: Line 6:


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


{
{
   options = {
   options = {
     foo = pkgs.lib.mkOption {
     foo = lib.mkOption {
       description = "...";
       description = "...";
     };
     };
Line 30: Line 30:


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


{
{
   options = {
   options = {
     foo = pkgs.lib.mkOption {
     foo = lib.mkOption {
       default = false;
       default = false;
       type = with pkgs.lib.types; bool;
       type = with lib.types; bool;
       description = "enable foo";
       description = "foo boolean option";
     };
     };
   };
   };
Line 59: Line 59:


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


{
{
   options = {
   options = {
     foo = pkgs.lib.mkOption {
     foo = lib.mkOption {
       default = false;
       default = false;
       type = with pkgs.lib.types; bool;
       type = with lib.types; bool;
       description = "enable foo";
       description = "foo boolean";
     };
     };
   };
   };


   config = pkgs.lib.mkIf config.foo {
   config = lib.mkIf config.foo {
     bar = 42;
     bar = 42;
   };
   };
Line 81: Line 81:


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


let
let
Line 89: Line 89:
in
in


with pkgs.lib; {
with lib; {
   options = {
   options = {
     foo.bar.baz = {
     foo.bar.baz = {
Line 105: Line 105:
</syntaxhighlight>
</syntaxhighlight>


[[Category:Discussion]]
[[Category:Reference]]
[[Category:NixOS]]