62 lines
1.3 KiB
Nix
62 lines
1.3 KiB
Nix
# 配置原子系统, 使用 tmpfs 作为根文件系统, 并配置持久化存储
|
|
{ inputs, config, pkgs, username, lib, ... }:
|
|
{
|
|
imports = [
|
|
inputs.impermanence.nixosModules.impermanence
|
|
];
|
|
|
|
# 启用 tmpfs 作为根文件系统
|
|
fileSystems."/" = lib.mkForce {
|
|
device = "tmpfs";
|
|
fsType = "tmpfs";
|
|
options = [ "relatime" "mode=755" ];
|
|
};
|
|
|
|
# 将 /nix 目录绑定到持久化存储
|
|
fileSystems."/nix" = lib.mkForce {
|
|
device = "/dev/disk/by-label/nixos"; # 需要根据实际情况修改
|
|
fsType = "btrfs";
|
|
options = [ "compress-force=zstd" ];
|
|
|
|
};
|
|
|
|
# 配置持久化存储
|
|
environment.persistence."/nix/persistent" = {
|
|
hideMounts = true;
|
|
directories = [
|
|
"/etc/nixos"
|
|
"/etc/NetworkManager/system-connections"
|
|
"/var/log"
|
|
"/var/lib"
|
|
"/root"
|
|
];
|
|
|
|
files = [
|
|
"/etc/machine-id"
|
|
"/etc/ssh/ssh_host_ed25519_key"
|
|
"/etc/ssh/ssh_host_ed25519_key.pub"
|
|
"/etc/ssh/ssh_host_rsa_key"
|
|
"/etc/ssh/ssh_host_rsa_key.pub"
|
|
];
|
|
|
|
users.${username} = {
|
|
directories = [
|
|
".config"
|
|
".cache"
|
|
".local"
|
|
".ssh"
|
|
".vscode"
|
|
".npm"
|
|
".nix"
|
|
"data"
|
|
"doc"
|
|
];
|
|
|
|
files = [
|
|
".zsh_history"
|
|
".gitconfig"
|
|
];
|
|
};
|
|
};
|
|
}
|