2021-11-29 09:56:24 +00:00
= Host-specific configuration
:toc:
2022-07-09 06:04:17 +00:00
These are NixOS configurations that are specific to a machine (e.g., desktop, servers, VMs, containers, installation media).
2021-11-29 09:56:24 +00:00
Ideally, it should be made minimal as much as possible considering you also have to manage your users.
2021-12-21 06:29:27 +00:00
== Integrating with custom modules
2024-01-16 07:01:59 +00:00
The host configurations placed here most likely use the link:../../modules/nixos[custom NixOS modules].
The custom modules shouldn't be imported manually from the host as this is already taken care of from the link:../../flake.nix[flake definition].
2021-12-21 06:29:27 +00:00
2024-01-16 07:01:59 +00:00
It is best practice to assume the host configurations make use of the link:../modules/nixos[custom NixOS modules], link:../../pkgs[custom packages], and the flake inputs.
In other words, always pay attention to link:../../flake.nix[`../../flake.nix`].
2021-12-21 06:29:27 +00:00
== User management
2021-11-29 09:56:24 +00:00
For managing users, there are multiple ways to manage them with this config:
* The usual `users.users.${user}` from system configuration (see `man configuration.nix.5`).
2024-01-16 07:01:59 +00:00
* If you intend to import users from the link:./_users[`./_users`], you can simply import them through `imports` in the system module.
2021-12-21 06:29:27 +00:00
+
2022-09-19 02:56:06 +00:00
--
2024-01-16 07:01:59 +00:00
For a convenient option, there is the function `getUser` defined from the link:../../lib/private.nix[private custom library].
2021-12-21 06:29:27 +00:00
You can use it as follows:
2022-09-19 02:56:06 +00:00
2021-12-21 06:29:27 +00:00
[source, nix]
----
2023-12-24 10:36:06 +00:00
imports = [
(lib.private.getUser "nixos" "foo-dogsquared")
(lib.private.getUser "nixos" "polaski")
];
2021-12-21 06:29:27 +00:00
----
2022-09-19 02:56:06 +00:00
--
2024-01-16 07:01:59 +00:00
* You could also easily map link:../home-manager[one of my home-manager configurations] into one of the users for a NixOS system with `lib.private.mapHomeManagerUser` which accepts two arguments: a name from of the home-manager user folder and the user config as if configuration with `users.users.<name>`.
2022-09-19 02:56:06 +00:00
+
--
Here's an example to easily get my main home-manager config to be one of the users of the system.
[source, nix]
----
2024-01-16 07:01:59 +00:00
lib.private.mapHomeManagerUser "foo-dogsquared" {
2022-09-19 02:56:06 +00:00
extraGroups = [ "audio" "docker" ];
password = "what";
createHome = true;
home = "/home/foo-dogsquared";
}
----
--