articles/SP-NixOS-diagrams/state-diagram.puml

77 lines
3.7 KiB
Plaintext

@startuml
title SP NixOS state diagram
hide empty description
state "Ubuntu state" as ubuntu_state
state "SP NixOS" as sp_nixos {
state "clean state" as clean_state
clean_state : * /etc/nixos = /etc/selfprivacy/nixos-config-source
clean_state : * system @ profile<sub>N</sub>
clean_state : * bootloader @ profile<sub>N</sub>
clean_state : * all services up
state "modified config state" as modified_state
modified_state : * /etc/nixos ≠ /etc/selfprivacy/nixos-config-source
modified_state : * system @ profile<sub>N</sub>
modified_state : * bootloader @ profile<sub>N</sub>
modified_state : * all services up
state "new profile <color:red>failed activation</color> state" as new_profile_failed_activation_state
new_profile_failed_activation_state : * /etc/nixos = /etc/selfprivacy/nixos-config-source
new_profile_failed_activation_state : * system @ profile<sub>N+1</sub>
new_profile_failed_activation_state : * bootloader @ profile<sub>N+1</sub>
new_profile_failed_activation_state : * some <color:red>services failed
state "old profile <color:red>without activation</color> state" as old_profile_no_activation_state
old_profile_no_activation_state : * /etc/nixos = /etc/selfprivacy/nixos-config-source
old_profile_no_activation_state : * system @ profile<sub>N-1</sub>
old_profile_no_activation_state : * <color:red>bootloader @ profile<sub>N</sub>
old_profile_no_activation_state : * <color:red>no services reload
/'
' state "new profile <color:red>failed bootloader state" as new_profile_failed_bootloader_state
' new_profile_failed_bootloader_state : * /etc/nixos = /etc/selfprivacy/nixos-config-source
' new_profile_failed_bootloader_state : * system @ profile<sub>N+1</sub>
' new_profile_failed_bootloader_state : * <color:red>bootloader @ profile<sub>N</sub>
' new_profile_failed_bootloader_state : * all services up
'/
[*] --> clean_state : boot
clean_state --> modified_state : <u>modify by API:\n""userdata.json""\n""sp-modules/flake.nix""\n<u>NixOS & SP modules update:\n""flake.lock""\n
modified_state -u-> modified_state : \n\n\n\n\n\n\nnixos-rebuild switch\n<color:red>build\n<color:red>failure
modified_state -u-> modified_state : nixos-rebuild switch\n<color:red>bootloader\n<color:red>update\n<color:red>failure
modified_state -l-> new_profile_failed_activation_state : nixos-rebuild switch\n<color:red>activation\n<color:red>failure
clean_state -u-> clean_state : \nrollback\nto profile<sub>N-1</sub>
clean_state -l-> old_profile_no_activation_state : rollback\n<color:red>bootloader\n<color:red>update\n<color:red>failure
old_profile_no_activation_state -l-> [*] : <color:red>99% chance disk is full!\n<color:red>do something?\nreboot?
new_profile_failed_activation_state -u-> clean_state : rollback\nto profile<sub>N-1</sub>
state "new state" as new_state
new_state : * /etc/nixos = /etc/selfprivacy/nixos-config-source
new_state : * system @ profile<sub>N+1</sub>
new_state : * bootloader @ profile<sub>N+1</sub>
new_state : * <b><color:darkred>all services up?
modified_state --> new_state : nixos-rebuild switch\n@ profile<sub>N+1</sub>
new_state -u-> clean_state : <b><u>selftest\n<b><color:green>OK</color></b> => do nothing\n<b><color:red>FAIL</color></b> => <b>rollback
/'
' new_state --u-> clean_state : <b>selftest\n<b><color:red>FAIL => rollback
'/
}
[*] -r-> ubuntu_state : boot
ubuntu_state --> sp_nixos
note on link
nixos-infect
---
<- ""https://releases.nixos.org/nix/nix-${NIX_VERSION}/install""
<- ""https://git.selfprivacy.org/selfprivacy/selfprivacy-nixos-infect""
end note
' <- ""https://git.selfprivacy.org/selfprivacy/selfprivacy-nixos-config""
footer %date("yyyy-MM-dd'T'HH:mmZ")
@enduml