Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commite2accca5d7e77898cb3f5bcceea4af04be6d6f92 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-03-09 15:46:31 +0200
Committer
 Syndamia <kamen@syndamia.com>
2024-03-09 15:46:31 +0200
Files6ee6d3b05e7700a386bb4560464259668f566128
syndamia.com-blog/your-first-nixos-config.tar
syndamia.com-blog/your-first-nixos-config.tar.gz
syndamia.com-blog/your-first-nixos-config.zip
Parent44c5067285c5130dbc5926618fba8384813ac615 (diff)
(blog/yfno) Started explaining modules blog/your-first-nixos-config
1 files changed, 29 insertions, 0 deletions
-rw-r--r--src/blog/your-first-nixos-config/index.md29
diff --git a/src/blog/your-first-nixos-config/index.md b/src/blog/your-first-nixos-config/index.md
index 3b41fcf..4e2f750 100644
--- a/src/blog/your-first-nixos-config/index.md
+++ b/src/blog/your-first-nixos-config/index.md
@@ -398,5 +398,34 @@ These are the "bigger" building blocks with which you would build a configuratio
## NixOS configurations
+Since the Nix language allows for many different ways to represent data, NixOS has settled on the idea of [modules](https://nixos.wiki/wiki/NixOS_modules): attribute sets (or functions) with a set of properties:
+
+```nix
+{
+ imports = [ ];
+ options = { };
+ config = { };
+}
+```
+
+`imports` is a list of paths to files, containing other modules, which will be included in your system.
+`options` is an attrset, containing names of external ways to configure this module.
+`config` is another attrset, containing the definitions of those external configuration names.
+The last two aren't really important for now and they can all be left out.
+
+For our purposes, the functional layout is more relevat.
+A module could also be a simple function, returning the aforementioned attrset, but also taking another attribute set, with at least four values:
+
+```nix
+{ config, options, pkgs, modulesPath, ... }:
+{
+ imports = [ ];
+ options = { };
+ config = { };
+}
+```
+
+NixOS takes all of your modules and then combines them.
+
[^grub]: In reality, if literally everything is different between those configurations, you would probably need to reboot and chose from your bootloader, but that's not significant now.
[^attrset-values]: You could also have each element on a separate line, with leading (or trailing) spaces/tabs.