Skip to main content

Home Manager Setup

Manage user environments with Home Manager

Manage personal configuration files and profiles with Home Manager, similar to the way that system configuration is performed, but don't require users to have root access.

This is a work in progress.

TODO

  • Optimize path when first installing via nix-shell

Make sure NixOS can handle Nix Flakes and nix-command

# /etc/nixos/configuration.nix

  nix = {
    package = pkgs.nixFlakes;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';
  };

As the user add home manager channel

nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager
nix-channel --update

Logout and log back in to install

nix-shell '<home-manager>' -A install

This will create a default configuration flie at ~/.config/home-manager/home.nix. Clone a repository into the folder like so.

rm -rf ~/.config/home-manager
git clone https://github.com/tiredofit/home.git ~/.config/home-manager

If no repo, there should be at the very least the following:

# ~.config/home-manager/flake.nix

{
  description = "Tired of I.T! Home Manager NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
    home-manager.url = "github:nix-community/home-manager/release-23.05";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };
  
  outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, home-manager, ... }:
    {
      homeConfigurations = {
        dave = inputs.home-manager.lib.homeManagerConfiguration {
          system = "x86_64-linux";
          homeDirectory = "/home/dave";
          username = "dave";
          stateVersion = "23.05";
          configuration = { config, pkgs, ... }:
            in
            {
              nixpkgs.overlays = [ ];
              nixpkgs.config = {
                allowUnfree = true;
                allowBroken = true;
              };

              imports = [
                ./home.nix
              ];
            };
        };
      };
          dave = self.homeConfigurations.dave.activationPackage;
          defaultPackage.x86_64-linux = self.dave;
    };
}

# ~/.config/home-manager/home.nix

{ config, pkgs, ... }:

{

  imports = [
  home = {

  home = {
    packages = with pkgs; [
      ]))
    ];
  };

  programs = {
    home-manager.enable = true;
    };
  };

}

Activate Home Manager

home-manager switch --flake ~/.config/nixpkgs/#dave -v

Keeping things up to date

Update Repository changes

nix flake update ~/.config/home-manager