fix: multi profile home manager

This commit is contained in:
Tine 2024-03-21 20:37:29 +01:00
parent 2c8dca6d5c
commit 6a45865a78
No known key found for this signature in database
4 changed files with 33 additions and 24 deletions

View file

@ -1,4 +1,4 @@
#/bin/env bash
#!/bin/env bash
set -euo pipefail
REPO_DIR=$(dirname $(readlink -f $0))
@ -45,6 +45,7 @@ while [[ $# -gt 0 ]]; do
;;
esac
done
echo_header "== DotFiles with GUI: $GUI and ENV: $ENVIRONMENT"
# Install basic packages.
# Most other packages are installed via Home Manager.
@ -143,11 +144,14 @@ fi
echo_header "==[host] Installing Home Manager"
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
NIXPKGS_ALLOW_UNFREE=1 ENVIRONMENT=$ENVIRONMENT nix-shell '<home-manager>' -A install
echo_header "==[host] Installing Home Manager packages"
workspace_link nix/home.nix .config/home-manager/home.nix
NIXPKGS_ALLOW_UNFREE=1 DOTFILES_ENV=$ENVIRONMENT home-manager switch
workspace_link nix/core.nix .config/home-manager/core.nix
workspace_link nix/personal.nix .config/home-manager/personal.nix
workspace_link nix/work.nix .config/home-manager/work.nix
NIXPKGS_ALLOW_UNFREE=1 ENVIRONMENT=$ENVIRONMENT home-manager switch
echo_header "==[host] Use zsh as default shell"
sudo chsh $USER --shell=/bin/zsh
@ -155,5 +159,6 @@ sudo chsh $USER --shell=/bin/zsh
echo_header "==[host] Plug for neovim"
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
nvim --headless +'PlugInstall --sync' +qa
nvim --headless +'PlugUpdate --sync' +qa
nvim --headless +PlugInstall +qa
nvim --headless +PlugUpdate +qa
nvim --headless +PlugUpgrade +qa

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ lib, config, pkgs, ... }:
{
# This value determines the Home Manager release that your configuration is
@ -66,6 +66,9 @@
# Kubernetes
k9s
kubectl
# Gnome
gnomeExtensions.pop-shell
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
@ -88,6 +91,11 @@
};
};
programs.gh = {
enable = true;
gitCredentialHelper.enable = true;
};
programs.git = {
enable = true;
userName = "Tine";
@ -96,6 +104,10 @@
difftastic.enable = true;
lfs.enable = true;
includes = [
{ path = "~/.gitconfig.local"; }
];
extraConfig = {
user = {
signingkey = "~/.ssh/id_ed25519";
@ -109,8 +121,8 @@
format = "ssh";
};
credentials = {
helper = "libsecret";
credential = {
helper = "secretservice";
};
init = {

View file

@ -1,21 +1,11 @@
{ config, pkgs, home, ... }:
with import <nixpkgs> { };
with lib;
let
environment = builtins.getEnv "DOTFILES_ENV";
environment = builtins.getEnv "ENVIRONMENT";
in
{
imports =
if environment != "" then
if environment == "personal" then
lib.info "loading PERSONAL home manager environment"
[ ./core.nix ./personal.nix ]
else
if environment == "work" then
lib.info "loading WORK home manager environment"
[ ./core.nix ./work.nix ]
else
lib.warn "DOTFILES_ENV is not one of 'personal' or 'work', ONLY core home environment will be available!" [ ]
else
lib.warn "DOTFILES_ENV not specified, ONLY core home environment will be available!" [ ];
if environment == "work"
then [ ./core.nix ./work.nix ]
else [ ./core.nix ./personal.nix ];
}

View file

@ -1,6 +1,8 @@
{ config, pkgs, ... }:
{ lib, config, pkgs, ... }:
{
home.username = "tine";
home.homeDirectory = "/home/tine";
programs.git.extraConfig.user.signingkey = lib.mkForce "~/.ssh/id_rsa";
}