From 611d7c1c1f81fa54c333306e8cd64a69133765c2 Mon Sep 17 00:00:00 2001 From: luochen570 <1160510664@qq.com> Date: Fri, 27 Feb 2026 12:03:01 +0800 Subject: [PATCH] modified: flake.nix new file: home/git.nix new file: home/nvchad.nix new file: home/zsh.nix new file: hosts/server/default.nix new file: lib/mkHost.nix new file: modules/wsl/wsl.nix new file: profiles/server.nix --- flake.nix | 55 ++++++++++++++++++++++++++++-------- home/git.nix | 12 ++++++++ home/nvchad.nix | 29 +++++++++++++++++++ home/zsh.nix | 61 ++++++++++++++++++++++++++++++++++++++++ hosts/server/default.nix | 10 +++++++ lib/mkHost.nix | 11 ++++++++ modules/wsl/wsl.nix | 0 profiles/server.nix | 7 +++++ 8 files changed, 174 insertions(+), 11 deletions(-) create mode 100644 home/git.nix create mode 100644 home/nvchad.nix create mode 100644 home/zsh.nix create mode 100644 hosts/server/default.nix create mode 100644 lib/mkHost.nix create mode 100644 modules/wsl/wsl.nix create mode 100644 profiles/server.nix diff --git a/flake.nix b/flake.nix index 865d9ae..df68503 100644 --- a/flake.nix +++ b/flake.nix @@ -1,18 +1,51 @@ { - description = "A basic NixOS configuration"; + description = "My Infra"; inputs = { - nixpkgs.url = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-23.05.tar.gz"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nix4nvchad = { + url = "github:nix-community/nix4nvchad"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; + + vscode-server.url = "github:nix-community/nixos-vscode-server"; }; - outputs = { self, nixpkgs }: { - nixosConfigurations.default = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./modules/ssh - ./modules/zsh-oh-my-zsh - ./modules/fcitx5 - ]; + outputs = inputs@{ self, nixpkgs, home-manager, ... }: + let + mkHost = import ./lib/mkHost.nix { + inherit nixpkgs home-manager inputs; + }; + in { + + nixosConfigurations = { + + desktop = mkHost { + hostname = "desktop"; + system = "x86_64-linux"; + profile = "desktop"; + }; + + server = mkHost { + hostname = "server"; + system = "x86_64-linux"; + profile = "server"; + }; + + wsl = mkHost { + hostname = "wsl"; + system = "x86_64-linux"; + profile = "wsl"; + }; + }; }; -} +} \ No newline at end of file diff --git a/home/git.nix b/home/git.nix new file mode 100644 index 0000000..b8d06bf --- /dev/null +++ b/home/git.nix @@ -0,0 +1,12 @@ +{ # Git + programs.git = { + enable = true; + settings = { + user = { + name = "luochen570"; + email = "1160510664@qq.com"; + }; + init.defaultBranch = "main"; + }; + }; +} \ No newline at end of file diff --git a/home/nvchad.nix b/home/nvchad.nix new file mode 100644 index 0000000..06d2b48 --- /dev/null +++ b/home/nvchad.nix @@ -0,0 +1,29 @@ +{ config, pkgs, inputs, system, ... }: +{ + # 导入 NvChad 模块 + imports = [ + inputs.nix4nvchad.homeManagerModules.default + ]; + + programs.nvchad = { + enable = true; + + # 可选:添加你需要的语言服务器和工具 + extraPackages = with pkgs; [ + # LSP 服务器 + nil # Nix LSP + nixd # Nix 语言服务器(另一种选择) + marksman # Markdown LSP + + # 格式化工具 + nixpkgs-fmt + shfmt + ]; + }; + + # 设置默认编辑器 + home.sessionVariables = { + EDITOR = "nvim"; + VISUAL = "nvim"; + }; +} \ No newline at end of file diff --git a/home/zsh.nix b/home/zsh.nix new file mode 100644 index 0000000..2fcac42 --- /dev/null +++ b/home/zsh.nix @@ -0,0 +1,61 @@ +{ config, pkgs, inputs, system, ... }: +{ programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + # initContent = "source ~/.p10k.zsh"; + plugins = [ + { + name = "powerlevel10k"; + src = pkgs.zsh-powerlevel10k; + file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; + } + { + name = "fzf-tab"; + src = "${pkgs.zsh-fzf-tab}/share/fzf-tab"; + } + # { + # name = "powerlevel10k-config"; + # src = "/home/luochen570/nixos-config/modules/home/p10k/"; + # file = "p10k.zsh"; + # } + ]; + # 设置alias + shellAliases = { + # Git相关 + gc1 = "git clone --recursive --depth=1"; + + # 目录操作 + md = "mkdir -p"; + "..." = "../.."; + "...." = "../../.."; + "....." = "../../../.."; + "......" = "../../../../.."; + + # eza/ls替代 + ls = "eza --color=auto"; + l = "eza -lbah --icons=auto"; + la = "eza -labgh --icons=auto"; + ll = "eza -lbg --icons=auto"; + lt = "eza -lTbg --icons=auto"; + lsa = "eza -lbagR --icons=auto"; + lst = "eza -lTabgh --icons=auto"; + + # bat/cat替代 + cat = "bat -pp"; + ccat = "cat"; + }; + + oh-my-zsh = { + enable = true; + plugins = [ + "sudo" + "z" + "extract" + "git" + # "fzf-tab" + ]; + }; + }; + } \ No newline at end of file diff --git a/hosts/server/default.nix b/hosts/server/default.nix new file mode 100644 index 0000000..440ed0b --- /dev/null +++ b/hosts/server/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + imports = [ + ./hardware.nix + ../../profiles/server.nix + ]; + + networking.hostName = "server"; +} \ No newline at end of file diff --git a/lib/mkHost.nix b/lib/mkHost.nix new file mode 100644 index 0000000..9813558 --- /dev/null +++ b/lib/mkHost.nix @@ -0,0 +1,11 @@ +{ nixpkgs, home-manager, system }: + +name: modules: +nixpkgs.lib.nixosSystem { + inherit system; + + modules = + modules ++ [ + home-manager.nixosModules.home-manager + ]; +} \ No newline at end of file diff --git a/modules/wsl/wsl.nix b/modules/wsl/wsl.nix new file mode 100644 index 0000000..e69de29 diff --git a/profiles/server.nix b/profiles/server.nix new file mode 100644 index 0000000..d97e8c5 --- /dev/null +++ b/profiles/server.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ../modules/core + ../modules/server/docker.nix + ../modules/server/ssh.nix + ]; +} \ No newline at end of file