-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from djacu/lesson/intro-to-types
Added a lesson on basic nixos module option types.
- Loading branch information
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{...}: { | ||
config = { | ||
exBool = true; | ||
exInt = 42; | ||
exEnum = "left"; | ||
exStr = "hello"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
let | ||
pkgs = import <nixpkgs> {}; | ||
inherit (pkgs) lib; | ||
in | ||
#lib.generators.toPretty | ||
#{} | ||
( | ||
pkgs.lib.evalModules { | ||
modules = [ | ||
./options.nix | ||
./config.nix | ||
]; | ||
} | ||
) | ||
.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Basic Types | ||
|
||
In this lesson, we will cover some basic types. | ||
There are certainly [many more types][nixos-manual-basic-types], but for this lesson, we will focus on just a few. | ||
|
||
Notice in the [options][options] file, we have declared boolean, enumeration, integer, and string options. | ||
|
||
[//]: # (./options.nix) | ||
|
||
Notice in the [config][config] file, we have declared values for all these options. | ||
|
||
[//]: # (./config.nix) | ||
|
||
If you execute the run file (`./run`), you should see an output that matches what we have configured. | ||
|
||
[nixos-manual-basic-types]: https://nixos.org/manual/nixos/stable/#sec-option-types | ||
[options]: ./options.nix | ||
[config]: ./config.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{lib, ...}: let | ||
inherit (lib) types; | ||
in { | ||
options = { | ||
exBool = lib.mkOption { | ||
type = types.bool; | ||
description = "My example boolean."; | ||
}; | ||
exEnum = lib.mkOption { | ||
type = types.enum ["left" "right"]; | ||
description = "My example enumeration."; | ||
}; | ||
exInt = lib.mkOption { | ||
type = types.int; | ||
description = "My example integer."; | ||
}; | ||
exStr = lib.mkOption { | ||
type = types.str; | ||
description = "My example string."; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nix eval -f eval.nix --json | nix run nixpkgs#jq -- . |