# 使用 home-manager 管理用户配置
# 安装
- 添加对应 channel
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
如果用的是稳定版 Nixpkgs, 需要把 channel 换到对应分支, 比如 22.05 对应 https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz
nix-shell '<home-manager>' -A install
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "rewine";
home.homeDirectory = "/home/rewine";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "22.11";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.emacs = {
enable = true;
extraPackages = epkgs: [
epkgs.nix-mode
epkgs.magit
];
};
services.gpg-agent = {
enable = true;
defaultCacheTtl = 1800;
enableSshSupport = true;
};
}
https://github.com/nix-community/home-manager/issues/2848
# 使用 flake
{
description = "Home Manager configuration of Jane Doe";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
homeConfigurations.rewine = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [
./home.nix
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
};
}