Skip to main content

ProfileManager

Struct ProfileManager 

Source
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

Source

pub fn new(profile_dir: impl Into<PathBuf>, name: impl Into<String>) -> Self

Create a new profile manager.

§Arguments
  • profile_dir — directory containing profile symlinks
  • name — profile name (e.g., "system")
Source

pub fn system() -> Self

System profile manager using default paths.

Source

pub fn profile_path(&self) -> PathBuf

Path to the main profile symlink (e.g., /nix/var/nix/profiles/system).

Source

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.

Source

pub fn list_generations(&self) -> Result<Vec<Generation>, ProfileError>

List all generations, sorted by number.

Source

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.

Source

pub fn switch_generation(&self, gen_num: u32) -> Result<(), ProfileError>

Switch to a specific existing generation number.

Source

pub fn rollback(&self) -> Result<u32, ProfileError>

Rollback to the previous generation.

Returns the generation number that was switched to.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more