@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 @ profileN clean_state : * bootloader @ profileN clean_state : * all services up state "modified config state" as modified_state modified_state : * /etc/nixos ≠ /etc/selfprivacy/nixos-config-source modified_state : * system @ profileN modified_state : * bootloader @ profileN modified_state : * all services up state "new profile failed activation 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 @ profileN+1 new_profile_failed_activation_state : * bootloader @ profileN+1 new_profile_failed_activation_state : * some services failed state "old profile without activation 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 @ profileN-1 old_profile_no_activation_state : * bootloader @ profileN old_profile_no_activation_state : * no services reload /' ' state "new profile 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 @ profileN+1 ' new_profile_failed_bootloader_state : * bootloader @ profileN ' new_profile_failed_bootloader_state : * all services up '/ [*] --> clean_state : boot clean_state --> modified_state : modify by API:\n""userdata.json""\n""sp-modules/flake.nix""\nNixOS & SP modules update:\n""flake.lock""\n modified_state -u-> modified_state : \n\n\n\n\n\n\nnixos-rebuild switch\nbuild\nfailure modified_state -u-> modified_state : nixos-rebuild switch\nbootloader\nupdate\nfailure modified_state -l-> new_profile_failed_activation_state : nixos-rebuild switch\nactivation\nfailure clean_state -u-> clean_state : \nrollback\nto profileN-1 clean_state -l-> old_profile_no_activation_state : rollback\nbootloader\nupdate\nfailure old_profile_no_activation_state -l-> [*] : 99% chance disk is full!\ndo something?\nreboot? new_profile_failed_activation_state -u-> clean_state : rollback\nto profileN-1 state "new state" as new_state new_state : * /etc/nixos = /etc/selfprivacy/nixos-config-source new_state : * system @ profileN+1 new_state : * bootloader @ profileN+1 new_state : * all services up? modified_state --> new_state : nixos-rebuild switch\n@ profileN+1 new_state -u-> clean_state : selftest\nOK => do nothing\nFAIL => rollback /' ' new_state --u-> clean_state : selftest\nFAIL => 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