From d9173abb7934ff1260ce30c42ca15867dca10b53 Mon Sep 17 00:00:00 2001 From: James Walker Date: Sat, 14 Sep 2024 18:12:01 -0400 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor=20home-manager=20?= =?UTF-8?q?/=20dotfiles=20to=20use=20chezmoi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 158 +++---------------- flake.nix | 29 +--- nix/darwin.nix | 4 +- nix/home.nix | 5 - nix/hosts/epicurus/darwin-configuration.nix | 4 - nix/hosts/plato/configuration.nix | 1 - nix/hosts/socrates/configuration.nix | 1 - nix/modules/base/common.nix | 16 +- nix/modules/base/darwin.nix | 15 +- nix/modules/base/nixos.nix | 10 +- nix/modules/dev/default.nix | 3 - nix/nixos.nix | 4 +- nix/users/default.nix | 2 +- nix/users/{walkah.nix => walkah/default.nix} | 13 +- nix/users/walkah/home.nix | 22 +++ 15 files changed, 76 insertions(+), 211 deletions(-) delete mode 100644 nix/home.nix rename nix/users/{walkah.nix => walkah/default.nix} (66%) create mode 100644 nix/users/walkah/home.nix diff --git a/flake.lock b/flake.lock index 11ef9cd..4f37f0f 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1726032244, - "narHash": "sha256-3VvRGPkpBJobQrFD3slQzMAwZlo4/UwxT8933U5tRVM=", + "lastModified": 1726188813, + "narHash": "sha256-Vop/VRi6uCiScg/Ic+YlwsdIrLabWUJc57dNczp0eBc=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "f4f18f3d7229845e1c9d517457b7a0b90a38b728", + "rev": "21fe31f26473c180390cfa81e3ea81aca0204c80", "type": "github" }, "original": { @@ -43,35 +43,6 @@ "type": "github" } }, - "dotfiles": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "home-manager": [ - "home-manager" - ], - "nixpkgs": [ - "nixpkgs" - ], - "pre-commit-hooks": [ - "pre-commit-hooks" - ] - }, - "locked": { - "lastModified": 1722618951, - "narHash": "sha256-ssE4hAbB+CZpbaRkVcDa9Ki9I3zaiODebGEzPXoYJPQ=", - "owner": "walkah", - "repo": "dotfiles", - "rev": "2de443f050f068a9aa31d178cfa4ead845a171ed", - "type": "github" - }, - "original": { - "owner": "walkah", - "repo": "dotfiles", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -120,22 +91,6 @@ "type": "github" } }, - "flake-compat_4": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems_2" @@ -154,24 +109,6 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_3" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "gitignore": { "inputs": { "nixpkgs": [ @@ -195,14 +132,16 @@ }, "home-manager": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { - "lastModified": 1726036828, - "narHash": "sha256-ZQHbpyti0jcAKnwQY1lwmooecLmSG6wX1JakQ/eZNeM=", + "lastModified": 1726308872, + "narHash": "sha256-d4vwO5N4RsLnCY7k5tY9xbdYDWQsY3RDMeUoIa4ms2A=", "owner": "nix-community", "repo": "home-manager", - "rev": "8a1671642826633586d12ac3158e463c7a50a112", + "rev": "6c1a461a444e6ccb3f3e42bb627b510c3a722a57", "type": "github" }, "original": { @@ -234,11 +173,11 @@ ] }, "locked": { - "lastModified": 1725843519, - "narHash": "sha256-Z6DglUwgFDz6fIvQ89wx/uBVWrGvEGECq0Ypyk/eigE=", + "lastModified": 1726102718, + "narHash": "sha256-u89QyfjtXryLHrO3Wre4kuWK5KDKiXe8lgRi6+cUOEw=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "214efbd73241d72a8f48b8b9a73bb54895cd51a7", + "rev": "5ae384b83b91080f0fead6bc1add1cff8277cb3f", "type": "github" }, "original": { @@ -265,16 +204,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725634671, - "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", + "lastModified": 1726206720, + "narHash": "sha256-tI7141IHDABMNgz4iXDo8agCp0SeTLbaIZ2DRndwcmk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", + "rev": "673d99f1406cb09b8eb6feab4743ebdf70046557", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -311,22 +250,6 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1726042813, - "narHash": "sha256-LnNKCCxnwgF+575y0pxUdlGZBO/ru1CtGHIqQVfvjlA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "159be5db480d1df880a0135ca0bfed84c2f88353", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat_3", @@ -354,16 +277,14 @@ "inputs": { "darwin": "darwin", "deploy-rs": "deploy-rs", - "dotfiles": "dotfiles", "flake-compat": "flake-compat_2", "flake-utils": "flake-utils", "home-manager": "home-manager", "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "pre-commit-hooks": "pre-commit-hooks", - "sops-nix": "sops-nix", - "workon": "workon" + "sops-nix": "sops-nix" } }, "sops-nix": { @@ -374,11 +295,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1725922448, - "narHash": "sha256-ruvh8tlEflRPifs5tlpa0gkttzq4UtgXkJQS7FusgFE=", + "lastModified": 1726218807, + "narHash": "sha256-z7CoWbSOtsOz8TmRKDnobURkKfv6nPZCo3ayolNuQGc=", "owner": "Mic92", "repo": "sops-nix", - "rev": "cede1a08039178ac12957733e97ab1006c6b6892", + "rev": "f30b1bac192e2dc252107ac8a59a03ad25e1b96e", "type": "github" }, "original": { @@ -417,21 +338,6 @@ "type": "github" } }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "utils": { "inputs": { "systems": "systems" @@ -449,28 +355,6 @@ "repo": "flake-utils", "type": "github" } - }, - "workon": { - "inputs": { - "flake-compat": "flake-compat_4", - "flake-utils": "flake-utils_2", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1719248198, - "narHash": "sha256-xF4Odea8BJhBT5qi5ShKn4BeQ5cm+a6vTf45fLq/ADA=", - "owner": "walkah", - "repo": "workon", - "rev": "468788594f1696e70b288d6ffa9ef54ed583e476", - "type": "github" - }, - "original": { - "owner": "walkah", - "repo": "workon", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 743f3d0..1418426 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; - home-manager.url = "github:nix-community/home-manager"; flake-utils.url = "github:numtide/flake-utils"; deploy-rs = { @@ -17,6 +16,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; @@ -36,25 +40,9 @@ url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; - - # My stuff - dotfiles = { - url = "github:walkah/dotfiles"; - inputs = { - nixpkgs.follows = "nixpkgs"; - home-manager.follows = "home-manager"; - flake-utils.follows = "flake-utils"; - pre-commit-hooks.follows = "pre-commit-hooks"; - }; - }; - - workon = { - url = "github:walkah/workon"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; - outputs = { self, nixpkgs, flake-utils, deploy-rs, pre-commit-hooks, workon, ... }@inputs: + outputs = { self, nixpkgs, flake-utils, deploy-rs, pre-commit-hooks, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let @@ -70,12 +58,9 @@ }) // { hosts = import ./nix/hosts.nix; - overlays.default = nixpkgs.lib.composeManyExtensions [ - workon.overlays.default - ]; + overlays.default = nixpkgs.lib.composeManyExtensions [ ]; darwinConfigurations = import ./nix/darwin.nix inputs; - homeConfigurations = import ./nix/home.nix inputs; nixosConfigurations = import ./nix/nixos.nix inputs; deploy = import ./nix/deploy.nix inputs; }; diff --git a/nix/darwin.nix b/nix/darwin.nix index 0bfe1d6..fb027a2 100644 --- a/nix/darwin.nix +++ b/nix/darwin.nix @@ -1,4 +1,4 @@ -{ self, darwin, home-manager, dotfiles, ... }: +{ self, darwin, home-manager, ... }: let mkDarwin = hostName: modules: let @@ -13,7 +13,7 @@ let nixpkgs.overlays = [ self.overlays.default ]; }) ] ++ modules; - specialArgs = { inherit dotfiles home-manager; }; + specialArgs = { inherit home-manager; }; }; in { diff --git a/nix/home.nix b/nix/home.nix deleted file mode 100644 index ce81f07..0000000 --- a/nix/home.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ dotfiles, ... }: -{ - "walkah@epicurus" = dotfiles.homeConfigurations.aarch64-darwin.walkah; - "walkah@heraclitus" = dotfiles.homeConfigurations.aarch64-darwin.walkah; -} diff --git a/nix/hosts/epicurus/darwin-configuration.nix b/nix/hosts/epicurus/darwin-configuration.nix index 454b7fe..d1cbe52 100644 --- a/nix/hosts/epicurus/darwin-configuration.nix +++ b/nix/hosts/epicurus/darwin-configuration.nix @@ -18,8 +18,4 @@ # Auto upgrade nix package and the daemon service. services.nix-daemon.enable = true; - - users.users.walkah.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ0mE4MyMnfd1b2nlBJT7kpZ6Vov+ILuGNfzdp5ZBNQe walkah@walkah.net" - ]; } diff --git a/nix/hosts/plato/configuration.nix b/nix/hosts/plato/configuration.nix index d86459a..54737ad 100644 --- a/nix/hosts/plato/configuration.nix +++ b/nix/hosts/plato/configuration.nix @@ -7,7 +7,6 @@ in imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../users ../../modules/base/nixos.nix ../../modules/coredns diff --git a/nix/hosts/socrates/configuration.nix b/nix/hosts/socrates/configuration.nix index dcb1f89..177921e 100644 --- a/nix/hosts/socrates/configuration.nix +++ b/nix/hosts/socrates/configuration.nix @@ -2,7 +2,6 @@ imports = [ ./hardware-configuration.nix ./networking.nix # generated at runtime by nixos-infect - ../../users ../../modules/base/nixos.nix ../../modules/akkoma diff --git a/nix/modules/base/common.nix b/nix/modules/base/common.nix index 6866b11..b28e599 100644 --- a/nix/modules/base/common.nix +++ b/nix/modules/base/common.nix @@ -1,13 +1,6 @@ -{ pkgs, ... }: +_: { - environment.systemPackages = with pkgs; [ - dogdns - htop - inetutils - vim - ]; - nix = { extraOptions = '' experimental-features = nix-command flakes @@ -30,10 +23,5 @@ }; }; - programs = { - zsh = { - enable = true; - promptInit = ""; - }; - }; + programs.zsh.enable = true; } diff --git a/nix/modules/base/darwin.nix b/nix/modules/base/darwin.nix index 1ced33c..27eb111 100644 --- a/nix/modules/base/darwin.nix +++ b/nix/modules/base/darwin.nix @@ -1,6 +1,6 @@ -{ pkgs, dotfiles, ... }: { +{ ... }: { - imports = [ ./common.nix ]; + imports = [ ./common.nix ../../users ]; nix = { configureBuildUsers = true; @@ -42,16 +42,5 @@ }; }; - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.walkah = import "${dotfiles}/home.nix"; - }; - - users.users.walkah = { - home = "/Users/walkah"; - shell = pkgs.zsh; - }; - system.stateVersion = 4; } diff --git a/nix/modules/base/nixos.nix b/nix/modules/base/nixos.nix index 0c18b81..211d4e1 100644 --- a/nix/modules/base/nixos.nix +++ b/nix/modules/base/nixos.nix @@ -1,6 +1,12 @@ -{ config, ... }: { +{ config, pkgs, ... }: { - imports = [ ./common.nix ../monitoring ]; + imports = [ ./common.nix ../monitoring ../../users ]; + + environment.systemPackages = with pkgs; [ + htop + inetutils + vim + ]; nix = { gc = { diff --git a/nix/modules/dev/default.nix b/nix/modules/dev/default.nix index 1e9ccb9..6868849 100644 --- a/nix/modules/dev/default.nix +++ b/nix/modules/dev/default.nix @@ -32,8 +32,5 @@ nixd nixf nixpkgs-fmt - - # My stuff - workon ]; } diff --git a/nix/nixos.nix b/nix/nixos.nix index d1481c2..e9668d8 100644 --- a/nix/nixos.nix +++ b/nix/nixos.nix @@ -1,4 +1,4 @@ -{ self, dotfiles, nixpkgs, home-manager, nixos-hardware, sops-nix, ... }: +{ self, nixpkgs, home-manager, nixos-hardware, sops-nix, ... }: let mkSystem = hostName: modules: let @@ -14,7 +14,7 @@ let nixpkgs.config.allowUnfree = true; }) ] ++ modules; - specialArgs = { inherit dotfiles nixos-hardware sops-nix; }; + specialArgs = { inherit nixos-hardware sops-nix; }; }; in { diff --git a/nix/users/default.nix b/nix/users/default.nix index 7ba6e59..eee513d 100644 --- a/nix/users/default.nix +++ b/nix/users/default.nix @@ -1,5 +1,5 @@ { ... }: { - imports = [ ./walkah.nix ]; + imports = [ ./walkah ]; } diff --git a/nix/users/walkah.nix b/nix/users/walkah/default.nix similarity index 66% rename from nix/users/walkah.nix rename to nix/users/walkah/default.nix index 44c2d16..be065d2 100644 --- a/nix/users/walkah.nix +++ b/nix/users/walkah/default.nix @@ -1,18 +1,23 @@ -{ pkgs, dotfiles, ... }: +{ lib, pkgs, ... }: { users.users.walkah = { - isNormalUser = true; + home = if pkgs.stdenv.isDarwin then "/Users/walkah" else "/home/walkah"; shell = pkgs.zsh; - extraGroups = [ "wheel" "docker" ]; openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ0mE4MyMnfd1b2nlBJT7kpZ6Vov+ILuGNfzdp5ZBNQe walkah@walkah.net" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM8YMax7PGIrcPNIHkpuNRFgn3HJK6Wepm+ycZWO6jfR walkah@walkah-ipadpro11" ]; + } // lib.optionalAttrs pkgs.stdenv.isLinux { + extraGroups = [ "wheel" "docker" ]; + group = "walkah"; + isNormalUser = true; }; + users.groups.walkah = { }; + home-manager = { useGlobalPkgs = true; useUserPackages = true; - users.walkah = import "${dotfiles}/home.nix"; + users.walkah = import ./home.nix; }; } diff --git a/nix/users/walkah/home.nix b/nix/users/walkah/home.nix new file mode 100644 index 0000000..38f407c --- /dev/null +++ b/nix/users/walkah/home.nix @@ -0,0 +1,22 @@ +{ lib, pkgs, ... }: { + home = { + username = "walkah"; + # homeDirectory = if pkgs.stdenv.isDarwin then "/Users/walkah" else "/home/walkah"; + + packages = with pkgs; [ + chezmoi + direnv + eza + fzf + git + starship + tmux + ]; + + activation.chezmoi = lib.hm.dag.entryAfter [ "installPackages" ] '' + $DRY_RUN_CMD ${pkgs.chezmoi}/bin/chezmoi init --apply walkah/dotfiles + ''; + + stateVersion = "24.05"; + }; +}