From 68047c894e0694043030ffc34c1b77798aade522 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Thu, 27 Mar 2025 04:12:43 +0800 Subject: [PATCH] refactor: clean up home --- configs/programs/default.nix | 3 +- configs/programs/editorconfig.nix | 23 ++++++++ configs/security.nix | 5 ++ configs/users.nix | 97 ++++++++++++------------------- flake.nix | 2 - 5 files changed, 67 insertions(+), 63 deletions(-) create mode 100644 configs/programs/editorconfig.nix diff --git a/configs/programs/default.nix b/configs/programs/default.nix index 2e36a6a..d2f479d 100644 --- a/configs/programs/default.nix +++ b/configs/programs/default.nix @@ -3,9 +3,9 @@ ./ags.nix ./clipse.nix ./comma.nix - ./zsh.nix ./direnv.nix ./dunst.nix + ./editorconfig.nix ./firefox.nix ./fuzzel.nix ./fzf.nix @@ -23,5 +23,6 @@ ./yazi.nix ./zellij.nix ./zoxide.nix + ./zsh.nix ]; } diff --git a/configs/programs/editorconfig.nix b/configs/programs/editorconfig.nix new file mode 100644 index 0000000..986d7ff --- /dev/null +++ b/configs/programs/editorconfig.nix @@ -0,0 +1,23 @@ +{ + home-manager.users.rafiq = { + editorconfig = { + enable = true; + settings = { + "*" = { + end_of_line = "lf"; + insert_final_newline = true; + trim_trailing_whitespace = true; + charset = "utf-8"; + indent_style = "space"; + indent_size = 2; + }; + "package.json" = { + indent_style = "unset"; + }; + "*.lock" = { + indent_size = "unset"; + }; + }; + }; + }; +} diff --git a/configs/security.nix b/configs/security.nix index 0ae8e0a..298f595 100644 --- a/configs/security.nix +++ b/configs/security.nix @@ -1,4 +1,9 @@ +{ inputs, ... }: { + imports = [ + inputs.sops-nix.nixosModules.sops + ]; + sops = { defaultSopsFile = ./secrets/secrets.yaml; age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; diff --git a/configs/users.nix b/configs/users.nix index e3c6cd7..8bfba46 100644 --- a/configs/users.nix +++ b/configs/users.nix @@ -6,17 +6,23 @@ ... }: { + imports = [ + inputs.home-manager.nixosModules.home-manager + ./scripts + ./programs + ]; + home-manager = { useGlobalPkgs = true; useUserPackages = true; extraSpecialArgs = specialArgs; }; - users.mutableUsers = false; # Always reset users on system activation - time.timeZone = "Asia/Singapore"; i18n.defaultLocale = "en_SG.UTF-8"; + users.mutableUsers = false; # Always reset users on system activation + users.users.rafiq = { isNormalUser = true; description = "rafiq"; @@ -29,66 +35,37 @@ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n" ]; }; - imports = [ - ./scripts - ./programs - ]; - home-manager.users.rafiq.imports = [ - { - # This enables using home-manager from the command line. - programs.home-manager.enable = true; + home-manager.users.rafiq = { + home = { + username = "rafiq"; + homeDirectory = "/home/rafiq"; - editorconfig = { - enable = true; - settings = { - "*" = { - end_of_line = "lf"; - insert_final_newline = true; - trim_trailing_whitespace = true; - charset = "utf-8"; - indent_style = "space"; - indent_size = 2; - }; - "package.json" = { - indent_style = "unset"; - }; - "*.lock" = { - indent_size = "unset"; - }; - }; + # This defines the version home-manager + # was originally bulit against on this system. + # Do not change it. + stateVersion = "25.05"; + + shell.enableShellIntegration = true; + shellAliases = { + gs = "git status"; + ai = "aichat -r %shell% -e"; + cd = "z"; + list-all-packages = "nix-store --query --requisites /run/current-system | cut -d- -f2- | sort | uniq"; }; - home = { - username = "rafiq"; - homeDirectory = "/home/rafiq"; - - # This defines the version home-manager - # was originally bulit against on this system. - # Do not change it. - stateVersion = "25.05"; - - shell.enableShellIntegration = true; - shellAliases = { - gs = "git status"; - ai = "aichat -r %shell% -e"; - cd = "z"; - list-all-packages = "nix-store --query --requisites /run/current-system | cut -d- -f2- | sort | uniq"; - }; - - packages = with pkgs; [ - aichat # duh - bat - btop # add settings as home-manager module - devenv - fastfetch # system info - hyprpicker - inputs.hyprcloser.packages.${pkgs.stdenv.hostPlatform.system}.default - ripgrep - ttyper - wl-clipboard # provides cli copy and paste commands - ]; - }; - } - ]; + packages = with pkgs; [ + aichat # duh + bat + btop # add settings as home-manager module + devenv + fastfetch # system info + hyprpicker + inputs.hyprcloser.packages.${pkgs.stdenv.hostPlatform.system}.default + ripgrep + ttyper + wl-clipboard # provides cli copy and paste commands + ]; + }; + }; } diff --git a/flake.nix b/flake.nix index bc6aca9..55e9db4 100644 --- a/flake.nix +++ b/flake.nix @@ -22,8 +22,6 @@ specialArgs = args; modules = [ ./configs - inputs.home-manager.nixosModules.home-manager - inputs.sops-nix.nixosModules.sops ]; }; };