-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration for common programs #10
Comments
Sorry for not replying earlier to this. It sounds like a great idea! I think we could even go further with it and automatically figure out what to persist based on what NixOS options are enabled, or at least default our options to the relevant NixOS option value. |
One idea on how to make this work, at least for the NixOS module, would be to design it to look like {
environment.persistence = {
stateDirectory = "/example/state";
directories = [ "/etc/example" "/var/lib/example" ];
};
} Then we could have a number of The main loss here is the ability to have multiple state directories. Another alternative is letting users set a What do you think @talyz? |
I'm leaning toward the latter alternative, but was thinking we could let the user decide this on a submodule / persistent path level, so an example config would look like {
environment.persistence."/persistent" = {
presets = {
enable = true;
bluetooth = false;
};
directories = [
"/var/lib/additional_directory/bluetooth"
];
files = [
"/etc/my_important_file"
];
};
} The The duplicate check should really be done by comparing all the |
I am interested in doing that and am willing to start the process. That said, I am pretty new to the Nix ecosystem, so I am at a bit of a loss where to start. Any pointers towards the first step? |
Candidates for special configurationMachine IDThis is simply defined with Clock fileOn systems without an RTC (e.g. a Raspberry Pi), the SSH host keysThis snippet persists the host keys for {
environment.persistence."<dir>".files =
lib.concatMap (key: [ key.path (key.path + ".pub") ]) config.services.openssh.hostKeys;
} This is nontrivial and a good candidate for defining once. A config setting like QuestionsAliasingThe clock file and SSH host keys are examples where the same kind of state could be managed by different services. For example,
DefaultsThe whole point of
|
I don't think bind mounts work in this case, actually: systemd generates new machine-id before the bind mount is finished. Or at least, I had that problem a few months ago. My solution was to use a symlink instead, it works great. I think we should implement #99 for NixOS as well, because there might be other software that conflicats with bind mounts.
I am not sure that works, too. I think I had problems trying to bind mount the SSH keys. I haven't tried symlinks; my solution was to redefine I can't speak about the clock file, I don't have a RPI. But my system that persist
I think it should not, but due to a slightly different reason than what you might imagine. I think there are definitely reasonable defaults that Impermanence should suggest. I don't think it should ever enable them (unless we are talking strictly about symlinks), since bind mounts are destructive. If you've started persisting
You brought up a good point, so don't mind if I'll use it! That problem solves itself if we just don't enable any presets by default. But I think it is a good idea to suggest using several persistence directories. Currently, I see the following categories for the data worth persisting:
I think that it's a good idea to do presets with these categories in mind. It would be also pretty nice if the docs would suggest that layout and show examples with it. I'm not currently working on the PR that would implement presets API. I tried, but I failed miserably because I'm just not good enough at Nix. But I can share some knowledge and know-how about things that should probably go into design, so if someone makes a PR - please do ping me, I'll try to help however I can! |
I've opened a draft PR that aims to implement presets. While it's still a very early stage, feedback is very welcome #108 |
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
What about instead of doing this just for this project, it can also be done for nixos configuration as a whole? There is already a bootspec project (NixOS RFC 0125: https://github.com/NixOS/rfcs/blob/master/rfcs/0125-bootspec.md), which standartizes nixos way of listing bootloader entries, what about persistencespec? Then most of the work might be offloaded to nixos module authors themselves, every file to be stored should be described in nixos module itself, i.e postgresql module should define # Entries like this can even be produced by systemd module itself, when service
# declares StateDirectory (It can even handle DynamicUser with its /var/lib/private state dir)
persistent.postgresql = {
directories = ["/var/lib/postgresql"];
meta.kind = lib.persistence.systemdStateDir;
}; Those entries then can be used in manual for nixos itself, for some backup solutions, and of course, for impermanence. Impermanence then would extend persistent.postgresql.storageClass = "main";
environment.persistence."/persistent".classes = ["main"]; |
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10
TODO: * Look at for more inspiration nix-community/impermanence#108 * Do home-manager * Common files nix-community/impermanence#10 * Useful config: https://github.com/chayleaf/dotfiles/blob/f77271b249e0c08368573c22a5c34f0737d3a766/system/modules/impermanence.nix
TODO: * Do home-manager * Look at for more inspiration github.com:nix-community/impermanence/pull/108 * Common files github.com:nix-community/impermanence/issues/10 * Useful config: github.com:chayleaf/dotfiles/blob/f77271b249e0c08368573c22a5c34f0737d3a766/system/modules/impermanence.nix
TODO: * Do home-manager * Look at for more inspiration github.com:nix-community/impermanence/pull/108 * Common files github.com:nix-community/impermanence/issues/10 * Useful config: github.com:chayleaf/dotfiles/blob/f77271b249e0c08368573c22a5c34f0737d3a766/system/modules/impermanence.nix
TODO: * Do home-manager * Look at for more inspiration github.com:nix-community/impermanence/pull/108 * Common files github.com:nix-community/impermanence/issues/10 * Useful config: github.com:chayleaf/dotfiles/blob/f77271b249e0c08368573c22a5c34f0737d3a766/system/modules/impermanence.nix
TODO: * Do home-manager * Look at for more inspiration github.com:nix-community/impermanence/pull/108 * Common files github.com:nix-community/impermanence/issues/10 * Useful config: github.com:chayleaf/dotfiles/blob/f77271b249e0c08368573c22a5c34f0737d3a766/system/modules/impermanence.nix
I haven't thought this through, but what about supplementing the
files=
anddirectories=
withprograms=
orservices=
which would know thatbluetooth=true
means persist/var/lib/bluetooth
andnetworkManager=true
means persist/var/lib/NetworkManager/system-connections
and so on?
This has the advantage that "what files does this program need to persist" can be figured out by the community once instead of by each user individually.
The text was updated successfully, but these errors were encountered: