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 set -euo pipefail
REPO_DIR=$(dirname $(readlink -f $0)) REPO_DIR=$(dirname $(readlink -f $0))
@ -45,6 +45,7 @@ while [[ $# -gt 0 ]]; do
;; ;;
esac esac
done done
echo_header "== DotFiles with GUI: $GUI and ENV: $ENVIRONMENT"
# Install basic packages. # Install basic packages.
# Most other packages are installed via Home Manager. # Most other packages are installed via Home Manager.
@ -143,11 +144,14 @@ fi
echo_header "==[host] Installing Home Manager" echo_header "==[host] Installing Home Manager"
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update 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" echo_header "==[host] Installing Home Manager packages"
workspace_link nix/home.nix .config/home-manager/home.nix 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" echo_header "==[host] Use zsh as default shell"
sudo chsh $USER --shell=/bin/zsh sudo chsh $USER --shell=/bin/zsh
@ -155,5 +159,6 @@ sudo chsh $USER --shell=/bin/zsh
echo_header "==[host] Plug for neovim" echo_header "==[host] Plug for neovim"
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ 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' https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
nvim --headless +'PlugInstall --sync' +qa nvim --headless +PlugInstall +qa
nvim --headless +'PlugUpdate --sync' +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 # This value determines the Home Manager release that your configuration is
@ -66,6 +66,9 @@
# Kubernetes # Kubernetes
k9s k9s
kubectl kubectl
# Gnome
gnomeExtensions.pop-shell
]; ];
# Home Manager is pretty good at managing dotfiles. The primary way to manage # 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 = { programs.git = {
enable = true; enable = true;
userName = "Tine"; userName = "Tine";
@ -96,6 +104,10 @@
difftastic.enable = true; difftastic.enable = true;
lfs.enable = true; lfs.enable = true;
includes = [
{ path = "~/.gitconfig.local"; }
];
extraConfig = { extraConfig = {
user = { user = {
signingkey = "~/.ssh/id_ed25519"; signingkey = "~/.ssh/id_ed25519";
@ -109,8 +121,8 @@
format = "ssh"; format = "ssh";
}; };
credentials = { credential = {
helper = "libsecret"; helper = "secretservice";
}; };
init = { init = {

View file

@ -1,21 +1,11 @@
{ config, pkgs, home, ... }: { config, pkgs, home, ... }:
with import <nixpkgs> { };
with lib;
let let
environment = builtins.getEnv "DOTFILES_ENV"; environment = builtins.getEnv "ENVIRONMENT";
in in
{ {
imports = imports =
if environment != "" then if environment == "work"
if environment == "personal" then then [ ./core.nix ./work.nix ]
lib.info "loading PERSONAL home manager environment" else [ ./core.nix ./personal.nix ];
[ ./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!" [ ];
} }

View file

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