restructured user

This commit is contained in:
2025-10-14 00:09:11 -05:00
parent 977d97fc0d
commit ea2be0de28
14 changed files with 11316 additions and 102 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
.keyring/
.nixos-switch-log
users/blake/dotfiles/zsh/zplug
users/blake/dots/zsh/zplug
users/blake/dotfiles/zsh/.zsh_history
users/blake/dotfiles/zsh/.zcompdump

33
hosts/default.nix Normal file
View File

@@ -0,0 +1,33 @@
{
pkgs,
config,
lib,
inputs,
...
}:
{
# passwordless rebuild
security.sudo.extraRules = [
{
users = ["blake"];
commands = [
{
command = "/run/current-system/sw/bin/nixos-rebuild";
options = ["NOPASSWD"];
}
{
command = "/run/current-system/sw/bin/systemctl";
options = ["NOPASSWD"];
}
{
command = "/run/current-system/sw/bin/journalctl";
options = ["NOPASSWD"];
}
{
command = "/run/current-system/sw/bin/tailscale";
options = ["NOPASSWD"];
}
];
}
];
}

View File

@@ -8,7 +8,7 @@ in
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
../../users/users.nix
../../users
../../modules/system
../../modules/homelab
../../modules/homelab/minecraft_recpro

View File

@@ -1,74 +0,0 @@
{ config, lib, pkgs, inputs, ... }:
let
cfg = config.users.blake;
in
{
options.users.blake = {
enable = lib.mkEnableOption "enable blake user";
username = lib.mkOption {
default = "blake";
description = ''
username
'';
};
};
config = lib.mkIf cfg.enable {
# create blake user
users.users.${cfg.username} = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "docker" "media" "podman" "minecraft" ]; # Enable sudo for the user.
uid = 1000;
shell = pkgs.zsh;
group = "blake";
hashedPasswordFile = config.sops.secrets."blake_passwd".path;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBK0AGJfZGyqW8/krvQV+PL7axcDW/EnKyHy9M8wryQx klefki"
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBPdC9cCX8awvA19Ri65fvbYjZYe8X1Ef+nOZAIv92AS6u4SkJYqOvPYfqRHXORNDpbzjTV6nackyCKvV5EO4niv4MFIgdkEQwuVHcYX32/dOsWdDoeXBT/l2sFFM7JESwQ== blake@zygarde"
];
};
# define home-manager user
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
extraSpecialArgs = { inherit inputs; };
users = {
"blake" = import ./home.nix;
};
};
# define blake group
users.groups.blake = {
gid = 1000;
};
# passwordless rebuild
security.sudo.extraRules = [
{
users = [ "blake" ];
commands = [
{
command = "/run/current-system/sw/bin/nixos-rebuild";
options = [ "NOPASSWD" ];
}
{
command = "/run/current-system/sw/bin/systemctl";
options = [ "NOPASSWD" ];
}
{
command = "/run/current-system/sw/bin/journalctl";
options = [ "NOPASSWD" ];
}
{
command = "/run/current-system/sw/bin/tailscale";
options = [ "NOPASSWD" ];
}
];
}
];
};
}

38
users/blake/default.nix Normal file
View File

@@ -0,0 +1,38 @@
{
config,
lib,
pkgs,
inputs,
...
}: {
# create blake user
users.users = {
blake = {
isNormalUser = true;
extraGroups = ["wheel" "networkmanager" "docker" "media" "podman" "minecraft"]; # Enable sudo for the user.
uid = 1000;
shell = pkgs.zsh;
group = "blake";
hashedPasswordFile = config.sops.secrets."blake_passwd".path;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBK0AGJfZGyqW8/krvQV+PL7axcDW/EnKyHy9M8wryQx klefki"
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBPdC9cCX8awvA19Ri65fvbYjZYe8X1Ef+nOZAIv92AS6u4SkJYqOvPYfqRHXORNDpbzjTV6nackyCKvV5EO4niv4MFIgdkEQwuVHcYX32/dOsWdDoeXBT/l2sFFM7JESwQ== blake@zygarde"
];
};
};
# define home-manager user
home-manager = {
extraSpecialArgs = {inherit inputs;};
backupFileExtension = "bak";
useUserPackages = true;
useGlobalPkgs = true;
users = {
"blake" = import ./home.nix;
};
};
nix.settings.trusted-users = ["blake"];
programs.zsh.enable = true;
}

View File

