Skip to main content

Nixos

Struct Nixos 

Source
pub struct Nixos {
    paths: Paths,
    lock: Arc<Mutex<()>>,
    budget: GcBudget,
}

Fields§

§paths: Paths§lock: Arc<Mutex<()>>§budget: GcBudget

Implementations§

Source§

impl Nixos

Source

fn activate_live_inner( &self, g: GenerationId, op: &OpId, slow: Option<(Duration, bool)>, ) -> Outcome

slow (gym hooks only): the activation unit first sleeps this long, and if uncancellable, ignores being stopped; it is the unit that is slow, so it outlives the daemon like a real long activation.

Source

pub fn new(paths: Paths) -> Nixos

Source

pub fn with_budget(self, budget: GcBudget) -> Nixos

The §12b bounds (services.planarian.gc).

Source

fn profile_generations(&self) -> Vec<(u64, String)>

The system profile’s generations: (profile number, store path).

Source

fn prune_roots(&self, profile: &[(u64, String)], protect: &[GenerationId])

Roots that no longer hold anything Planarian needs, removed before a collection so it can free what the profile no longer keeps (§9 step 5, §12b): a build root whose candidate is a profile generation (the profile link roots it from commit on, and a collected one must go), and a gen-<n> root for a generation no longer protected.

Source

fn age_out_roots_at(&self, now: SystemTime) -> Vec<String>

Build roots older than PARKING_GRACE (by the link’s own time): no transaction can still be waiting on them, so they are a crashed or abandoned build’s (C4).

Source

fn plan_profile( &self, protect: &[GenerationId], emergency: bool, ) -> Result<(GcPlan, Vec<(u64, String)>), Outcome>

Plan over profile numbers. Protected generations are the profile entries whose store path is a protected generation’s.

Source

fn boot_menu_path(&self) -> PathBuf

The store path the boot menu was last installed for.

Source

fn profile_generation(&self) -> Option<u64>

The boot menu is the one for path: as recorded after the last successful install, or, before any (a machine installed before this record existed), when path is the system that booted. The number of the profile generation the profile link points at (system-<n>-link).

Source

fn boot_menu_for(&self, path: &str) -> bool

Source

fn report_path(&self) -> PathBuf

Source

fn registry_path(&self) -> PathBuf

Source

fn with_registry<R>( &self, f: impl FnOnce(&mut Registry) -> R, ) -> Result<R, Outcome>

Source

fn override_file(&self, root: &Path) -> PathBuf

Source

fn store_dir(&self) -> PathBuf

Source

fn visible_files( &self, root: &Path, ) -> Result<(Vec<PathBuf>, Vec<String>), Outcome>

The owner’s Nix-visible files, and the untracked files left out.

Source

fn copy_owner(&self, root: &Path) -> Result<(PathBuf, Vec<String>), Outcome>

Copy the owner’s visible files into a fresh directory.

Source

fn flake_ref(&self, dir: &Path) -> String

Source

fn staged_dir(&self, source: &Hash) -> PathBuf

Source

fn unit_name(op: &OpId) -> String

Source

fn lock_dir(dir: &Path) -> Result<File>

§9 step 4 (I23, R11): an exclusive flock on a directory, held until the returned handle drops. The directory itself is locked, so nothing is added to the owner’s tree. Cooperating writers take the same lock; one that does not is outside I23 (docs/bypasses.md, X-12).

Source

fn lock_profile(&self) -> Result<File, Outcome>

Promote, restore and collect (the system profile and boot menu) are serialized across the daemon and the watchdog (§28, C5).

Source

fn prune_override_store( &self, keep_gens: &[GenerationId], now: SystemTime, ) -> Vec<String>

The content-addressed override store keeps what a generation still in the profile or protected references, the live file’s content, and anything remembered within PARKING_GRACE (a transaction still in flight has remembered its base and candidate but recorded neither). Everything else goes (§28, C5). Returns the pruned hashes.

Source

fn write_atomically(target: &Path, text: &str) -> Result<()>

Trait Implementations§

Source§

impl Clone for Nixos

Source§

fn clone(&self) -> Nixos

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Nixos

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl GenerationBackend for Nixos

Source§

fn created_by(&self, g: GenerationId) -> Option<(u32, Timestamp)>

The profile link’s owner and modification time (nixos-rebuild as root, or Planarian, which also runs as root: the journal tells those apart; this answers for rebuilds outside Planarian).

Source§

fn verify_candidate( &self, path: &StorePath, nar: Option<&Hash>, ) -> Result<bool, Outcome>

C6: the store path’s contents still hash to what the store recorded (nix-store --verify-path), and that is the NAR hash the transaction recorded when it built the candidate. Existence alone is not enough.

Source§

fn publish_boot_once( &self, g: GenerationId, keep: GenerationId, op: &OpId, ) -> Outcome

The boot-only path with systemd-boot (§12f): g gets its own profile generation and boot entry, keep is made the newest profile generation again (so the menu’s default stays keep), and the entry for g is set to boot once (bootctl set-oneshot). All or nothing: on any failure the profile is put back on keep’s boot menu.

