2023-07-08 14:27:43 +00:00
---
title: Declarative user management
---
= Declarative user management
2023-12-18 10:03:18 +00:00
Similarly to xref:../01-declarative-host-management/index.adoc[Declarative host management], this project also provides a way to declare home-manager users.
2023-12-23 12:32:08 +00:00
The `./setups/home-manager.nix` sits in the project root expecting certain data.
Similar to the declarative NixOS setup, it expects an attribute set of users with each representing one of the users from github:{github-repo}[`./users/home-manager/`, path=./users/home-manager/, rev=master].
2023-07-08 14:27:43 +00:00
These are then included as part of `homeConfigurations` for easier installation with the standalone home-manager tool.
Of which they are then included as part of deploy nodes for deploy-rs (also for easier deployment).
Here's an example user with complete schema.
.A user with complete schema
2023-12-23 12:32:08 +00:00
[source, nix]
2023-07-08 14:27:43 +00:00
----
2023-12-23 12:32:08 +00:00
{
foo-dogsquared = {
systems = [ "x86_64-linux" ];
nixpkgs-channel = "nixos-stable";
home-manager-channel = "home-manager-23.05";
home-directory = "/home/foo-dogsquared";
username = "foodogsquared";
modules = [
({ config, lib, ... }: {
services.foo.enable = true;
})
];
deploy = {
hostname = "local.foodogsquared.one";
ssh-user = "admin";
profile = "foodogsquared";
fast-connection = true;
auto-rollback = true;
magic-rollback = true;
remote-build = true;
};
};
}
2023-07-08 14:27:43 +00:00
----
2023-08-01 05:32:27 +00:00
- `systems` contains a list of platforms of the home-manager user.
2023-07-08 14:27:43 +00:00
This is mainly used to indicate the platform used for the nixpkgs repository.
2023-08-02 15:00:09 +00:00
- `nixpkgs-channel` indicates the branch of the nixpkgs to be used.
By default, this uses the `nixpkgs` which follows the `nixos-unstable` branch.
2023-07-08 14:27:43 +00:00
- `home-manager-channel` contains the home-manager channel to be used.
The value should be one of the home-manager channel that is imported into this flake.
By default, it sets the home-manager channel at `home-manager` which is pointed at the unstable channel.
- `home-directory` is the associated home directory of the home-manager.
It is set for `config.home.directory` at the home-manager configuration.
By default, it will be set at `/home/$USERNAME`.
- `username` is the username of the home-manager user to be used for `config.home.username` at the home-manager configuration.
If unset, it will use the table key.
In the above example, the unset value would be `foo-dogsquared`.
2023-12-23 12:32:08 +00:00
- `modules` is an extra list of modules to be imported with the configuration.
2023-07-08 14:27:43 +00:00
- `deploy` is pretty similar to the previous configuration setting that it sets certain options for deploy-rs.