@@ -0,0 +1,20 @@
{
pkgs,
config,
lib,
inputs,
...
}: {
# configure git
programs.git = {
enable = true;
userName = "blake";
userEmail = "me@blakedheld.xyz";
extraConfig = {
init.defaultBranch = "trunk";
core.editor = "nvim";
pull.rebase = true;
push.autoSetupRemote = true;
};
};
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
# home manager envs
. "/etc/profiles/per-user/blake/etc/profile.d/hm-session-vars.sh"
# Only source this once
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then
export __HM_ZSH_SESS_VARS_SOURCED=1
fi

206
users/blake/dots/zsh/.zshrc Normal file
View File

@@ -0,0 +1,206 @@
# blake's zsh config file
# 'source .zshrc' to load the config after editing
# prompt
#PS1='%B%S%F{004}[%n@%m]:%f%s%F{015}%~%f%S%F{004}$%f%s%b '
# blakes prompt
PS1='%F{0}%K{126}%B[%n@%m]%b%k%f:%F{015}%B[%~]%b%f%F{015}%S$%s%f '
# --- defaults ---
export EDITOR=nvim
export PAGER=less
# --- history ---
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.config/zsh/.zsh_history
setopt append_history
setopt inc_append_history
unsetopt share_history
# --- tab complete ---
autoload -Uz compinit && compinit
setopt no_menu_complete
compinit
# --- aliases ---
# zsh
alias cfz='nvim $HOME/.config/zsh/.zshrc'
alias src='source $HOME/.config/zsh/.zshrc'
# config editing
alias cfh='nvim $HOME/.config/hypr/hyprland.conf'
alias cfl='nvim $HOME/.config/lf/lfrc'
# navigation
setopt autocd
set -o vi
alias ls='ls --color=auto --group-directories-first'
alias ll='ls -lh --color=auto --group-directories-first'
alias la='ls -Alh --color=auto --group-directories-first'
alias ..='cd ..'
alias ...='cd ../..'
alias fs='du -h | sort -h'
alias ds='du -hs'
# shortcuts
alias vswap='cd ~/.local/state/nvim/swap'
alias rswap='rm ~/.local/state/nvim/swap/*'
alias tn='lf ~/documents/holocron/notes/tech'
alias nhc='lf ~/documents/holocron/work/nhc'
alias diary='cd ~/documents/holocron/notes/journal/diary'
alias screenies='lf ~/pictures/screenshots'
alias holo='lf ~/documents/holocron'
# safety
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm -Iv'
# colors
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# scripts
alias rebuild='sh ~/.nix/bin/rebuild.sh'
alias perms='sudo sh ~/.nix/bin/perms.sh'
alias bb='sudo sh ~/.nix/bin/backup_browse.sh'
# tools
alias v='nvim'
alias sv='sudo nvim'
alias vim='nvim'
alias wifi='nmtui'
alias bt='bluetuith --no-warning'
alias audio='pulsemixer'
alias img='nsxiv'
alias vid='mpv'
alias pdf='zathura'
alias fw='sudo ufw status verbose'
alias sec='sops ~/.nix/secrets/secrets.yaml'
# git
alias status='git status'
alias add='git add'
alias commit='git commit -am'
alias push='git push'
alias pull='git pull'
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
alias dtf='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
# systemd
alias stat='sudo systemctl status'
alias restart='sudo systemctl restart'
alias start='sudo systemctl start'
alias stop='sudo systemctl stop'
alias jou='sudo journalctl -xeu'
alias live='sudo journalctl -o short-iso -n 50 -fu'
# shortcuts
alias chil='nvim ~/documents/holocron/tech/devices/yveltal/chilton'
alias school='nvim ~/documents/holocron/school/school.md'
# system
alias peace='systemctl poweroff'
alias love='systemctl reboot'
alias lock='loginctl lock-session'
# ssh
alias nebby='ssh nebula'
# wild shit
alias mgdrive='rclone mount gdrive: /media/gdrive --daemon --vfs-cache-mode writes'
alias micloud='rclone mount icloud: /media/icloud --daemon --vfs-cache-mode writes'
alias smp='mcrcon -H 10.0.0.104 -P 25575 -p WoopaGangaRecProGamingPassLmaoJkJk'
alias mcap='sudo umount /media/microsd ; sudo cryptsetup luksClose /dev/mapper/capsule ; sudo cryptsetup luksOpen UUID=a9e81f14-1e74-4777-a37a-81a0a43ae8d9 capsule --key-file ~/.config/cred/capsule.keyfile ; sudo mount -a'
# --- ssh auth sock ---
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
# --- path ---
# Define directories to add to PATH
ADDTOPATHS=(
"$HOME/.local/bin"
"$HOME/.local/bin/timecapsule"
)
for ADDTOPATH in "${ADDTOPATHS[@]}"; do
if [ -d "$ADDTOPATH" ]; then
case ":${PATH}:" in
*:"${ADDTOPATH}":*)
;;
*)
PATH="${PATH}:${ADDTOPATH}"
;;
esac
else
fi
done
export PATH
# --- scripts ---
# make lf change the working directory upon exit
alias lf='lfcd'
lfcd () {cd "$(command lf -print-last-dir "$@")"}
# --- plugins ---
# you really hate the idea of your zshrc auto cloning
# and installling the plugin manager. To do so manually:
# git clone https://github.com/zplug/zplug "$HOME/.config/zsh/zplug"
export ZPLUG_HOME="$HOME/.config/zsh/zplug/" # Change this to your custom directory
if [ -d "$HOME/.config/zsh/zplug" ]; then
export ZPLUG_INSTALLED="1"
source "$HOME/.config/zsh/zplug/init.zsh"
else
if [[ $- == *i* ]]; then
echo "⚠️ zplug is not installed. Run: git clone https://github.com/zplug/zplug $HOME/.config/zsh/zplug"
fi
fi
# init zplug
if [ -n "ZPLUG_INSTALLED" ]; then
zplug "zsh-users/zsh-syntax-highlighting", defer:2
zplug "zsh-users/zsh-history-substring-search"
zplug "zsh-users/zsh-autosuggestions" # Command suggestions as you type
zplug "zsh-users/zsh-completions" # Additional completions for more commands
zplug "olivierverdier/zsh-git-prompt"
zplug load
# install if there are new plugins
if ! zplug check --verbose; then
zplug install
zplug load
fi
fi
# -- syntax highlighting --
# Adjusted zsh-syntax-highlighting colors for red-green color blindness
ZSH_HIGHLIGHT_STYLES[default]=none
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=magenta # (Was red)
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan
ZSH_HIGHLIGHT_STYLES[alias]=fg=blue # (Was green)
ZSH_HIGHLIGHT_STYLES[builtin]=fg=cyan
ZSH_HIGHLIGHT_STYLES[function]=fg=blue # (Was green)
ZSH_HIGHLIGHT_STYLES[command]=fg=blue,bold # (Was green)
ZSH_HIGHLIGHT_STYLES[precommand]=fg=cyan
ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=cyan
ZSH_HIGHLIGHT_STYLES[hashed-command]=fg=blue # (Was green)
ZSH_HIGHLIGHT_STYLES[path]=fg=cyan,underline # This ensures paths are underlined
ZSH_HIGHLIGHT_STYLES[globbing]=fg=cyan
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=magenta # (Was red)
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=cyan
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=white,bold
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=white
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[assign]=fg=cyan
ZSH_HIGHLIGHT_STYLES[comment]=fg=yellow

