From b1f250812d831eb1a8d701816d2e715fc14401f2 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 02:51:43 -0700 Subject: [PATCH 01/12] refactor: integrate nix-darwin config --- flake.lock | 194 ++++++++++++++- flake.nix | 40 ++- modules/common/fonts.nix | 3 +- modules/darwin/darwin-configuration.nix | 5 +- modules/darwin/homebrew.nix | 14 ++ modules/darwin/yabai.nix | 23 ++ modules/home-manager/common/core.nix | 4 +- modules/home-manager/darwin/darwin-home.nix | 227 ++++++++++++++++++ modules/home-manager/linux/desktop.nix | 3 +- .../home-manager/linux/linux-home.nix | 0 modules/nixos/nixos-configuration.nix | 1 - modules/nixos/nvidia.nix | 3 +- modules/nixos/secureboot.nix | 30 +-- 13 files changed, 509 insertions(+), 38 deletions(-) create mode 100644 modules/darwin/homebrew.nix create mode 100644 modules/darwin/yabai.nix create mode 100644 modules/home-manager/darwin/darwin-home.nix rename home.nix => modules/home-manager/linux/linux-home.nix (100%) diff --git a/flake.lock b/flake.lock index 25195d7..ca7bfc6 100755 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,23 @@ "type": "github" } }, + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1718075954, + "narHash": "sha256-4TeUhv5VLEufP+Z/NkKnUk4NUaf59cMsj6NvsVbE+8w=", + "owner": "Homebrew", + "repo": "brew", + "rev": "3f08c75e7b950d4340dab462f3e7f77e8093fa2b", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.3.5", + "repo": "brew", + "type": "github" + } + }, "catppuccin": { "locked": { "lastModified": 1721784420, @@ -125,6 +142,24 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "flakey-profile": { "locked": { "lastModified": 1712898590, @@ -182,6 +217,38 @@ "type": "github" } }, + "homebrew-cask": { + "flake": false, + "locked": { + "lastModified": 1722851290, + "narHash": "sha256-AKG4PyxskEEsbkutZUEMbeToOaX9cPusp61mkOgOwX4=", + "owner": "homebrew", + "repo": "homebrew-cask", + "rev": "812e3ae0f3c750120b131d8b80ae13c8ae3d7f4e", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-cask", + "type": "github" + } + }, + "homebrew-core": { + "flake": false, + "locked": { + "lastModified": 1722848547, + "narHash": "sha256-QtfYus4K58sqtXiYXgd+WL67geNuD7bFriXHCwe6H2g=", + "owner": "homebrew", + "repo": "homebrew-core", + "rev": "5024945b7225d78c56b0482c503f8a20371d5eff", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-core", + "type": "github" + } + }, "lanzaboote": { "inputs": { "crane": "crane", @@ -244,22 +311,78 @@ "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.90.0.tar.gz" } }, - "nixpkgs": { + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1722421184, - "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58", + "lastModified": 1722609272, + "narHash": "sha256-Kkb+ULEHVmk07AX+OhwyofFxBDpw+2WvsXguUS2m6e4=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "f7142b8024d6b70c66fd646e1d099d3aa5bfec49", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", + "owner": "LnL7", + "repo": "nix-darwin", "type": "github" } }, + "nix-darwin_2": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1716329735, + "narHash": "sha256-ap51w+VqG21vuzyQ04WrhI2YbWHd3UGz0e7dc/QQmoA=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "eac4f25028c1975a939c8f8fba95c12f8a25e01c", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src", + "flake-utils": "flake-utils_3", + "nix-darwin": "nix-darwin_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1719720211, + "narHash": "sha256-FNK5ZxmNC+V/wOuioc5HqkUy0ld4eW3NqcsZHLYg9HI=", + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "rev": "0afc51fd86693c73e4b60be8ed8c782c4c09b4cc", + "type": "github" + }, + "original": { + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687274257, + "narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=", + "path": "/nix/store/22qgs3skscd9bmrxv9xv4q5d4wwm5ppx-source", + "rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1710695816, @@ -276,6 +399,38 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1716330097, + "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1722421184, + "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -308,9 +463,13 @@ "bleedingpkgs": "bleedingpkgs", "catppuccin": "catppuccin", "home-manager": "home-manager", + "homebrew-cask": "homebrew-cask", + "homebrew-core": "homebrew-core", "lanzaboote": "lanzaboote", "lix-module": "lix-module", - "nixpkgs": "nixpkgs", + "nix-darwin": "nix-darwin", + "nix-homebrew": "nix-homebrew", + "nixpkgs": "nixpkgs_3", "stablepkgs": "stablepkgs" } }, @@ -384,6 +543,21 @@ "repo": "default", "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" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 836d087..0a92d8d 100755 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,17 @@ }; stablepkgs.url = "github:nixos/nixpkgs/nixos-24.05"; bleedingpkgs.url = "github:nixos/nixpkgs/master"; + nix-darwin.url = "github:LnL7/nix-darwin"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + homebrew-core = { + url = "github:homebrew/homebrew-core"; + flake = false; + }; + homebrew-cask = { + url = "github:homebrew/homebrew-cask"; + flake = false; + }; catppuccin.url = "github:catppuccin/nix"; lanzaboote = { url = "github:nix-community/lanzaboote/v0.4.1"; @@ -24,7 +35,7 @@ }; outputs = { self, nixpkgs, home-manager, catppuccin, lanzaboote, stablepkgs - , bleedingpkgs, lix-module, ... }@inputs: { + , bleedingpkgs, lix-module, nix-darwin, nix-homebrew, ... }@inputs: rec { formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt; nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; @@ -51,7 +62,7 @@ home-manager.backupFileExtension = "backup"; home-manager.users.youwen = { imports = [ - ./home.nix + ./modules/home-manager/linux/linux-home.nix ./modules/home-manager/linux/desktop.nix ./modules/home-manager/linux/programs.nix ./modules/home-manager/common/core.nix @@ -61,5 +72,30 @@ } ]; }; + formatter.aarch64-darwin = nixpkgs.legacyPackages.aarch64-darwin.nixfmt; + # Build darwin flake using: + # $ darwin-rebuild build --flake .#Youwens-MacBook-Pro + darwinConfigurations."Youwens-MacBook-Pro" = nix-darwin.lib.darwinSystem { + specialArgs = { inherit inputs; }; + modules = [ + ./modules/common/fonts.nix + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.youwen.imports = [ + ./modules/home-manager/darwin/darwin-home.nix + ./modules/home-manager/common/core.nix + ]; + home-manager.backupFileExtension = "backup"; + + # Optionally, use home-manager.extraSpecialArgs to pass + # arguments to home.nix + } + nix-homebrew.darwinModules.nix-homebrew + ./modules/darwin/homebrew.nix + ./modules/darwin/yabai.nix + ]; + }; }; } diff --git a/modules/common/fonts.nix b/modules/common/fonts.nix index ee59e1f..4cf26d2 100644 --- a/modules/common/fonts.nix +++ b/modules/common/fonts.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: -{ +{ pkgs, ... }: { fonts = { enableDefaultPackages = true; fontconfig = { diff --git a/modules/darwin/darwin-configuration.nix b/modules/darwin/darwin-configuration.nix index e84f8ca..0f0901e 100644 --- a/modules/darwin/darwin-configuration.nix +++ b/modules/darwin/darwin-configuration.nix @@ -1,4 +1,7 @@ -{ config, pkgs, ... }: { +{ config, pkgs, self, ... }: { + # Expose the package set, including overlays, for convenience. + darwinPackages = self.darwinConfigurations."Youwens-MacBook-Pro".pkgs; + # List packages installed in system profile. To search by name, run: # $ nix-env -qaP | grep wget environment.systemPackages = with pkgs; [ ]; diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix new file mode 100644 index 0000000..e3ec0b6 --- /dev/null +++ b/modules/darwin/homebrew.nix @@ -0,0 +1,14 @@ +{ inputs, ... }: { + nix-homebrew = { + enable = true; + enableRosetta = true; + user = "youwen"; + + taps = { + "homebrew/homebrew-core" = inputs.homebrew-core; + "homebrew/homebrew-cask" = inputs.homebrew-cask; + }; + + mutableTaps = false; + }; +} diff --git a/modules/darwin/yabai.nix b/modules/darwin/yabai.nix new file mode 100644 index 0000000..537431a --- /dev/null +++ b/modules/darwin/yabai.nix @@ -0,0 +1,23 @@ +{ config, pkgs, ... }: { + services.yabai = { + enable = true; + enableScriptingAddition = true; + config = { + focus_follows_mouse = "autoraise"; + mouse_follows_focus = "off"; + window_placement = "second_child"; + window_opacity = "off"; + top_padding = 36; + bottom_padding = 10; + left_padding = 10; + right_padding = 10; + window_gap = 10; + }; + }; + services.skhd = { enable = true; }; + services.jankyborders = { + enable = true; + hidpi = true; + }; +} + diff --git a/modules/home-manager/common/core.nix b/modules/home-manager/common/core.nix index de1a43e..85336fe 100644 --- a/modules/home-manager/common/core.nix +++ b/modules/home-manager/common/core.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: -{ +{ pkgs, ... }: { programs.bash.enable = true; programs.nushell = { enable = true; @@ -136,7 +135,6 @@ ]; }; - programs.fd.enable = true; programs.btop = { diff --git a/modules/home-manager/darwin/darwin-home.nix b/modules/home-manager/darwin/darwin-home.nix new file mode 100644 index 0000000..a41bfb5 --- /dev/null +++ b/modules/home-manager/darwin/darwin-home.nix @@ -0,0 +1,227 @@ +{ inputs, config, pkgs, ... }: + +{ + home.username = "youwen"; + home.homeDirectory = "/Users/youwen"; + + # link the configuration file in current directory to the specified location in home directory + # home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg; + + # link all files in `./scripts` to `~/.config/i3/scripts` + # home.file.".config/i3/scripts" = { + # source = ./scripts; + # recursive = true; # link recursively + # executable = true; # make all files executable + # }; + + # encode the file content in nix configuration file directly + # home.file.".xxx".text = '' + # xxx + # ''; + + home.file.".config/neofetch/config.conf".source = ./config/neofetch.conf; + + # Packages that should be installed to the user profile. + home.packages = with pkgs; [ + neofetch + + # archives + zip + xz + unzip + p7zip + + # utils + nurl # helps fetch git data for nixpkgs + + # nix related + # + # it provides the command `nom` works just like `nix` + # with more details log output + nix-output-monitor + + # dev tools + nodePackages_latest.pnpm + rustfmt + rust-analyzer + ]; + + programs.fzf = { enable = true; }; + + programs.git = { + enable = true; + userName = "Youwen Wu"; + userEmail = "youwenw@gmail.com"; + delta.enable = true; + extraConfig = { + init.defaultBranch = "main"; + commit.gpgsign = "false"; + user.signingkey = "8F5E6C1AF90976CA7102917A865658ED1FE61EC3"; + }; + }; + + programs.lazygit = { + enable = true; + settings = { + git.paging = { + colorArg = "always"; + pager = "delta --dark --paging=never"; + }; + }; + }; + + programs.bat.enable = true; + + programs.ripgrep.enable = true; + + programs.kitty = { + enable = true; + theme = "Tokyo Night"; + font.name = "CaskaydiaCove Nerd Font"; + settings = { + font_size = 12; + window_padding_width = "8 8 0"; + confirm_os_window_close = -1; + shell_integration = "enabled"; + enable_audio_bell = "no"; + background_opacity = "0.8"; + }; + }; + + programs.readline = { + enable = true; + extraConfig = "set editing-mode vi"; + }; + + programs.zoxide = { + enable = true; + # enableZshIntegration = true; + enableFishIntegration = true; + enableNushellIntegration = true; + }; + + programs.gh = { + enable = true; + extensions = [ pkgs.github-copilot-cli ]; + }; + + programs.oh-my-posh = { + enable = true; + enableZshIntegration = true; + enableFishIntegration = true; + enableBashIntegration = true; + useTheme = "gruvbox"; + }; + + programs.fish = { + enable = true; + shellAliases = { + rebuild = "sudo nixos-rebuild switch"; + ls = "eza -l --icons=auto"; + }; + functions = { + update-nixos = { + description = + "Update the system flake and attempt to build and switch to the new configuration."; + body = '' + cd /etc/nixos + nix flake update + sudo nixos-rebuild switch + ''; + }; + }; + interactiveShellInit = '' + fish_vi_key_bindings + set -g fish_greeting + ''; + plugins = [ + { + name = "autopair"; + src = pkgs.fetchFromGitHub { + owner = "jorgebucaran"; + repo = "autopair.fish"; + rev = "4d1752ff5b39819ab58d7337c69220342e9de0e2"; + hash = "sha256-qt3t1iKRRNuiLWiVoiAYOu+9E7jsyECyIqZJ/oRIT1A="; + }; + } + { + name = "fzf"; + src = pkgs.fetchFromGitHub { + owner = "PatrickF1"; + repo = "fzf.fish"; + rev = "8920367cf85eee5218cc25a11e209d46e2591e7a"; + hash = "sha256-T8KYLA/r/gOKvAivKRoeqIwE2pINlxFQtZJHpOy9GMM="; + }; + } + { + name = "sponge"; + src = pkgs.fetchFromGitHub { + owner = "meaningful-ooo"; + repo = "sponge"; + rev = "384299545104d5256648cee9d8b117aaa9a6d7be"; + hash = "sha256-MdcZUDRtNJdiyo2l9o5ma7nAX84xEJbGFhAVhK+Zm1w="; + }; + } + { + name = "done"; + src = pkgs.fetchFromGitHub { + owner = "franciscolourenco"; + repo = "done"; + rev = "eb32ade85c0f2c68cbfcff3036756bbf27a4f366"; + hash = "sha256-DMIRKRAVOn7YEnuAtz4hIxrU93ULxNoQhW6juxCoh4o="; + }; + } + ]; + }; + + programs.nushell = { + enable = true; + configFile.text = '' + $env.config = { + edit_mode: vi, + show_banner: false + } + ''; + }; + + programs.fd.enable = true; + + programs.btop = { + enable = true; + settings = { + color_theme = "tokyo-night"; + vim_keys = true; + theme_background = false; + }; + }; + + programs.eza = { + enable = true; + enableFishIntegration = true; + enableBashIntegration = true; + }; + + programs.bash.enable = true; + programs.zsh.enable = true; + + programs.neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = 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. + home.stateVersion = "24.05"; + # + # 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. + + # Let home Manager install and manage itself. + programs.home-manager.enable = true; + +} diff --git a/modules/home-manager/linux/desktop.nix b/modules/home-manager/linux/desktop.nix index 0959914..2839ea3 100644 --- a/modules/home-manager/linux/desktop.nix +++ b/modules/home-manager/linux/desktop.nix @@ -1,5 +1,4 @@ -{ pkgs, ...}: -{ +{ pkgs, ... }: { wayland.windowManager.hyprland = import ./hyprland-conf.nix; # Audio effects and EQ tool diff --git a/home.nix b/modules/home-manager/linux/linux-home.nix similarity index 100% rename from home.nix rename to modules/home-manager/linux/linux-home.nix diff --git a/modules/nixos/nixos-configuration.nix b/modules/nixos/nixos-configuration.nix index cf2b50b..f2817a4 100755 --- a/modules/nixos/nixos-configuration.nix +++ b/modules/nixos/nixos-configuration.nix @@ -80,7 +80,6 @@ # Enable CUPS to print documents. services.printing.enable = true; - # Enable touchpad support (enabled default in most desktopManager). # services.xserver.libinput.enable = true; diff --git a/modules/nixos/nvidia.nix b/modules/nixos/nvidia.nix index 779d5e9..789fb5f 100644 --- a/modules/nixos/nvidia.nix +++ b/modules/nixos/nvidia.nix @@ -1,5 +1,4 @@ -{ config, ... }: -{ +{ config, ... }: { hardware.nvidia = { modesetting.enable = true; powerManagement.enable = true; diff --git a/modules/nixos/secureboot.nix b/modules/nixos/secureboot.nix index 61ce5c5..c5ccbac 100644 --- a/modules/nixos/secureboot.nix +++ b/modules/nixos/secureboot.nix @@ -1,17 +1,17 @@ - ({ pkgs, lib, ... }: { - environment.systemPackages = [ - # For debugging and troubleshooting Secure Boot. - pkgs.sbctl - ]; +({ pkgs, lib, ... }: { + environment.systemPackages = [ + # For debugging and troubleshooting Secure Boot. + pkgs.sbctl + ]; - # Lanzaboote currently replaces the systemd-boot module. - # This setting is usually set to true in configuration.nix - # generated at installation time. So we force it to false - # for now. - boot.loader.systemd-boot.enable = lib.mkForce false; + # Lanzaboote currently replaces the systemd-boot module. + # This setting is usually set to true in configuration.nix + # generated at installation time. So we force it to false + # for now. + boot.loader.systemd-boot.enable = lib.mkForce false; - boot.lanzaboote = { - enable = true; - pkiBundle = "/etc/secureboot"; - }; - }) + boot.lanzaboote = { + enable = true; + pkiBundle = "/etc/secureboot"; + }; +}) From 5a7a329829d393a0434e6507b9f01068bcfa8844 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 03:15:48 -0700 Subject: [PATCH 02/12] refactor: correctly build darwin --- flake.nix | 3 +- modules/darwin/darwin-configuration.nix | 14 ++- modules/home-manager/common/core.nix | 11 +- modules/home-manager/darwin/darwin-home.nix | 133 +------------------- modules/home-manager/linux/catppuccin.nix | 18 +++ 5 files changed, 35 insertions(+), 144 deletions(-) create mode 100644 modules/home-manager/linux/catppuccin.nix diff --git a/flake.nix b/flake.nix index 0a92d8d..66fadd1 100755 --- a/flake.nix +++ b/flake.nix @@ -66,6 +66,7 @@ ./modules/home-manager/linux/desktop.nix ./modules/home-manager/linux/programs.nix ./modules/home-manager/common/core.nix + ./modules/home-manager/common/catppuccin.nix inputs.catppuccin.homeManagerModules.catppuccin ]; }; @@ -78,7 +79,7 @@ darwinConfigurations."Youwens-MacBook-Pro" = nix-darwin.lib.darwinSystem { specialArgs = { inherit inputs; }; modules = [ - ./modules/common/fonts.nix + ./modules/darwin/darwin-configuration.nix home-manager.darwinModules.home-manager { home-manager.useGlobalPkgs = true; diff --git a/modules/darwin/darwin-configuration.nix b/modules/darwin/darwin-configuration.nix index 0f0901e..4f87456 100644 --- a/modules/darwin/darwin-configuration.nix +++ b/modules/darwin/darwin-configuration.nix @@ -1,6 +1,6 @@ -{ config, pkgs, self, ... }: { +{ config, pkgs, ... }: { # Expose the package set, including overlays, for convenience. - darwinPackages = self.darwinConfigurations."Youwens-MacBook-Pro".pkgs; + # darwinPackages = config.self.darwinConfigurations."Youwens-MacBook-Pro".pkgs; # List packages installed in system profile. To search by name, run: # $ nix-env -qaP | grep wget @@ -39,4 +39,14 @@ }; security.pam.enableSudoTouchIdAuth = true; + + fonts = { + packages = with pkgs; [ + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + (nerdfonts.override { fonts = [ "CascadiaCode" ]; }) + (google-fonts.override { fonts = [ "Lora" ]; }) + ]; + }; } diff --git a/modules/home-manager/common/core.nix b/modules/home-manager/common/core.nix index 85336fe..07dae28 100644 --- a/modules/home-manager/common/core.nix +++ b/modules/home-manager/common/core.nix @@ -12,10 +12,9 @@ programs.fzf = { enable = true; - catppuccin.enable = true; }; - programs.git = { + programs.git = pkgs.lib.mkDefault { enable = true; userName = "Youwen Wu"; userEmail = "youwenw@gmail.com"; @@ -29,8 +28,6 @@ programs.lazygit = { enable = true; - catppuccin.enable = true; - catppuccin.flavor = "macchiato"; settings = { git.paging = { colorArg = "always"; @@ -40,10 +37,6 @@ }; programs.bat.enable = true; - programs.bat.catppuccin = { - enable = true; - flavor = "macchiato"; - }; programs.ripgrep.enable = true; @@ -74,8 +67,6 @@ programs.fish = { enable = true; - catppuccin.enable = true; - catppuccin.flavor = "mocha"; shellAliases = { rebuild = "sudo nixos-rebuild switch"; ls = "eza -l --icons=auto"; diff --git a/modules/home-manager/darwin/darwin-home.nix b/modules/home-manager/darwin/darwin-home.nix index a41bfb5..d2246db 100644 --- a/modules/home-manager/darwin/darwin-home.nix +++ b/modules/home-manager/darwin/darwin-home.nix @@ -19,8 +19,8 @@ # xxx # ''; - home.file.".config/neofetch/config.conf".source = ./config/neofetch.conf; - + home.file.".config/neofetch/config.conf".source = ../../../config/neofetch.conf; + # Packages that should be installed to the user profile. home.packages = with pkgs; [ neofetch @@ -46,8 +46,6 @@ rust-analyzer ]; - programs.fzf = { enable = true; }; - programs.git = { enable = true; userName = "Youwen Wu"; @@ -60,20 +58,6 @@ }; }; - programs.lazygit = { - enable = true; - settings = { - git.paging = { - colorArg = "always"; - pager = "delta --dark --paging=never"; - }; - }; - }; - - programs.bat.enable = true; - - programs.ripgrep.enable = true; - programs.kitty = { enable = true; theme = "Tokyo Night"; @@ -88,23 +72,6 @@ }; }; - programs.readline = { - enable = true; - extraConfig = "set editing-mode vi"; - }; - - programs.zoxide = { - enable = true; - # enableZshIntegration = true; - enableFishIntegration = true; - enableNushellIntegration = true; - }; - - programs.gh = { - enable = true; - extensions = [ pkgs.github-copilot-cli ]; - }; - programs.oh-my-posh = { enable = true; enableZshIntegration = true; @@ -112,105 +79,9 @@ enableBashIntegration = true; useTheme = "gruvbox"; }; - - programs.fish = { - enable = true; - shellAliases = { - rebuild = "sudo nixos-rebuild switch"; - ls = "eza -l --icons=auto"; - }; - functions = { - update-nixos = { - description = - "Update the system flake and attempt to build and switch to the new configuration."; - body = '' - cd /etc/nixos - nix flake update - sudo nixos-rebuild switch - ''; - }; - }; - interactiveShellInit = '' - fish_vi_key_bindings - set -g fish_greeting - ''; - plugins = [ - { - name = "autopair"; - src = pkgs.fetchFromGitHub { - owner = "jorgebucaran"; - repo = "autopair.fish"; - rev = "4d1752ff5b39819ab58d7337c69220342e9de0e2"; - hash = "sha256-qt3t1iKRRNuiLWiVoiAYOu+9E7jsyECyIqZJ/oRIT1A="; - }; - } - { - name = "fzf"; - src = pkgs.fetchFromGitHub { - owner = "PatrickF1"; - repo = "fzf.fish"; - rev = "8920367cf85eee5218cc25a11e209d46e2591e7a"; - hash = "sha256-T8KYLA/r/gOKvAivKRoeqIwE2pINlxFQtZJHpOy9GMM="; - }; - } - { - name = "sponge"; - src = pkgs.fetchFromGitHub { - owner = "meaningful-ooo"; - repo = "sponge"; - rev = "384299545104d5256648cee9d8b117aaa9a6d7be"; - hash = "sha256-MdcZUDRtNJdiyo2l9o5ma7nAX84xEJbGFhAVhK+Zm1w="; - }; - } - { - name = "done"; - src = pkgs.fetchFromGitHub { - owner = "franciscolourenco"; - repo = "done"; - rev = "eb32ade85c0f2c68cbfcff3036756bbf27a4f366"; - hash = "sha256-DMIRKRAVOn7YEnuAtz4hIxrU93ULxNoQhW6juxCoh4o="; - }; - } - ]; - }; - - programs.nushell = { - enable = true; - configFile.text = '' - $env.config = { - edit_mode: vi, - show_banner: false - } - ''; - }; - - programs.fd.enable = true; - - programs.btop = { - enable = true; - settings = { - color_theme = "tokyo-night"; - vim_keys = true; - theme_background = false; - }; - }; - - programs.eza = { - enable = true; - enableFishIntegration = true; - enableBashIntegration = true; - }; - programs.bash.enable = true; programs.zsh.enable = true; - programs.neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = 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 diff --git a/modules/home-manager/linux/catppuccin.nix b/modules/home-manager/linux/catppuccin.nix new file mode 100644 index 0000000..4e08a2f --- /dev/null +++ b/modules/home-manager/linux/catppuccin.nix @@ -0,0 +1,18 @@ +{ + programs.fzf.catppuccin = { + enable = true; + flavor = "macchiato"; + }; + programs.lazygit.catppuccin = { + enable = true; + flavor = "macchiato"; + }; + programs.bat.catppuccin = { + enable = true; + flavor = "macchiato"; + }; + programs.fish.catppuccin = { + enable = true; + flavor = "mocha"; + }; +} From 911d49affa34aba7761915b92fe42767a5a4bfb7 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 03:16:30 -0700 Subject: [PATCH 03/12] fix: correctly references darwinPackages --- modules/darwin/darwin-configuration.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/darwin/darwin-configuration.nix b/modules/darwin/darwin-configuration.nix index 4f87456..2babf59 100644 --- a/modules/darwin/darwin-configuration.nix +++ b/modules/darwin/darwin-configuration.nix @@ -1,6 +1,6 @@ -{ config, pkgs, ... }: { +{ inputs, config, pkgs, ... }: { # Expose the package set, including overlays, for convenience. - # darwinPackages = config.self.darwinConfigurations."Youwens-MacBook-Pro".pkgs; + darwinPackages = inputs.self.darwinConfigurations."Youwens-MacBook-Pro".pkgs; # List packages installed in system profile. To search by name, run: # $ nix-env -qaP | grep wget From a164cd2d2f2fd241724e9e12082bb7973a05b85d Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 03:17:31 -0700 Subject: [PATCH 04/12] refactor: make fish overrideable using mkdefault --- modules/home-manager/common/core.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-manager/common/core.nix b/modules/home-manager/common/core.nix index 07dae28..ca750f9 100644 --- a/modules/home-manager/common/core.nix +++ b/modules/home-manager/common/core.nix @@ -65,7 +65,7 @@ useTheme = "gruvbox"; }; - programs.fish = { + programs.fish = pkgs.lib.mkDefault { enable = true; shellAliases = { rebuild = "sudo nixos-rebuild switch"; From 3a917eb837d600efa3e2e64ab8f2dd18d5fc3e41 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 03:23:18 -0700 Subject: [PATCH 05/12] refactor: use mkDefault on all options in common --- modules/home-manager/common/core.nix | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/home-manager/common/core.nix b/modules/home-manager/common/core.nix index ca750f9..e4c7e6e 100644 --- a/modules/home-manager/common/core.nix +++ b/modules/home-manager/common/core.nix @@ -1,6 +1,6 @@ { pkgs, ... }: { - programs.bash.enable = true; - programs.nushell = { + programs.bash.enable = pkgs.lib.mkDefault true; + programs.nushell = pkgs.lib.mkDefault { enable = true; configFile.text = '' $env.config = { @@ -10,7 +10,7 @@ ''; }; - programs.fzf = { + programs.fzf = pkgs.lib.mkDefault { enable = true; }; @@ -26,7 +26,7 @@ }; }; - programs.lazygit = { + programs.lazygit = pkgs.lib.mkDefault { enable = true; settings = { git.paging = { @@ -36,28 +36,28 @@ }; }; - programs.bat.enable = true; + programs.bat.enable = pkgs.lib.mkDefault true; - programs.ripgrep.enable = true; + programs.ripgrep.enable = pkgs.lib.mkDefault true; programs.readline = { enable = true; extraConfig = "set editing-mode vi"; }; - programs.zoxide = { + programs.zoxide = pkgs.lib.mkDefault { enable = true; # enableZshIntegration = true; enableFishIntegration = true; enableNushellIntegration = true; }; - programs.gh = { + programs.gh = pkgs.lib.mkDefault { enable = true; extensions = [ pkgs.github-copilot-cli ]; }; - programs.oh-my-posh = { + programs.oh-my-posh = pkgs.lib.mkDefault { enable = true; # enableZshIntegration = true; enableFishIntegration = true; @@ -126,9 +126,9 @@ ]; }; - programs.fd.enable = true; + programs.fd.enable = pkgs.lib.mkDefault true; - programs.btop = { + programs.btop = pkgs.lib.mkDefault { enable = true; settings = { color_theme = "tokyo-night"; @@ -137,13 +137,13 @@ }; }; - programs.eza = { + programs.eza = pkgs.lib.mkDefault { enable = true; enableFishIntegration = true; enableBashIntegration = true; }; - programs.neovim = { + programs.neovim = pkgs.lib.mkDefault { enable = true; defaultEditor = true; viAlias = true; From 89097fcb16ff146fec88257ab98f7d8e6b530c6c Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 17:04:46 -0700 Subject: [PATCH 06/12] fix: reverts 911d49af which introduces infinite recursion error --- modules/darwin/darwin-configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/darwin/darwin-configuration.nix b/modules/darwin/darwin-configuration.nix index 2babf59..7f1633b 100644 --- a/modules/darwin/darwin-configuration.nix +++ b/modules/darwin/darwin-configuration.nix @@ -1,6 +1,6 @@ { inputs, config, pkgs, ... }: { # Expose the package set, including overlays, for convenience. - darwinPackages = inputs.self.darwinConfigurations."Youwens-MacBook-Pro".pkgs; + # darwinPackages = inputs.self.darwinConfigurations."Youwens-MacBook-Pro".pkgs; # List packages installed in system profile. To search by name, run: # $ nix-env -qaP | grep wget From e9badf4d3d7129c6cc096d3669491c051397b62c Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 17:04:54 -0700 Subject: [PATCH 07/12] feat: add more yabai configuration --- modules/darwin/yabai.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/darwin/yabai.nix b/modules/darwin/yabai.nix index 537431a..3e39586 100644 --- a/modules/darwin/yabai.nix +++ b/modules/darwin/yabai.nix @@ -4,14 +4,21 @@ enableScriptingAddition = true; config = { focus_follows_mouse = "autoraise"; - mouse_follows_focus = "off"; + mouse_follows_focus = "on"; window_placement = "second_child"; window_opacity = "off"; - top_padding = 36; - bottom_padding = 10; - left_padding = 10; - right_padding = 10; + top_padding = 12; + bottom_padding = 12; + left_padding = 12; + right_padding = 12; window_gap = 10; + split_ratio = 0.50; + split_type = "auto"; + layout = "bsp"; + mouse_modifier = "fn"; + mouse_action1 = "move"; + mouse_action2 = "resize"; + mouse_drop_action = "swap"; }; }; services.skhd = { enable = true; }; From cc8eb445a40784942f6b5200c8aa0d0c8f15a535 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 17:42:19 -0700 Subject: [PATCH 08/12] fix: cant mkdefault fish because of merging with integrations --- modules/home-manager/common/core.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-manager/common/core.nix b/modules/home-manager/common/core.nix index e4c7e6e..dd691e7 100644 --- a/modules/home-manager/common/core.nix +++ b/modules/home-manager/common/core.nix @@ -65,7 +65,7 @@ useTheme = "gruvbox"; }; - programs.fish = pkgs.lib.mkDefault { + programs.fish = { enable = true; shellAliases = { rebuild = "sudo nixos-rebuild switch"; From 1056a696d370807f52b9a3abe2a8cc4d636ac07e Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 5 Aug 2024 17:42:31 -0700 Subject: [PATCH 09/12] refactor: remove some hardcoded configuration in favor of overrides --- modules/home-manager/darwin/darwin-home.nix | 33 ++------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/modules/home-manager/darwin/darwin-home.nix b/modules/home-manager/darwin/darwin-home.nix index d2246db..34d7975 100644 --- a/modules/home-manager/darwin/darwin-home.nix +++ b/modules/home-manager/darwin/darwin-home.nix @@ -46,39 +46,10 @@ rust-analyzer ]; - programs.git = { - enable = true; - userName = "Youwen Wu"; - userEmail = "youwenw@gmail.com"; - delta.enable = true; - extraConfig = { - init.defaultBranch = "main"; - commit.gpgsign = "false"; - user.signingkey = "8F5E6C1AF90976CA7102917A865658ED1FE61EC3"; - }; - }; + programs.git.extraConfig.commit.gpgsign = "false"; - programs.kitty = { - enable = true; - theme = "Tokyo Night"; - font.name = "CaskaydiaCove Nerd Font"; - settings = { - font_size = 12; - window_padding_width = "8 8 0"; - confirm_os_window_close = -1; - shell_integration = "enabled"; - enable_audio_bell = "no"; - background_opacity = "0.8"; - }; - }; + programs.oh-my-posh.enableZshIntegration = true; - programs.oh-my-posh = { - enable = true; - enableZshIntegration = true; - enableFishIntegration = true; - enableBashIntegration = true; - useTheme = "gruvbox"; - }; programs.bash.enable = true; programs.zsh.enable = true; From fa7e3d178ecc7a9dcfacda67535db6a9b455468c Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Tue, 6 Aug 2024 00:06:45 -0700 Subject: [PATCH 10/12] refactor: move hardware configuration to machine-specific directory --- flake.nix | 1 + .../nixos/hardware-configuration.nix | 0 modules/nixos/nixos-configuration.nix | 6 +++--- 3 files changed, 4 insertions(+), 3 deletions(-) rename hardware-configuration.nix => machines/nixos/hardware-configuration.nix (100%) diff --git a/flake.nix b/flake.nix index 66fadd1..572552a 100755 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,7 @@ ./modules/nixos/nvidia.nix ./modules/nixos/networking.nix ./modules/common/fonts.nix + ./machines/nixos/hardware-configuration.nix catppuccin.nixosModules.catppuccin diff --git a/hardware-configuration.nix b/machines/nixos/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to machines/nixos/hardware-configuration.nix diff --git a/modules/nixos/nixos-configuration.nix b/modules/nixos/nixos-configuration.nix index f2817a4..a36a326 100755 --- a/modules/nixos/nixos-configuration.nix +++ b/modules/nixos/nixos-configuration.nix @@ -5,9 +5,9 @@ { config, inputs, pkgs, ... }: { - imports = [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; + # imports = [ # Include the results of the hardware scan. + # ./hardware-configuration.nix + # ]; # Bootloader. boot.loader = { From ccd6199d95aea5eb321193a7bf9046bde4e5b651 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Tue, 6 Aug 2024 00:11:19 -0700 Subject: [PATCH 11/12] fix(nixos): repair some broken relative paths to build successfully --- flake.nix | 2 +- modules/home-manager/linux/linux-home.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 572552a..efa9f2e 100755 --- a/flake.nix +++ b/flake.nix @@ -67,7 +67,7 @@ ./modules/home-manager/linux/desktop.nix ./modules/home-manager/linux/programs.nix ./modules/home-manager/common/core.nix - ./modules/home-manager/common/catppuccin.nix + ./modules/home-manager/linux/catppuccin.nix inputs.catppuccin.homeManagerModules.catppuccin ]; }; diff --git a/modules/home-manager/linux/linux-home.nix b/modules/home-manager/linux/linux-home.nix index d320401..49a466d 100755 --- a/modules/home-manager/linux/linux-home.nix +++ b/modules/home-manager/linux/linux-home.nix @@ -19,9 +19,9 @@ # xxx # ''; - home.file.".config/neofetch/config.conf".source = ./config/neofetch.conf; + home.file.".config/neofetch/config.conf".source = ../../../config/neofetch.conf; home.file.".wallpapers" = { - source = ./wallpapers; + source = ../../../wallpapers; recursive = true; }; From 1236708729f91e08202c0170072155daf66aee5e Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Tue, 6 Aug 2024 00:13:05 -0700 Subject: [PATCH 12/12] chore: run nixfmt --- flake.nix | 2 +- modules/darwin/yabai.nix | 2 +- modules/home-manager/common/core.nix | 4 +--- modules/home-manager/darwin/darwin-home.nix | 5 +++-- modules/home-manager/linux/linux-home.nix | 3 ++- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index efa9f2e..942a7bd 100755 --- a/flake.nix +++ b/flake.nix @@ -67,7 +67,7 @@ ./modules/home-manager/linux/desktop.nix ./modules/home-manager/linux/programs.nix ./modules/home-manager/common/core.nix - ./modules/home-manager/linux/catppuccin.nix + ./modules/home-manager/linux/catppuccin.nix inputs.catppuccin.homeManagerModules.catppuccin ]; }; diff --git a/modules/darwin/yabai.nix b/modules/darwin/yabai.nix index 3e39586..dae736f 100644 --- a/modules/darwin/yabai.nix +++ b/modules/darwin/yabai.nix @@ -12,7 +12,7 @@ left_padding = 12; right_padding = 12; window_gap = 10; - split_ratio = 0.50; + split_ratio = 0.5; split_type = "auto"; layout = "bsp"; mouse_modifier = "fn"; diff --git a/modules/home-manager/common/core.nix b/modules/home-manager/common/core.nix index dd691e7..ef7a4d0 100644 --- a/modules/home-manager/common/core.nix +++ b/modules/home-manager/common/core.nix @@ -10,9 +10,7 @@ ''; }; - programs.fzf = pkgs.lib.mkDefault { - enable = true; - }; + programs.fzf = pkgs.lib.mkDefault { enable = true; }; programs.git = pkgs.lib.mkDefault { enable = true; diff --git a/modules/home-manager/darwin/darwin-home.nix b/modules/home-manager/darwin/darwin-home.nix index 34d7975..12383fc 100644 --- a/modules/home-manager/darwin/darwin-home.nix +++ b/modules/home-manager/darwin/darwin-home.nix @@ -19,8 +19,9 @@ # xxx # ''; - home.file.".config/neofetch/config.conf".source = ../../../config/neofetch.conf; - + home.file.".config/neofetch/config.conf".source = + ../../../config/neofetch.conf; + # Packages that should be installed to the user profile. home.packages = with pkgs; [ neofetch diff --git a/modules/home-manager/linux/linux-home.nix b/modules/home-manager/linux/linux-home.nix index 49a466d..f5798d6 100755 --- a/modules/home-manager/linux/linux-home.nix +++ b/modules/home-manager/linux/linux-home.nix @@ -19,7 +19,8 @@ # xxx # ''; - home.file.".config/neofetch/config.conf".source = ../../../config/neofetch.conf; + home.file.".config/neofetch/config.conf".source = + ../../../config/neofetch.conf; home.file.".wallpapers" = { source = ../../../wallpapers; recursive = true;