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

View file

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

View file

@ -1,64 +1,60 @@
{ config, pkgs, lib, ... }:
let
username = config.myOptions.system.username;
inherit (lib.meta) getExe getExe';
in
{
home-manager.users.${username} = {
programs.zsh.shellAliases = {
# I'm not the greatest typist
sl = "ls";
mdkir = "mkdir";
soruce = "source";
suod = "sudo";
sduo = "sudo";
programs.zsh.shellAliases = {
# I'm not the greatest typist
sl = "ls";
mdkir = "mkdir";
soruce = "source";
suod = "sudo";
sduo = "sudo";
# Directory changing
".." = "cd ..";
"..." = "cd ../../";
"...." = "cd ../../../";
"....." = "cd ../../../../";
".2" = "cd ../../";
".3" = "cd ../../../";
".4" = "cd ../../../../";
".5" = "cd ../../../../../";
# Directory changing
".." = "cd ..";
"..." = "cd ../../";
"...." = "cd ../../../";
"....." = "cd ../../../../";
".2" = "cd ../../";
".3" = "cd ../../../";
".4" = "cd ../../../../";
".5" = "cd ../../../../../";
# Files/Directories utilities
fcd = "cd $(find -type d | fzf)";
mkdir = "mkdir -p";
md = "mkdir";
fhere = "find . -name";
rr = "rm -r";
rf = "rm -f";
rrf = "rm -rf";
vimdiff = "nvim -d";
# Files/Directories utilities
fcd = "cd $(find -type d | fzf)";
mkdir = "mkdir -p";
md = "mkdir";
fhere = "find . -name";
rr = "rm -r";
rf = "rm -f";
rrf = "rm -rf";
vimdiff = "nvim -d";
# Directory listing aliases
ls = "ls --color=auto";
l = "ls -lahX --classify";
ll = "ls -lahX --classify --group-directories-first";
ldir = "ls -lahX --classify | grep --color=never ^d";
dotall = "ls -lahXd .[a-z]*";
dotfiles = "dotall | grep -v ^d";
dotdirs = "dotall | grep --color=never ^d";
# Directory listing aliases
ls = "ls --color=auto";
l = "ls -lahX --classify";
ll = "ls -lahX --classify --group-directories-first";
ldir = "ls -lahX --classify | grep --color=never ^d";
dotall = "ls -lahXd .[a-z]*";
dotfiles = "dotall | grep -v ^d";
dotdirs = "dotall | grep --color=never ^d";
# File validation and manipulation
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
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``
encrypt = "${getExe pkgs.gnupg} -c --no-symkey-cache --cipher-algo AES256"; # Encrypt file with AES256 symetric encryption
# File validation and manipulation
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
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``
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
# (much better than using some random "what is my ip" service)
# <https://unix.stackexchange.com/a/81699>
canihazip = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short";
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";
# Get global IP address by querying opendns directly
# (much better than using some random "what is my ip" service)
# <https://unix.stackexchange.com/a/81699>
canihazip = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short";
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";
# Expand aliases from sudo
sudo = "sudo ";
};
# Expand aliases from sudo
sudo = "sudo ";
};
}

View file

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

View file

@ -1,41 +1,37 @@
{ config, pkgs, ... }:
let
username = config.myOptions.system.username;
inherit (pkgs) fetchFromGitHub;
in
{
home-manager.users.${username} = {
programs.zsh.plugins = [
{
name = "zsh-nix-shell";
src = pkgs.zsh-nix-shell;
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
}
{
name = "zsh-vi-mode";
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 = "zsh-autosuggestions";
src = pkgs.zsh-autosuggestions;
file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh";
}
{
name = "zsh-autopair";
file = "zsh-autopair.plugin.zsh";
src = fetchFromGitHub {
owner = "hlissner";
repo = "zsh-autopair";
rev = "2ec3fd3c9b950c01dbffbb2a4d191e1d34b8c58a";
hash = "sha256-Y7fkpvCOC/lC2CHYui+6vOdNO8dNHGrVYTGGNf9qgdg=";
};
}
];
};
programs.zsh.plugins = [
{
name = "zsh-nix-shell";
src = pkgs.zsh-nix-shell;
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
}
{
name = "zsh-vi-mode";
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 = "zsh-autosuggestions";
src = pkgs.zsh-autosuggestions;
file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh";
}
{
name = "zsh-autopair";
file = "zsh-autopair.plugin.zsh";
src = fetchFromGitHub {
owner = "hlissner";
repo = "zsh-autopair";
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;
in
{
networking.hostName = cfg.hostname;
# Default shell for the user
programs.zsh.enable = true;
users = {
# Prevent mutating users outside of our configurations.
# TODO: Solve this, currentry it fails with no password
@ -15,6 +18,7 @@ in
users.${cfg.username} = {
isNormalUser = true;
extraGroups = [ "wheel" ];
shell = pkgs.zsh;
};
};
}