View File

@@ -0,0 +1,21 @@
{
pkgs,
config,
...
}: {
# just using the normal lfrc
programs.lf = {
enable = false;
};
# install it to userspace
home.packages = with pkgs; [lf ctpv trashy];
# link configs
xdg.configFile."lf/lfrc" = {
source = config.lib.file.mkOutOfStoreSymlink "/home/blake/.nix/users/blake/dots/lf/lfrc";
};
xdg.configFile."ctpv/config" = {
source = config.lib.file.mkOutOfStoreSymlink "/home/blake/.nix/users/blake/dots/lf/ctpv_config";
};
}

Submodule users/blake/dots/zsh/zplug added at ac6c2a3e9e

View File

@@ -1,10 +1,14 @@
{ config, lib, pkgs, inputs, ... }:
{
config,
lib,
pkgs,
inputs,
...
}: {
imports = [
./dots/neovim
./dots/lf
./dots/git
];
# general config
@@ -14,20 +18,19 @@
# stand alone packages
home.packages = with pkgs; [
ripgrep
btop
p7zip
imagemagick
sops
usbutils
ripgrep
btop
p7zip
imagemagick
sops
usbutils
];
# setup zsh
home.sessionVariables.ZDOTDIR = "$HOME/.config/zsh";
programs.zsh = {
enable = true;
# dotDir = ".config/zsh";
# dotDir = ".config/zsh";
};
# link dotfiles
xdg.configFile."zsh" = {
@@ -61,21 +64,22 @@
};
};
# import sshkeys from keyring
home.file.".ssh/id_snowbelle".source = config.lib.file.mkOutOfStoreSymlink /home/blake/.nix/.keyring/ssh/id_snowbelle;
home.file.".ssh/id_snowbelle.pub".source = config.lib.file.mkOutOfStoreSymlink /home/blake/.nix/.keyring/ssh/id_snowbelle.pub;
#home.file.".ssh/id_snowbelle".source = config.lib.file.mkOutOfStoreSymlink /home/blake/.nix/.keyring/ssh/id_snowbelle;
#home.file.".ssh/id_snowbelle.pub".source = config.lib.file.mkOutOfStoreSymlink /home/blake/.nix/.keyring/ssh/id_snowbelle.pub;
# configure git
programs.git = {
enable = true;
userName = "blake";
userEmail = "me@blakedheld.xyz";
extraConfig = {
init.defaultBranch = "trunk";
core.editor = "nvim";
pull.rebase = true;
push.autoSetupRemote = true;
# manage secrets with sops
sops.secrets = {
"id_snowbelle" = {
owner = "blake";
group = "blake";
mode = "0600";
path = "/home/blake/.ssh/id_snowbelle";
};
"id_snowbelle.pub" = {
owner = "blake";
group = "blake";
mode = "644";
path = "/home/blake/.ssh/id_snowbelle.pub";
};
};
};
}

View File

@@ -2,7 +2,7 @@
{
imports = [
./blake/blake.nix
./blake
];
users.blake.enable = lib.mkDefault true;