bootstrap head
This commit is contained in:
@@ -0,0 +1,189 @@
|
|||||||
|
# Edit this configuration file to define what should be installed on
|
||||||
|
# your system. Help is available in the configuration.nix(5) man page
|
||||||
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||||
|
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ # Include the results of the hardware scan.
|
||||||
|
./hardware-configuration.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
# Bootloader.
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
|
networking.hostName = "nixos"; # Define your hostname.
|
||||||
|
programs.nix-ld.enable = true;
|
||||||
|
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
|
||||||
|
|
||||||
|
# Configure network proxy if necessary
|
||||||
|
# networking.proxy.default = "http://user:password@proxy:port/";
|
||||||
|
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
|
||||||
|
|
||||||
|
|
||||||
|
fonts.enableDefaultPackages = true;
|
||||||
|
fonts.packages = with pkgs; [
|
||||||
|
noto-fonts
|
||||||
|
noto-fonts-cjk-sans
|
||||||
|
noto-fonts-cjk-serif
|
||||||
|
sarasa-gothic # 更纱黑体,包含优秀的中英文等宽字体,极其适合终端和编程
|
||||||
|
wqy_microhei
|
||||||
|
wqy_zenhei
|
||||||
|
];
|
||||||
|
|
||||||
|
fonts.fontconfig = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
# 设置全局默认字体,防止系统回退到显示效果不佳的字体
|
||||||
|
defaultFonts = {
|
||||||
|
serif = [ "Noto Serif CJK SC" "Noto Serif" ];
|
||||||
|
sansSerif = [ "Noto Sans CJK SC" "Noto Sans" ];
|
||||||
|
monospace = [ "Sarasa Term SC" "Noto Sans Mono CJK SC" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# 解决锯齿问题的核心:开启抗锯齿、微调和次像素渲染
|
||||||
|
antialias = true;
|
||||||
|
hinting = {
|
||||||
|
enable = true;
|
||||||
|
style = "slight"; # 若在高分屏 (HiDPI) 下,"slight" 通常表现最好
|
||||||
|
};
|
||||||
|
subpixel = {
|
||||||
|
rgba = "rgb"; # 针对 LCD 屏幕的次像素排列优化
|
||||||
|
lcdfilter = "default";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
# Enable networking
|
||||||
|
networking.networkmanager.enable = true;
|
||||||
|
|
||||||
|
# Set your time zone.
|
||||||
|
time.timeZone = "Asia/Shanghai";
|
||||||
|
|
||||||
|
# Select internationalisation properties.
|
||||||
|
i18n.defaultLocale = "zh_CN.UTF-8";
|
||||||
|
|
||||||
|
i18n.extraLocaleSettings = {
|
||||||
|
LC_ADDRESS = "zh_CN.UTF-8";
|
||||||
|
LC_IDENTIFICATION = "zh_CN.UTF-8";
|
||||||
|
LC_MEASUREMENT = "zh_CN.UTF-8";
|
||||||
|
LC_MONETARY = "zh_CN.UTF-8";
|
||||||
|
LC_NAME = "zh_CN.UTF-8";
|
||||||
|
LC_NUMERIC = "zh_CN.UTF-8";
|
||||||
|
LC_PAPER = "zh_CN.UTF-8";
|
||||||
|
LC_TELEPHONE = "zh_CN.UTF-8";
|
||||||
|
LC_TIME = "zh_CN.UTF-8";
|
||||||
|
};
|
||||||
|
|
||||||
|
i18n.inputMethod = {
|
||||||
|
enable = true;
|
||||||
|
type = "fcitx5";
|
||||||
|
fcitx5.addons = with pkgs; [
|
||||||
|
# 注入 rime-ice,并补齐中文输入与 KDE/Qt 集成组件。
|
||||||
|
(fcitx5-rime.override {
|
||||||
|
rimeDataPkgs = [
|
||||||
|
pkgs.rime-ice
|
||||||
|
];
|
||||||
|
})
|
||||||
|
qt6Packages.fcitx5-chinese-addons
|
||||||
|
fcitx5-gtk
|
||||||
|
kdePackages.fcitx5-qt
|
||||||
|
kdePackages.fcitx5-configtool
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable the X11 windowing system.
|
||||||
|
# You can disable this if you're only using the Wayland session.
|
||||||
|
services.xserver.enable = true;
|
||||||
|
|
||||||
|
# Enable the KDE Plasma Desktop Environment.
|
||||||
|
services.displayManager.sddm.enable = true;
|
||||||
|
services.desktopManager.plasma6.enable = true;
|
||||||
|
|
||||||
|
# Configure keymap in X11
|
||||||
|
services.xserver.xkb = {
|
||||||
|
layout = "us";
|
||||||
|
variant = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable CUPS to print documents.
|
||||||
|
services.printing.enable = true;
|
||||||
|
|
||||||
|
# Enable sound with pipewire.
|
||||||
|
services.pulseaudio.enable = false;
|
||||||
|
security.rtkit.enable = true;
|
||||||
|
services.pipewire = {
|
||||||
|
enable = true;
|
||||||
|
alsa.enable = true;
|
||||||
|
alsa.support32Bit = true;
|
||||||
|
pulse.enable = true;
|
||||||
|
# If you want to use JACK applications, uncomment this
|
||||||
|
#jack.enable = true;
|
||||||
|
|
||||||
|
# use the example session manager (no others are packaged yet so this is enabled by default,
|
||||||
|
# no need to redefine it in your config for now)
|
||||||
|
#media-session.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable touchpad support (enabled default in most desktopManager).
|
||||||
|
# services.xserver.libinput.enable = true;
|
||||||
|
|
||||||
|
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||||
|
users.users.test = {
|
||||||
|
isNormalUser = true;
|
||||||
|
description = "test";
|
||||||
|
extraGroups = [ "networkmanager" "wheel" ];
|
||||||
|
packages = with pkgs; [
|
||||||
|
kdePackages.kate
|
||||||
|
nodejs
|
||||||
|
git
|
||||||
|
neovim
|
||||||
|
# thunderbird
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Install firefox.
|
||||||
|
programs.firefox.enable = true;
|
||||||
|
virtualisation.virtualbox.guest.enable = true;
|
||||||
|
# Allow unfree packages
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
|
# List packages installed in system profile. To search, run:
|
||||||
|
# $ nix search wget
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
|
||||||
|
# wget
|
||||||
|
];
|
||||||
|
|
||||||
|
# Some programs need SUID wrappers, can be configured further or are
|
||||||
|
# started in user sessions.
|
||||||
|
# programs.mtr.enable = true;
|
||||||
|
# programs.gnupg.agent = {
|
||||||
|
# enable = true;
|
||||||
|
# enableSSHSupport = true;
|
||||||
|
# };
|
||||||
|
|
||||||
|
# List services that you want to enable:
|
||||||
|
|
||||||
|
# Enable the OpenSSH daemon.
|
||||||
|
# services.openssh.enable = true;
|
||||||
|
|
||||||
|
# Open ports in the firewall.
|
||||||
|
# networking.firewall.allowedTCPPorts = [ ... ];
|
||||||
|
# networking.firewall.allowedUDPPorts = [ ... ];
|
||||||
|
# Or disable the firewall altogether.
|
||||||
|
# networking.firewall.enable = false;
|
||||||
|
|
||||||
|
# This value determines the NixOS release from which the default
|
||||||
|
# settings for stateful data, like file locations and database versions
|
||||||
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||||
|
# this value at the release version of the first install of this system.
|
||||||
|
# Before changing this value read the documentation for this option
|
||||||
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||||
|
system.stateVersion = "25.11"; # Did you read the comment?
|
||||||
|
|
||||||
|
}
|
||||||
Generated
+48
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"home-manager": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1774738535,
|
||||||
|
"narHash": "sha256-2jfBEZUC67IlnxO5KItFCAd7Oc+1TvyV/jQlR+2ykGQ=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"rev": "769e07ef8f4cf7b1ec3b96ef015abec9bc6b1e2a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1774386573,
|
||||||
|
"narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"home-manager": "home-manager",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
description = "luodh 的 NixOS 终极配置";
|
||||||
|
|
||||||
|
# 输入(也就是原材料供应链)
|
||||||
|
inputs = {
|
||||||
|
# 这里我们使用 nixos-unstable 分支,因为你之前用 CachyOS,大概率喜欢较新的内核和软件
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
# 引入 Home Manager
|
||||||
|
home-manager = {
|
||||||
|
url = "github:nix-community/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs"; # 保证 Home Manager 用的软件版本和系统一致
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# 输出(最终建成的系统)
|
||||||
|
outputs = { self, nixpkgs, home-manager, ... }@inputs: {
|
||||||
|
nixosConfigurations = {
|
||||||
|
# 这里的 "nixos" 是你的系统主机名 (hostname)。
|
||||||
|
# 如果你在安装系统时改过主机名,请把这里的 "nixos" 换成你的实际主机名。
|
||||||
|
"nixos" = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [
|
||||||
|
# 1. 引入系统底层的硬件和全局配置
|
||||||
|
./configuration.nix
|
||||||
|
|
||||||
|
({ config, pkgs, ... }: {
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
# 调用我们之前写的 derivation,并将其命名为 claude-code
|
||||||
|
claude-code = final.callPackage ./pkgs/claude.nix { };
|
||||||
|
})
|
||||||
|
];
|
||||||
|
})
|
||||||
|
|
||||||
|
# 2. 把 Home Manager 作为系统模块请进来
|
||||||
|
home-manager.nixosModules.home-manager
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
|
||||||
|
# ⚠️ 极其重要:把这里的 "luodh" 替换成你在 NixOS 里登录的实际系统用户名
|
||||||
|
home-manager.users.test = import ./home.nix;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
|
# and may be overwritten by future invocations. Please make changes
|
||||||
|
# to /etc/nixos/configuration.nix instead.
|
||||||
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "ehci_pci" "ahci" "sd_mod" "sr_mod" ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
fileSystems."/" =
|
||||||
|
{ device = "/dev/disk/by-uuid/a4dec1b6-8027-46c5-b143-0fc9ea1e2ef7";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/boot" =
|
||||||
|
{ device = "/dev/disk/by-uuid/0115-3C19";
|
||||||
|
fsType = "vfat";
|
||||||
|
options = [ "fmask=0077" "dmask=0077" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices = [ ];
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
virtualisation.virtualbox.guest.enable = true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
# ⚠️ 极其重要:替换成你的实际系统用户名
|
||||||
|
home.username = "test";
|
||||||
|
home.homeDirectory = "/home/test";
|
||||||
|
|
||||||
|
# 允许安装闭源软件(比如 QQ)
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
|
# 你的个人日常软件全写在这里!
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
qq
|
||||||
|
fastfetch
|
||||||
|
claude-code
|
||||||
|
# 你还可以加上其他软件,比如网易云、微信等
|
||||||
|
];
|
||||||
|
|
||||||
|
# 以后你的 niri、KDE 等 dotfiles 配置都可以通过这种方式管理
|
||||||
|
# home.file.".config/niri/config.kdl".source = ./niri-config.kdl;
|
||||||
|
|
||||||
|
# 这个版本号不要改!它不是软件版本,而是系统状态标识
|
||||||
|
home.stateVersion = "23.11";
|
||||||
|
|
||||||
|
|
||||||
|
# 让 Home Manager 管理自己
|
||||||
|
programs.home-manager.enable = true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
pkgs.stdenv.mkDerivation rec {
|
||||||
|
pname = "claude-code";
|
||||||
|
# 根据您之前的截图,我们锁定该版本以保证可复现性
|
||||||
|
version = "2.1.87";
|
||||||
|
|
||||||
|
# 直接从 GCS Bucket 抓取二进制文件,绕过 bash 脚本
|
||||||
|
src = pkgs.fetchurl {
|
||||||
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-x64/claude";
|
||||||
|
|
||||||
|
# 提示:首次构建时,您可以将 hash 填为 lib.fakeHash
|
||||||
|
# Nix 会报错并告诉您正确的 SHA-256 哈希值,然后将其填入此处即可
|
||||||
|
hash = "sha256-saW4lGmGKt7g5NwoyrWoMUvE0BF+Gasmp7f/fOm1m9U=";
|
||||||
|
};
|
||||||
|
|
||||||
|
# 引入 autoPatchelfHook 自动修复 ELF 文件的动态链接
|
||||||
|
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
|
||||||
|
|
||||||
|
# 添加运行该二进制所需的常见 C 标准库
|
||||||
|
# 如果运行后提示缺失某些 .so 文件,可在此处追加对应的依赖包
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
stdenv.cc.cc.lib
|
||||||
|
zlib
|
||||||
|
];
|
||||||
|
|
||||||
|
# 因为下载的是单一二进制文件,不需要解压源码
|
||||||
|
dontUnpack = true;
|
||||||
|
|
||||||
|
# 安装阶段:将其放入 Nix 标准的 bin 目录下
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp $src $out/bin/claude
|
||||||
|
chmod +x $out/bin/claude
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with pkgs.lib; {
|
||||||
|
description = "Claude Code CLI";
|
||||||
|
homepage = "https://claude.ai";
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user