Source§

fn one_shot_pending(&self) -> Result<Option<GenerationId>, Outcome>

The pending one-shot entry, from systemd-boot’s LoaderEntryOneShot EFI variable: nixos-generation-<n>.conf → the profile generation’s path.

Source§

fn current(&self) -> Result<GenerationId, Outcome>

Source§

fn boot_entries(&self) -> Result<Vec<GenerationId>, Outcome>

Source§

fn boot_default(&self) -> Result<GenerationId, Outcome>

Source§

fn last_booted(&self) -> Result<GenerationId, Outcome>

Source§

fn stage( &self, owner: &PinnedSource, overrides: &OverrideSet, ) -> Result<StagedSource, Outcome>

Source§

fn source_hash(&self, owner: &PinnedSource) -> Result<Hash, Outcome>

Recompute the NAR hash of the owner’s Nix-visible source now (stale check, §9 step 6).
Source§

fn untracked(&self, owner: &PinnedSource) -> Vec<String>

The owner’s files Nix cannot see now (untracked in a git flake), to report with the stale check: one added during the build was not there at staging (§9 step 1).
Source§

fn evaluate(&self, src: &StagedSource) -> Result<EvaluatedGeneration, Outcome>

Source§

fn build(&self, eval: &EvaluatedGeneration) -> Result<Built, Outcome>

Store-only; roots its own output.
Source§

fn dry_activation(&self, path: &StorePath) -> Result<ActivationPlan, Outcome>

What switching from the running generation to an existing one would start, stop, restart and reload (its dry activation), for SwitchGeneration / Revert / Rollback (§11, R04). An activation that failed, timed out or was cut short is an error, never a smaller plan.
Source§

fn pending_jobs(&self) -> Result<Vec<JobId>, Outcome>

Source§

fn jobs_tagged(&self, op: &OpId) -> Result<Option<Vec<JobId>>, Outcome>

None: the backend cannot say whether work tagged with op exists.
Source§

fn override_hash(&self) -> Result<Hash, Outcome>

The override file’s current content hash (promotion compares against it, §9 step 4).
Source§

fn activate_live(&self, g: GenerationId, op: &OpId) -> Outcome

switch-to-configuration test.
Source§

fn publish_boot(&self, g: GenerationId, op: &OpId) -> Outcome

Boot entry only; no re-activation.
Source§

fn protect(&self, g: GenerationId, op: &OpId) -> Outcome

Source§

fn cancel(&self, job: &JobId, op: &OpId) -> Outcome

Source§

fn swap_override(&self, from: &Hash, to: &Hash, op: &OpId) -> Outcome

Atomically replace the live override file with the content whose hash is to, but only if its current hash is from. Idempotent: if it already hashes to to, succeed without writing.
Source§

fn path_of(&self, g: GenerationId) -> Result<StorePath, Outcome>

The system store path of a known generation.
Source§

fn evaluate_built( &self, path: &StorePath, ) -> Result<EvaluatedGeneration, Outcome>

Evaluate an already-built generation from its store path (its exported manifest), for SwitchGeneration / Revert / Rollback.
Source§

fn read_overrides(&self) -> Result<(OverrideSet, Hash), Outcome>

The live override set and its content hash.
Source§

fn remember_override(&self, set: &OverrideSet) -> Result<Hash, Outcome>

Keep override content addressable by hash, so swap_override can write it.
Source§

fn override_for(&self, g: GenerationId) -> Result<Option<Hash>, Outcome>

The override content recorded for a generation when it was committed.
Source§

fn override_content(&self, h: &Hash) -> Result<OverrideSet, Outcome>

The override content remember_override kept under this hash.
Source§

fn record_override(&self, g: GenerationId, hash: &Hash) -> Result<(), Outcome>

Source§

fn gc_plan( &self, protect: &[GenerationId], emergency: bool, ) -> Result<GcPlan, Outcome>

What collect_garbage would delete now. Read-only.
Source§

fn space_report(&self) -> Option<SpaceReport>

The last collection’s result.
Source§

fn release_root(&self, root: &str) -> bool

Remove a GC root symlink this backend created.
Source§

fn age_out_build_roots(&self) -> Vec<String>

Remove build roots no transaction can still use: older than the longest a candidate may wait (§12f), a crashed build’s included. At startup and before every collection (§9 step 5, C4). Returns them.
Source§

fn collect_garbage( &self, protect: &[GenerationId], emergency: bool, op: &OpId, ) -> Outcome

Collect generations under the §12b bounds (gc::plan), never touching protect (I3), then collect store garbage. Mutating.

Auto Trait Implementations§

§

impl Freeze for Nixos

§

impl RefUnwindSafe for Nixos

§

impl Send for Nixos

§

impl Sync for Nixos

§

impl Unpin for Nixos

§

impl UnsafeUnpin for Nixos

§

impl UnwindSafe for Nixos

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.