From 2a395c3d3aa0fa04aa775c8aa35293ef8d0bf4ae Mon Sep 17 00:00:00 2001 From: Yadunand Prem Date: Tue, 4 Nov 2025 02:38:41 +0800 Subject: [PATCH] move home manager configuration to machine --- .envrc | 2 ++ flake.nix | 22 ++++-------- keys.nix | 6 ++-- machines/yadunut-mbp/configuration.nix | 22 +++++++++--- .../yadunut-mbp/homes/yadunut.nix | 12 ++++--- modules/common/users/default.nix | 36 +++---------------- 6 files changed, 43 insertions(+), 57 deletions(-) create mode 100644 .envrc rename modules/common/users/home.nix => machines/yadunut-mbp/homes/yadunut.nix (76%) diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..0f94eed --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +# shellcheck shell=bash +use flake diff --git a/flake.nix b/flake.nix index b2233d7..d39bf61 100644 --- a/flake.nix +++ b/flake.nix @@ -43,20 +43,12 @@ "aarch64-darwin" "x86_64-darwin" ] - ( - system: - - let - pkgs = import nixpkgs { inherit system; }; - in - { - default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell { - packages = [ - clan-core.packages.${system}.clan-cli - pkgs.nil - ]; - }; - } - ); + (system: { + default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell { + packages = [ + clan-core.packages.${system}.clan-cli + ]; + }; + }); }; } diff --git a/keys.nix b/keys.nix index d6f5f6f..0e2f0d5 100644 --- a/keys.nix +++ b/keys.nix @@ -1,4 +1,6 @@ rec { - yadunut = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJXOpmWsAnl2RtOuJJMRUx+iJTwf2RWJ1iS3FqXJFzFG"; - users = [ yadunut ]; + user = { + yadunut = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJXOpmWsAnl2RtOuJJMRUx+iJTwf2RWJ1iS3FqXJFzFG"; + }; + users = with users; [ yadunut ]; } diff --git a/machines/yadunut-mbp/configuration.nix b/machines/yadunut-mbp/configuration.nix index c1c017e..d1c7ae9 100644 --- a/machines/yadunut-mbp/configuration.nix +++ b/machines/yadunut-mbp/configuration.nix @@ -1,9 +1,12 @@ -{ pkgs, ... }: -let - keys = import ../../keys.nix; -in +{ + pkgs, + lib, + inputs, + ... +}: { imports = [ + inputs.home-manager.darwinModules.home-manager ../../modules/common/sane-defaults ../../modules/common/users ]; @@ -14,6 +17,15 @@ in sane-defaults.enable = true; }; + # # Home Manager configuration + home-manager.useUserPackages = true; + home-manager.users.yadunut = { + imports = [ + ./homes/yadunut.nix + inputs.nixvim.homeModules.nixvim + ]; + }; + nixpkgs.config.allowUnfree = true; homebrew = { @@ -31,6 +43,7 @@ in "datagrip" "discord" "fantastical" + "fastmail" "ghostty" "google-chrome" "iina" @@ -51,7 +64,6 @@ in "slack" "spotify" "steam" - "superwhisper" "syncthing-app" "tailscale" "tailscale-app" diff --git a/modules/common/users/home.nix b/machines/yadunut-mbp/homes/yadunut.nix similarity index 76% rename from modules/common/users/home.nix rename to machines/yadunut-mbp/homes/yadunut.nix index 8775194..dca6f79 100644 --- a/modules/common/users/home.nix +++ b/machines/yadunut-mbp/homes/yadunut.nix @@ -6,12 +6,13 @@ ... }: let + keys = import ../../../keys.nix; config = { nut = { git = { enable = true; gpgProgram = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; - signingKey = "~/.ssh/yadunut_ed25519.pub"; + signingKey = keys.user.yadunut; }; zsh.enable = true; neovim.enable = true; @@ -27,6 +28,9 @@ let pkgs.cachix pkgs.ouch + pkgs.nil + pkgs.nixd + pkgs.claude-code pkgs.codex pkgs.amp-cli @@ -40,8 +44,8 @@ in { imports = [ config - ../../home/git - ../../home/zsh - ../../home/neovim + ../../../modules/home/git + ../../../modules/home/zsh + ../../../modules/home/neovim ]; } diff --git a/modules/common/users/default.nix b/modules/common/users/default.nix index c3bba20..f7c7de3 100644 --- a/modules/common/users/default.nix +++ b/modules/common/users/default.nix @@ -2,54 +2,28 @@ _class, lib, config, - inputs, ... }: let keys = import ../../../keys.nix; cfg = config.nut.users; - nixosModule = { - config = lib.mkIf cfg.enable { - # Enable Home Manager for NixOS and define the user - home-manager.useUserPackages = true; - home-manager.users.yadunut = { - imports = [ - ./home.nix - inputs.nixvim.homeManagerModules.nixvim - ]; - home.homeDirectory = lib.mkForce "/home/yadunut"; - }; - }; - }; + nixosModule = { }; darwinModule = { config = lib.mkIf cfg.enable { + # Darwin user configuration users.users."yadunut" = { - openssh.authorizedKeys.keys = [ keys.yadunut ]; + home = "/Users/yadunut"; + openssh.authorizedKeys.keys = [ keys.user.yadunut ]; }; users.users."root" = { - openssh.authorizedKeys.keys = [ keys.yadunut ]; - }; - home-manager.useUserPackages = true; - home-manager.users.yadunut = { - imports = [ - ./home.nix - inputs.nixvim.homeManagerModules.nixvim - ]; - home.homeDirectory = lib.mkForce "/Users/yadunut"; + openssh.authorizedKeys.keys = [ keys.user.yadunut ]; }; }; }; in { imports = [ - # Import the correct Home Manager module for the current platform - ( - if _class == "darwin" then - inputs.home-manager.darwinModules.home-manager - else - inputs.home-manager.nixosModules.home-manager - ) (lib.optionalAttrs (_class == "nixos") nixosModule) (lib.optionalAttrs (_class == "darwin") darwinModule) ];