1
1
mirror of https://github.com/divnix/digga.git synced 2024-12-18 05:31:30 +03:00
digga/doc/concepts/users.md
2022-01-10 23:21:52 -08:00

2.1 KiB

Note:

This section and its semantics need a conceptiual rework. Since recently portable home configurations that are not bound to any specific host are a thing.

Users

Users are a special case of profiles that define system users and 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 branch.

Basic Usage

users/myuser/default.nix:

{ ... }:
{
  users.users.myuser = {
    isNormalUser = true;
  };

  home-manager.users.myuser = {
    programs.mpv.enable = true;
  };
}

Home Manager

Home Manager support follows the same principles as regular nixos configurations, it even gets its own namespace in your flake.nix as home.

All modules defined in user modules will be imported to 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

flake.nix

{
  home.users.nixos = { suites, ... }: {
    imports = suites.base;
  };
}

External Usage

You can easily use the defined home-manager configurations outside of NixOS using the homeConfigurations flake output. The bud helper script makes this even easier.

This is great for keeping your environment consistent across Unix systems, including OSX.

From within the projects devshell:

# builds the nixos user defined in the NixOS host
bud home NixOS nixos

# build and activate
bud home NixOS nixos switch

Manually from outside the project:

# build
nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPackage"

# activate
./result/activate && unlink result