From 0ba88090bfe30e96abedab58228c8adc326277e2 Mon Sep 17 00:00:00 2001 From: Sayantan Chaudhuri Date: Tue, 17 Dec 2024 03:00:32 +0530 Subject: [PATCH] Persist files added to /etc past system updates in SteamOS 3.6+ (#1355) * Add atomic update persistence list for SteamOS 3.6+ * Apply suggestions from code review and fix pushing the actual list Co-authored-by: Cole Helbling * fixup: create atomic-update.conf.d entry only if directory exists * fixup: typo in variable name steamos, not streamos lol * fixup: path in test fixture --------- Co-authored-by: Cole Helbling --- src/planner/steam_deck.rs | 25 +++++++++++++++++++++++-- tests/fixtures/linux/steam-deck.json | 12 ++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/planner/steam_deck.rs b/src/planner/steam_deck.rs index dca2f4b36..269855091 100644 --- a/src/planner/steam_deck.rs +++ b/src/planner/steam_deck.rs @@ -254,10 +254,10 @@ impl Planner for SteamDeck { .map_err(PlannerError::Action)?; actions.push(create_bind_mount_unit.boxed()); } else { - let revert_clean_streamos_nix_offload = RevertCleanSteamosNixOffload::plan() + let revert_clean_steamos_nix_offload = RevertCleanSteamosNixOffload::plan() .await .map_err(PlannerError::Action)?; - actions.push(revert_clean_streamos_nix_offload.boxed()); + actions.push(revert_clean_steamos_nix_offload.boxed()); let ensure_steamos_nix_directory = EnsureSteamosNixDirectory::plan() .await @@ -270,6 +270,27 @@ impl Planner for SteamDeck { actions.push(start_nix_mount.boxed()); } + if std::path::Path::new("/etc/atomic-update.conf.d").exists() { + let create_atomic_update_buf = "\ + /etc/fish/conf.d/nix.fish\n\ + /etc/nix/**\n\ + /etc/profile.d/nix.sh\n\ + /etc/systemd/system/nix-daemon.socket\n\ + /etc/tmpfiles.d/nix-daemon.conf\n\ + "; + let create_atomic_update_unit = CreateFile::plan( + "/etc/atomic-update.conf.d/nix-installer.conf", + None, + None, + 0o0644, + create_atomic_update_buf.to_string(), + false, + ) + .await + .map_err(PlannerError::Action)?; + actions.push(create_atomic_update_unit.boxed()); + } + let ensure_symlinked_units_resolve_buf = "\ [Unit]\n\ Description=Ensure Nix related units which are symlinked resolve\n\ diff --git a/tests/fixtures/linux/steam-deck.json b/tests/fixtures/linux/steam-deck.json index 93e78ffdd..9a14c2fe3 100644 --- a/tests/fixtures/linux/steam-deck.json +++ b/tests/fixtures/linux/steam-deck.json @@ -55,6 +55,18 @@ }, "state": "Completed" }, + { + "action": { + "action_name": "create_file", + "path": "/etc/atomic-update.conf.d/nix-installer.conf", + "user": null, + "group": null, + "mode": 420, + "buf": "/etc/fish/conf.d/nix.fish\n/etc/nix/**\n/etc/profile.d/nix.sh\n/etc/systemd/system/nix-daemon.socket\n/etc/tmpfiles.d/nix-daemon.conf\n", + "force": false + }, + "state": "Completed" + }, { "action": { "action_name": "start_systemd_unit",