2021-08-01 21:38:52 +00:00
|
|
|
> ##### _Note:_
|
2023-01-28 20:49:10 +00:00
|
|
|
>
|
|
|
|
> This section and its semantics need a conceptiual rework.
|
2021-08-01 21:38:52 +00:00
|
|
|
> Since recently [portable home configurations][portableuser]
|
|
|
|
> that are not bound to any specific host are a thing.
|
|
|
|
|
2021-02-14 02:38:20 +00:00
|
|
|
# Users
|
|
|
|
|
2021-04-19 02:26:27 +00:00
|
|
|
Users are a special case of [profiles](profiles.md) that define system
|
2021-02-14 02:38:20 +00:00
|
|
|
users and [home-manager][home-manager] configurations. For your convenience,
|
|
|
|
home manager is wired in by default so all you have to worry about is declaring
|
|
|
|
your users. For a fully fleshed out example, check out the developers personal
|
2021-02-18 01:31:33 +00:00
|
|
|
[branch](https://github.com/divnix/devos/tree/nrd/users/nrd/default.nix).
|
2021-02-14 02:38:20 +00:00
|
|
|
|
|
|
|
## Basic Usage
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-02-14 02:38:20 +00:00
|
|
|
`users/myuser/default.nix`:
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-02-14 02:38:20 +00:00
|
|
|
```nix
|
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
users.users.myuser = {
|
|
|
|
isNormalUser = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
home-manager.users.myuser = {
|
|
|
|
programs.mpv.enable = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2021-03-23 14:44:57 +00:00
|
|
|
## Home Manager
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-06-03 19:25:06 +00:00
|
|
|
Home Manager support follows the same principles as regular nixos configurations,
|
|
|
|
it even gets its own namespace in your `flake.nix` as `home`.
|
|
|
|
|
2021-04-19 02:26:27 +00:00
|
|
|
All modules defined in [user modules][modules-list] will be imported to
|
2021-06-03 19:25:06 +00:00
|
|
|
Home Manager.
|
|
|
|
User profiles can be collected in a similar fashion as system ones into a `suites`
|
|
|
|
argument that gets passed to your home-manager users.
|
|
|
|
|
|
|
|
### Example
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-10-04 15:54:27 +00:00
|
|
|
`flake.nix`
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-06-03 19:25:06 +00:00
|
|
|
```nix
|
|
|
|
{
|
2021-10-04 15:54:27 +00:00
|
|
|
home.users.nixos = { suites, ... }: {
|
2021-06-03 19:25:06 +00:00
|
|
|
imports = suites.base;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-02-14 02:38:20 +00:00
|
|
|
## External Usage
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-02-14 02:38:20 +00:00
|
|
|
You can easily use the defined home-manager configurations outside of NixOS
|
2022-08-13 19:34:46 +00:00
|
|
|
using the `homeConfigurations` flake output.
|
2021-02-14 02:38:20 +00:00
|
|
|
|
2022-08-13 19:34:46 +00:00
|
|
|
This is great for keeping your environment consistent across Unix-like systems,
|
|
|
|
including macOS.
|
2021-02-14 02:38:20 +00:00
|
|
|
|
|
|
|
### From within the projects devshell:
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-02-14 02:38:20 +00:00
|
|
|
```sh
|
2022-08-13 19:34:46 +00:00
|
|
|
# builds the pub-solar user defined in the PubSolarOS host
|
|
|
|
nix build '.#homeConfigurations."pub-solar@PubSolarOS".activationPackage'
|
2021-02-14 02:38:20 +00:00
|
|
|
|
|
|
|
# build and activate
|
2022-08-13 19:34:46 +00:00
|
|
|
nix build '.#homeConfigurations."pub-solar@PubSolarOS".activationPackage' && ./result/activate && unlink result
|
2021-02-14 02:38:20 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Manually from outside the project:
|
2023-01-28 20:49:10 +00:00
|
|
|
|
2021-02-14 02:38:20 +00:00
|
|
|
```sh
|
|
|
|
# build
|
2021-03-23 14:37:11 +00:00
|
|
|
nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPackage"
|
2021-02-14 02:38:20 +00:00
|
|
|
|
|
|
|
# activate
|
|
|
|
./result/activate && unlink result
|
|
|
|
```
|
|
|
|
|
|
|
|
[home-manager]: https://nix-community.github.io/home-manager
|
2021-10-09 16:17:42 +00:00
|
|
|
[modules-list]: https://github.com/divnix/devos/tree/main/users/modules/module-list.nix
|
2021-08-01 21:38:52 +00:00
|
|
|
[portableuser]: https://digga.divnix.com/api-reference-home.html#homeusers
|