| rxp_gc | R Documentation |
This function performs garbage collection on Nix store paths and build log files
generated by rixpress. It can operate in two modes: full garbage collection
(when keep_since = NULL) or targeted deletion based on log file age.
rxp_gc(
keep_since = NULL,
project_path = ".",
dry_run = FALSE,
timeout_sec = 300,
verbose = FALSE,
ask = TRUE
)
keep_since |
Date or character string (YYYY-MM-DD format). If provided,
only build logs older than this date will be targeted for deletion, along
with their associated Nix store paths. If |
project_path |
Character string specifying the path to the project
directory containing the |
dry_run |
Logical. If |
timeout_sec |
Numeric. Timeout in seconds for individual Nix commands. Also used for concurrency lock expiration. Default is 300 seconds. |
verbose |
Logical. If |
ask |
Logical. If |
The function operates in two modes:
Full Garbage Collection Mode (keep_since = NULL):
Runs nix-store --gc to delete all unreferenced store paths
Does not delete any build log files
Suitable for complete cleanup of unused Nix store paths
Targeted Deletion Mode (keep_since specified):
Identifies build logs older than the specified date
Extracts store paths from old logs using rxp_inspect()
Protects recent store paths by creating temporary GC roots
Attempts to delete old store paths individually using nix-store --delete
Deletes the corresponding build log .json files from _rixpress/
Handles referenced paths gracefully (paths that cannot be deleted due to dependencies)
Concurrency Safety: The function uses a lock file mechanism to prevent multiple instances from running simultaneously, which could interfere with each other's GC root management.
Reference Handling: Some store paths may not be deletable because they are still referenced by:
User or system profile generations
Active Nix shell environments
Result symlinks in project directories
Other store paths that depend on them
These paths are reported but not considered errors.
Invisibly returns a list with cleanup summary information:
kept: Vector of build log filenames that were kept
deleted: Vector of build log filenames targeted for deletion
protected: Number of store paths protected via GC roots (date-based mode)
deleted_count: Number of store paths successfully deleted
failed_count: Number of store paths that failed to delete
referenced_count: Number of store paths skipped due to references
log_files_deleted: Number of build log files successfully deleted
log_files_failed: Number of build log files that failed to delete
dry_run_details: List of detailed information when dry_run = TRUE
rxp_list_logs, rxp_inspect
Other utilities:
print.rxp_derivation(),
rxp_check_chronicles(),
rxp_copy(),
rxp_init(),
rxp_inspect(),
rxp_list_logs(),
rxp_load(),
rxp_read(),
rxp_trace()
## Not run:
# Preview what would be deleted (dry run)
rxp_gc(keep_since = "2025-08-01", dry_run = TRUE, verbose = TRUE)
# Delete artifacts from builds older than August 1st, 2025
rxp_gc(keep_since = "2025-08-01")
# Full garbage collection of all unreferenced store paths
rxp_gc()
# Clean up artifacts older than 30 days ago
rxp_gc(keep_since = Sys.Date() - 30)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.