pub struct ProfileManager { /* private fields */ }Expand description
Manages a Nix-style symlink profile (e.g., system, per-user).
The profile lives as a symlink at {profile_dir}/{profile_name} pointing
to {profile_dir}/{profile_name}-{N}-link where N is the generation
number. Each generation link in turn points to a store path.
Implementations§
Source§impl ProfileManager
impl ProfileManager
Sourcepub fn new(profile_dir: impl Into<PathBuf>, name: impl Into<String>) -> Self
pub fn new(profile_dir: impl Into<PathBuf>, name: impl Into<String>) -> Self
Create a new profile manager.
§Arguments
profile_dir— directory containing profile symlinksname— profile name (e.g.,"system")
Sourcepub fn profile_path(&self) -> PathBuf
pub fn profile_path(&self) -> PathBuf
Path to the main profile symlink (e.g., /nix/var/nix/profiles/system).
Sourcepub fn current_generation(&self) -> Result<Option<u32>, ProfileError>
pub fn current_generation(&self) -> Result<Option<u32>, ProfileError>
Get the current generation number by reading the profile symlink.
Returns Ok(None) if the profile symlink does not exist yet.
Sourcepub fn list_generations(&self) -> Result<Vec<Generation>, ProfileError>
pub fn list_generations(&self) -> Result<Vec<Generation>, ProfileError>
List all generations, sorted by number.
Sourcepub fn set(&self, store_path: &Path) -> Result<u32, ProfileError>
pub fn set(&self, store_path: &Path) -> Result<u32, ProfileError>
Set the profile to a new store path, creating a new generation.
Returns the new generation number.
Sourcepub fn switch_generation(&self, gen_num: u32) -> Result<(), ProfileError>
pub fn switch_generation(&self, gen_num: u32) -> Result<(), ProfileError>
Switch to a specific existing generation number.
Sourcepub fn rollback(&self) -> Result<u32, ProfileError>
pub fn rollback(&self) -> Result<u32, ProfileError>
Rollback to the previous generation.
Returns the generation number that was switched to.
Sourcepub fn delete_generation(&self, gen_num: u32) -> Result<(), ProfileError>
pub fn delete_generation(&self, gen_num: u32) -> Result<(), ProfileError>
Delete a specific generation (remove the -N-link symlink).
Cannot delete the currently active generation.
Auto Trait Implementations§
impl Freeze for ProfileManager
impl RefUnwindSafe for ProfileManager
impl Send for ProfileManager
impl Sync for ProfileManager
impl Unpin for ProfileManager
impl UnsafeUnpin for ProfileManager
impl UnwindSafe for ProfileManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more