nixos-config/users/README.adoc
2021-11-29 17:56:24 +08:00

1.7 KiB
Raw Blame History

Table of Contents

This is where user-specific configurations comes in. Ideally, the configurations are home-manager config. The configs should assume to be used as a configuration as .config/nixpkgs/home.nix (i.e., home-manager.lib.homeManagerConfiguration, home-manager.users.${user}, in your ordinary home-manager setup in a foreign distro).

Heres an example of a sample user config placed in users/hello.nix.

{ config, options, pkgs, lib, ... }:

{
  programs.home-manager.enable = true;
  programs.direnv.enable = true;
  home.file.".npmrc".source = ./config/npmrc;
}

This is to be imported to homeManagerConfiguration in the flake outputs and when indicated from config.modules.users.users (e.g., modules.users.users = [ "hello" ];).

Modules

There are also user modules (in ./modules) that are imported to use with home-manager, allowing you to extend it as you wish. It works just like home-manager modules.

For easier identification, it should be stored with modules as the top-level attribute (e.g., modules.alacritty, modules.i18n).

Heres an example user module that simply ports my Alacritty config.

{ config, options, lib, pkgs, ... }:

let
  cfg = config.modules.alacritty;
in
{
  options.modules.alacritty.enable = lib.mkEnableOption "Ports my Alacritty configuration.";

  config = lib.mkIf cfg.enable {
    home.packages = with pkgs; [ alacritty ];
    xdg.configFile."alacritty" = {
      source = ../config/alacritty
      recursive = true;
    };
  };
}