From 8c2b1dfc6eb1d3ab27a37061ad069a2ca95590a1 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 7 Jul 2025 14:15:33 +0800 Subject: [PATCH] feat(nixos): move persist options to system and users modules --- nix/modules/machine/root/ephemeral.nix | 6 ------ nix/modules/system.nix | 2 ++ nix/modules/users.nix | 2 ++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/nix/modules/machine/root/ephemeral.nix b/nix/modules/machine/root/ephemeral.nix index 8ccb62b..04bc67c 100644 --- a/nix/modules/machine/root/ephemeral.nix +++ b/nix/modules/machine/root/ephemeral.nix @@ -18,18 +18,12 @@ in fi ''; 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" - ]; }) ]; }; diff --git a/nix/modules/system.nix b/nix/modules/system.nix index c2af5c0..2989756 100644 --- a/nix/modules/system.nix +++ b/nix/modules/system.nix @@ -1,5 +1,7 @@ { flake.modules.nixos.default = { + persistFiles = [ "/etc/machine-id" ]; + persistDirs = [ "/var/lib/systemd" ]; system.stateVersion = "25.11"; }; flake.modules.homeManager.default = diff --git a/nix/modules/users.nix b/nix/modules/users.nix index de640b3..c6e74e6 100644 --- a/nix/modules/users.nix +++ b/nix/modules/users.nix @@ -13,6 +13,8 @@ in # nix.settings.trusted-users = [ "@wheel" ]; #TODO: move ssh key settings elsewhere # users.users.root.openssh.authorizedKeys.keys = [ owner.pubkey ]; + # persist uids and gids + persistDirs = [ "/var/lib/nixos" ]; users = { mutableUsers = false; groups.users.gid = 100;