aboutsummaryrefslogtreecommitdiff
path: root/guix/profiles.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-01-31 23:29:37 +0100
committerLudovic Courtès <ludo@gnu.org>2022-02-02 18:12:22 +0100
commit9679123ce083c69cdfd1505d95a4066d41280394 (patch)
treec163a7ca6978fc2da86801cc0b12e158b3874561 /guix/profiles.scm
parent62e3ba78afb8fc4e2b32cb55e18a7d6dcbb26bcb (diff)
downloadguix-9679123ce083c69cdfd1505d95a4066d41280394.tar
guix-9679123ce083c69cdfd1505d95a4066d41280394.tar.gz
guix system: 'describe' shows the running system, not the current one.
* guix/profiles.scm (generation-number): Add optional 'base-profile' parameter and use it. * guix/scripts/system.scm (process-command): Add "/run/current-system" as first argument to 'generation-number'. * doc/guix.texi (Invoking guix system): Clarify that 'guix system describe' shows the running system.
Diffstat (limited to 'guix/profiles.scm')
-rw-r--r--guix/profiles.scm13
1 files changed, 9 insertions, 4 deletions
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 1d354ecb78..96be421727 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
@@ -2037,9 +2037,14 @@ paths."
(make-regexp (string-append "^" (regexp-quote (basename profile))
"-([0-9]+)")))
-(define (generation-number profile)
- "Return PROFILE's number or 0. An absolute file name must be used."
- (or (and=> (false-if-exception (regexp-exec (profile-regexp profile)
+(define* (generation-number profile
+ #:optional (base-profile profile))
+ "Return PROFILE's number or 0. An absolute file name must be used.
+
+Optionally, if BASE-PROFILE is provided, use it instead of PROFILE to
+construct the regexp matching generations. This is useful in special cases
+like: (generation-number \"/run/current-system\" %system-profile)."
+ (or (and=> (false-if-exception (regexp-exec (profile-regexp base-profile)
(basename (readlink profile))))
(compose string->number (cut match:substring <> 1)))
0))