This commit is contained in:
2025-04-20 12:11:32 +08:00
parent f44d3c2d1a
commit 54f7e868ee

View File

@@ -5,6 +5,11 @@
inputs.impermanence.nixosModules.impermanence inputs.impermanence.nixosModules.impermanence
]; ];
# 系统启动时确保持久化目录存在
system.activationScripts.persistent-dirs.text = ''
mkdir -p /nix/persistent
'';
# 启用 tmpfs 作为根文件系统 # 启用 tmpfs 作为根文件系统
fileSystems."/" = lib.mkForce{ fileSystems."/" = lib.mkForce{
device = "none"; device = "none";
@@ -12,6 +17,20 @@
options = [ "defaults" "size=2G" "mode=755" ]; options = [ "defaults" "size=2G" "mode=755" ];
}; };
# 将 /nix 存储在持久化分区
fileSystems."/nix" = lib.mkForce{
device = "/nix/persistent/nix";
fsType = "btrfs";
options = [ "compress-force=zstd" ];
};
# 建议的 fstab 配置
fileSystems."/nix/persistent" = {
device = "/dev/disk/by-label/nixos-persistent"; # 需要根据实际情况修改
fsType = "btrfs";
neededForBoot = true;
};
# 配置持久化存储 # 配置持久化存储
environment.persistence."/nix/persistent" = { environment.persistence."/nix/persistent" = {
# 不在文件管理器中显示这些挂载点 # 不在文件管理器中显示这些挂载点
@@ -61,23 +80,6 @@
}; };
}; };
# 系统启动时确保持久化目录存在
system.activationScripts.persistent-dirs.text = ''
mkdir -p /nix/persistent
'';
# 建议的 fstab 配置
fileSystems."/nix/persistent" = {
device = "/dev/disk/by-label/nixos-persistent"; # 需要根据实际情况修改
fsType = "ext4";
neededForBoot = true;
};
# 将 /nix 存储在持久化分区
fileSystems."/nix" = {
device = "/nix/persistent/nix";
fsType = "btrfs";
options = [ "bind" ];
};
} }