From 6ce8b4264e1cf6ace857f3f5d79058fab6078c91 Mon Sep 17 00:00:00 2001 From: GRMrGecko Date: Thu, 16 May 2024 00:13:09 -0500 Subject: [PATCH] Get home-manager configurations working --- dotfiles | 1 + flake.nix | 1 + install.sh | 2 +- modules/home/profiles/desktop.nix | 8 +++++ modules/home/profiles/gaming-pc.nix | 7 +++++ modules/home/zsh.nix | 49 +++++++++++++++++++++++++++++ modules/nixos/common.nix | 4 +++ modules/nixos/desktop.nix | 3 ++ modules/nixos/users.nix | 1 + rebuild.sh | 2 +- update.sh | 2 +- users/main-user.nix | 7 ++++- users/root.nix | 23 ++++++++++++++ 13 files changed, 106 insertions(+), 4 deletions(-) create mode 160000 dotfiles create mode 100644 modules/home/profiles/desktop.nix create mode 100644 modules/home/profiles/gaming-pc.nix create mode 100644 users/root.nix diff --git a/dotfiles b/dotfiles new file mode 160000 index 0000000..3c00685 --- /dev/null +++ b/dotfiles @@ -0,0 +1 @@ +Subproject commit 3c006855689bcaeb401e2b52c979ce4c57cd8fd5 diff --git a/flake.nix b/flake.nix index 049ded5..b4dc7e7 100644 --- a/flake.nix +++ b/flake.nix @@ -76,6 +76,7 @@ homeConfigurations = { ${settings.user.name} = mkHome ./users/main-user.nix; + "root" = mkHome ./users/root.nix; }; }; } diff --git a/install.sh b/install.sh index 320f926..333e39f 100755 --- a/install.sh +++ b/install.sh @@ -11,7 +11,7 @@ if [[ -n $nixHostOverride ]]; then fi # Confirm host configuration is available; If not, we should not continue. -if ! grep -q "nixosConfigurations.$host" flake.nix; then +if ! grep -q "nixosConfigurations.$host " flake.nix; then host="default" fi diff --git a/modules/home/profiles/desktop.nix b/modules/home/profiles/desktop.nix new file mode 100644 index 0000000..d4bed37 --- /dev/null +++ b/modules/home/profiles/desktop.nix @@ -0,0 +1,8 @@ +{pkgs, settings, ...}: + +{ + home.file = { + ".config/mpv".source = ../../../dotfiles/.config/mpv; + ".config/polybar".source = ../../../dotfiles/.config/polybar; + }; +} \ No newline at end of file diff --git a/modules/home/profiles/gaming-pc.nix b/modules/home/profiles/gaming-pc.nix new file mode 100644 index 0000000..7b8e717 --- /dev/null +++ b/modules/home/profiles/gaming-pc.nix @@ -0,0 +1,7 @@ +{pkgs, settings, ...}: + +{ + imports = [ + ./desktop.nix + ]; +} \ No newline at end of file diff --git a/modules/home/zsh.nix b/modules/home/zsh.nix index 3232a7f..2c22f38 100644 --- a/modules/home/zsh.nix +++ b/modules/home/zsh.nix @@ -1,8 +1,57 @@ {pkgs, settings, ...}: { + home.file = { + ".config/zsh/plugins/zsh-autosuggestions".source = "${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions"; + ".config/zsh/plugins/fast-syntax-highlighting".source = "${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions"; + ".config/zsh/plugins/nix-zsh-completions".source = "${pkgs.nix-zsh-completions}/share/zsh/plugins/nix"; + ".config/zsh/plugins/pure".source = "${pkgs.pure-prompt}/share/zsh/site-functions"; + ".config/zsh/functions".source = ../../dotfiles/.config/zsh/functions; + ".config/zsh/keybinds.zsh".source = ../../dotfiles/.config/zsh/keybinds.zsh; + }; + programs.zsh = { enable = true; dotDir = ".config/zsh"; + envExtra = '' + export EDITOR="vim" + export TERMINAL="konsole" + export TERM="konsole" + export BROWSER="firefox" + export VIDEO="mpv" + export OPENER="xdg-open" + ''; + initExtra = '' + # Set emacs key binding. + bindkey -e + + # Import functions. + source "$ZDOTDIR/functions" + + # Set custom key bindings. + zsh_add_config keybinds.zsh + + # Configure pure-prompt. + export PURE_PROMPT_SYMBOL="$" + if [ "$USER" = "root" ]; then + export PURE_PROMPT_SYMBOL="#" + fi + export PROMPT_PURE_SSH_CONNECTION=YES + zsh_fpath_plugin sindresorhus/pure + autoload -U promptinit; promptinit + zstyle :prompt:pure:user color cyan + zstyle :prompt:pure:host color white + zstyle ':prompt:pure:prompt:*' color white + prompt pure + + # Add extra plugins. + zsh_add_plugin zdharma-continuum/fast-syntax-highlighting + + ZSH_AUTOSUGGEST_STRATEGY=(history completion) + zsh_add_plugin zsh-users/zsh-autosuggestions + + # Show off the system. + ${pkgs.fastfetch}/bin/fastfetch + ''; }; } \ No newline at end of file diff --git a/modules/nixos/common.nix b/modules/nixos/common.nix index d9fc2e4..d1f257e 100644 --- a/modules/nixos/common.nix +++ b/modules/nixos/common.nix @@ -91,6 +91,10 @@ # Nix Package Auto Cleanup nix = { settings.auto-optimise-store = true; + optimise = { + automatic = true; + dates = [ "03:45" ]; + }; gc = { automatic = true; dates = "weekly"; diff --git a/modules/nixos/desktop.nix b/modules/nixos/desktop.nix index 0fc4de7..caf57e2 100644 --- a/modules/nixos/desktop.nix +++ b/modules/nixos/desktop.nix @@ -67,6 +67,9 @@ vlc kdePackages.k3b + # Desktop + polybar + # Software defined radio gqrx ]; diff --git a/modules/nixos/users.nix b/modules/nixos/users.nix index bc9447d..7c6284b 100644 --- a/modules/nixos/users.nix +++ b/modules/nixos/users.nix @@ -45,6 +45,7 @@ }; users = { ${settings.user.name} = import ../../users/main-user.nix; + "root" = import ../../users/root.nix; }; }; } diff --git a/rebuild.sh b/rebuild.sh index b679c18..188795c 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -11,7 +11,7 @@ if [[ -n $nixHostOverride ]]; then fi # Confirm host configuration is available; If not, we should not continue. -if ! grep -q "nixosConfigurations.$host" flake.nix; then +if ! grep -q "nixosConfigurations.$host " flake.nix; then host="default" fi diff --git a/update.sh b/update.sh index 7e2223b..ae8cf2b 100755 --- a/update.sh +++ b/update.sh @@ -11,7 +11,7 @@ if [[ -n $nixHostOverride ]]; then fi # Confirm host configuration is available; If not, we should not continue. -if ! grep -q "nixosConfigurations.$host" flake.nix; then +if ! grep -q "nixosConfigurations.$host " flake.nix; then host="default" fi diff --git a/users/main-user.nix b/users/main-user.nix index 5e0af2a..fdbd3ee 100644 --- a/users/main-user.nix +++ b/users/main-user.nix @@ -4,7 +4,12 @@ imports = [ ../modules/home/git.nix ../modules/home/zsh.nix - ]; + ] ++ (if (builtins.pathExists ../modules/home/profiles/${settings.profile}.nix) + then + [ ../modules/home/profiles/${settings.profile}.nix ] + else + [] + ); home.username = settings.user.name; home.homeDirectory = "/home/${settings.user.name}"; diff --git a/users/root.nix b/users/root.nix new file mode 100644 index 0000000..6010d0c --- /dev/null +++ b/users/root.nix @@ -0,0 +1,23 @@ +{pkgs, settings, ...}: + +{ + imports = [ + ../modules/home/zsh.nix + ]; + + home.username = "root"; + home.homeDirectory = "/root"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "23.11"; +} \ No newline at end of file