diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 76536daf49..32fbe8efbc 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -133,9 +133,19 @@ (define (populate-root-file-system system target) (directives (%store-directory))) ;; Add system generation 1. - (false-if-exception (delete-file "/var/guix/profiles/system-1-link")) - (symlink system - (string-append target "/var/guix/profiles/system-1-link"))) + (let ((generation-1 (string-append target + "/var/guix/profiles/system-1-link"))) + (let try () + (catch 'system-error + (lambda () + (symlink system generation-1)) + (lambda args + ;; If GENERATION-1 already exists, overwrite it. + (if (= EEXIST (system-error-errno args)) + (begin + (delete-file generation-1) + (try)) + (apply throw args))))))) (define (reset-timestamps directory) "Reset the timestamps of all the files under DIRECTORY, so that they appear