Restructure home-manager config

This commit is contained in:
ItsDrike 2024-03-24 13:18:51 +01:00
parent 019372838b
commit b4acb6e15f
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
6 changed files with 138 additions and 151 deletions

View file

@ -4,11 +4,6 @@ let
username = config.myOptions.system.username; username = config.myOptions.system.username;
in in
{ {
imports = [
./packages
./programs
];
home-manager = lib.mkIf myHmConf.enabled { home-manager = lib.mkIf myHmConf.enabled {
# Use verbose mode for home-manager # Use verbose mode for home-manager
verbose = true; verbose = true;
@ -31,13 +26,23 @@ in
extraSpecialArgs = { inherit inputs self; }; extraSpecialArgs = { inherit inputs self; };
users.${username} = { users.${username} = {
# Let home-manager manage itself in standalone mode # These imports will be scoped under this key so all settings
programs.home-manager.enable = true; # in them will be added to `home-manager.users.${username}`..
imports = [
./packages
./programs
];
home = { config = {
inherit username; # Let home-manager manage itself in standalone mode
homeDirectory = "/home/${username}"; programs.home-manager.enable = true;
stateVersion = myHmConf.stateVersion;
# Basic user config
home = {
inherit username;
homeDirectory = "/home/${username}";
stateVersion = myHmConf.stateVersion;
};
}; };
}; };
}; };

View file

@ -1,45 +1,39 @@
{ config, pkgs, lib, ... }: { pkgs, ... }: {
let home.packages = with pkgs; [
username = config.myOptions.system.username; fzf # fuzzy finder
in jq # JSON processor
{ zip # compression/archiver for creating .zip files
home-manager.users.${username} = { unzip # extraction util for .zip files
home.packages = with pkgs; [ file # show type of file
fzf # fuzzy finder rsync # incremental file transfer util
jq # JSON processor btop # system monitor
zip # compression/archiver for creating .zip files hyperfine # benchmarker
unzip # extraction util for .zip files delta # git delta viewer
file # show type of file gnupg # encryption
rsync # incremental file transfer util bc # GNU calculator
btop # system monitor mediainfo # shows tags/info about video/audio files
hyperfine # benchmarker usbutils # tools for working with usb devices (like lsusb)
delta # git delta viewer hexyl # hex viewer
gnupg # encryption strace # linux system call tracer
bc # GNU calculator yt-dlp # media downloader
mediainfo # shows tags/info about video/audio files glow # markdown renderer
usbutils # tools for working with usb devices (like lsusb) xdg-ninja # check $HOME for unwanted files
hexyl # hex viewer nettools # Various tools for controlling the network
strace # linux system call tracer dnsutils # DNS utilities
yt-dlp # media downloader dig # DNS utilities
glow # markdown renderer curl # CLI tool for transfering data with URLs
xdg-ninja # check $HOME for unwanted files
nettools # Various tools for controlling the network
dnsutils # DNS utilities
dig # DNS utilities
curl # CLI tool for transfering data with URLs
# Rust replacements # Rust replacements
procs # better ps procs # better ps
ripgrep # better grep ripgrep # better grep
fd # better find fd # better find
du-dust # better du du-dust # better du
bat # better cat bat # better cat
# Development # Development
gcc # GNU C compiler gcc # GNU C compiler
cmake # build system generator cmake # build system generator
meson # C/C++ build system meson # C/C++ build system
gh # GitHub CLI tool gh # GitHub CLI tool
]; ];
};
} }

View file

@ -1,64 +1,60 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
username = config.myOptions.system.username;
inherit (lib.meta) getExe getExe'; inherit (lib.meta) getExe getExe';
in in
{ {
home-manager.users.${username} = { programs.zsh.shellAliases = {
programs.zsh.shellAliases = { # I'm not the greatest typist
# I'm not the greatest typist sl = "ls";
sl = "ls"; mdkir = "mkdir";
mdkir = "mkdir"; soruce = "source";
soruce = "source"; suod = "sudo";
suod = "sudo"; sduo = "sudo";
sduo = "sudo";
# Directory changing # Directory changing
".." = "cd .."; ".." = "cd ..";
"..." = "cd ../../"; "..." = "cd ../../";
"...." = "cd ../../../"; "...." = "cd ../../../";
"....." = "cd ../../../../"; "....." = "cd ../../../../";
".2" = "cd ../../"; ".2" = "cd ../../";
".3" = "cd ../../../"; ".3" = "cd ../../../";
".4" = "cd ../../../../"; ".4" = "cd ../../../../";
".5" = "cd ../../../../../"; ".5" = "cd ../../../../../";
# Files/Directories utilities # Files/Directories utilities
fcd = "cd $(find -type d | fzf)"; fcd = "cd $(find -type d | fzf)";
mkdir = "mkdir -p"; mkdir = "mkdir -p";
md = "mkdir"; md = "mkdir";
fhere = "find . -name"; fhere = "find . -name";
rr = "rm -r"; rr = "rm -r";
rf = "rm -f"; rf = "rm -f";
rrf = "rm -rf"; rrf = "rm -rf";
vimdiff = "nvim -d"; vimdiff = "nvim -d";
# Directory listing aliases # Directory listing aliases
ls = "ls --color=auto"; ls = "ls --color=auto";
l = "ls -lahX --classify"; l = "ls -lahX --classify";
ll = "ls -lahX --classify --group-directories-first"; ll = "ls -lahX --classify --group-directories-first";
ldir = "ls -lahX --classify | grep --color=never ^d"; ldir = "ls -lahX --classify | grep --color=never ^d";
dotall = "ls -lahXd .[a-z]*"; dotall = "ls -lahXd .[a-z]*";
dotfiles = "dotall | grep -v ^d"; dotfiles = "dotall | grep -v ^d";
dotdirs = "dotall | grep --color=never ^d"; dotdirs = "dotall | grep --color=never ^d";
# File validation and manipulation # File validation and manipulation
yamlcheck = "${getExe pkgs.python3} -c 'import sys, yaml as y; y.safe_load(open(sys.argv[1]))'"; # Validate YAML yamlcheck = "${getExe pkgs.python3} -c 'import sys, yaml as y; y.safe_load(open(sys.argv[1]))'"; # Validate YAML
jsoncheck = "${getExe pkgs.jq} "." >/dev/null <"; # Validate JSON jsoncheck = "${getExe pkgs.jq} "." >/dev/null <"; # Validate JSON
urlencode = "${getExe pkgs.python3} -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.argv[1]));'"; # Encode strings as URLs (space->%20, etc.) urlencode = "${getExe pkgs.python3} -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.argv[1]));'"; # Encode strings as URLs (space->%20, etc.)
mergepdf = "${getExe pkgs.gnostscript} -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf"; # Usage: `mergepdf input{1,2,3}.pdf`` mergepdf = "${getExe pkgs.gnostscript} -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf"; # Usage: `mergepdf input{1,2,3}.pdf``
encrypt = "${getExe pkgs.gnupg} -c --no-symkey-cache --cipher-algo AES256"; # Encrypt file with AES256 symetric encryption encrypt = "${getExe pkgs.gnupg} -c --no-symkey-cache --cipher-algo AES256"; # Encrypt file with AES256 symetric encryption
# Get global IP address by querying opendns directly # Get global IP address by querying opendns directly
# (much better than using some random "what is my ip" service) # (much better than using some random "what is my ip" service)
# <https://unix.stackexchange.com/a/81699> # <https://unix.stackexchange.com/a/81699>
canihazip = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short"; canihazip = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short";
canihazip4 = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short -4"; canihazip4 = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short -4";
canihazip6 = "${getExe pkgs.dig} @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6"; canihazip6 = "${getExe pkgs.dig} @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6";
# Expand aliases from sudo # Expand aliases from sudo
sudo = "sudo "; sudo = "sudo ";
};
}; };
} }

View file

@ -1,18 +1,10 @@
{ config, pkgs, ... }: { config, pkgs, ... }: {
let
username = config.myOptions.system.username;
hmCfg = config.home-manager.users.${username};
in
{
imports = [ imports = [
./plugins.nix ./plugins.nix
./aliases.nix ./aliases.nix
]; ];
programs.zsh.enable = true; config = {
users.users.${username}.shell = pkgs.zsh;
home-manager.users.${username} = {
programs.zsh = { programs.zsh = {
enable = true; enable = true;
dotDir = ".config/zsh"; dotDir = ".config/zsh";
@ -25,7 +17,7 @@ in
share = true; share = true;
# don't clutter $HOME # don't clutter $HOME
path = "${hmCfg.xdg.dataHome}/zsh/zsh_history"; path = "${config.xdg.dataHome}/zsh/zsh_history";
# save timestamps to histfile # save timestamps to histfile
extended = true; extended = true;

View file

@ -1,41 +1,37 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
username = config.myOptions.system.username;
inherit (pkgs) fetchFromGitHub; inherit (pkgs) fetchFromGitHub;
in in
{ {
programs.zsh.plugins = [
home-manager.users.${username} = { {
programs.zsh.plugins = [ name = "zsh-nix-shell";
{ src = pkgs.zsh-nix-shell;
name = "zsh-nix-shell"; file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
src = pkgs.zsh-nix-shell; }
file = "share/zsh-nix-shell/nix-shell.plugin.zsh"; {
} name = "zsh-vi-mode";
{ src = pkgs.zsh-vi-mode;
name = "zsh-vi-mode"; file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh";
src = pkgs.zsh-vi-mode; }
file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"; {
} name = "fast-syntax-highlighting";
{ src = "${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions";
name = "fast-syntax-highlighting"; }
src = "${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions"; {
} name = "zsh-autosuggestions";
{ src = pkgs.zsh-autosuggestions;
name = "zsh-autosuggestions"; file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh";
src = pkgs.zsh-autosuggestions; }
file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh"; {
} name = "zsh-autopair";
{ file = "zsh-autopair.plugin.zsh";
name = "zsh-autopair"; src = fetchFromGitHub {
file = "zsh-autopair.plugin.zsh"; owner = "hlissner";
src = fetchFromGitHub { repo = "zsh-autopair";
owner = "hlissner"; rev = "2ec3fd3c9b950c01dbffbb2a4d191e1d34b8c58a";
repo = "zsh-autopair"; hash = "sha256-Y7fkpvCOC/lC2CHYui+6vOdNO8dNHGrVYTGGNf9qgdg=";
rev = "2ec3fd3c9b950c01dbffbb2a4d191e1d34b8c58a"; };
hash = "sha256-Y7fkpvCOC/lC2CHYui+6vOdNO8dNHGrVYTGGNf9qgdg="; }
}; ];
}
];
};
} }

View file

@ -1,9 +1,12 @@
{ config, lib, ... }: with lib; let { config, lib, pkgs, ... }: with lib; let
cfg = config.myOptions.system; cfg = config.myOptions.system;
in in
{ {
networking.hostName = cfg.hostname; networking.hostName = cfg.hostname;
# Default shell for the user
programs.zsh.enable = true;
users = { users = {
# Prevent mutating users outside of our configurations. # Prevent mutating users outside of our configurations.
# TODO: Solve this, currentry it fails with no password # TODO: Solve this, currentry it fails with no password
@ -15,6 +18,7 @@ in
users.${cfg.username} = { users.${cfg.username} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
shell = pkgs.zsh;
}; };
}; };
} }