feat(nixos): make persist options
This commit is contained in:
parent
a83523bbf1
commit
a6fdc1b6e6
2 changed files with 66 additions and 23 deletions
|
@ -1,23 +1,14 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib) mkMerge mkIf mkAfter;
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.default =
|
||||
{ hostName, ... }:
|
||||
let
|
||||
inherit (config.flake.manifest.hosts.nixos.${hostName}.machine) root;
|
||||
in
|
||||
{
|
||||
imports = [ inputs.impermanence.nixosModules.impermanence ];
|
||||
config = mkMerge [
|
||||
# Ephemeral by default - assumes btrfs
|
||||
(mkIf (root.ephemeral or true) {
|
||||
(mkIf (config.flake.manifest.hosts.nixos.${hostName}.machine.root.ephemeral or true) {
|
||||
boot.initrd.postDeviceCommands = mkAfter ''
|
||||
mkdir /btrfs_tmp
|
||||
mount /dev/root_vg/root /btrfs_tmp
|
||||
|
@ -26,18 +17,19 @@ in
|
|||
btrfs subvolume delete "/btrfs_tmp/root"
|
||||
fi
|
||||
'';
|
||||
programs.fuse.userAllowOther = true;
|
||||
fileSystems."/persist".neededForBoot = true;
|
||||
environment.persistence."/persist" = {
|
||||
hideMounts = true;
|
||||
files = [
|
||||
"/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"
|
||||
"/etc/machine-id"
|
||||
];
|
||||
};
|
||||
persistFiles = [
|
||||
#TODO: move to system config
|
||||
"/etc/machine-id"
|
||||
#TODO: move to ssh config
|
||||
"/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"
|
||||
];
|
||||
persistDirs = [
|
||||
"/var/lib/systemd"
|
||||
"/var/lib/nixos"
|
||||
];
|
||||
})
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue