From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:38069) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvg1e-0004I5-4x for guix-patches@gnu.org; Thu, 08 Aug 2019 06:52:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvg1c-0006Aa-Oq for guix-patches@gnu.org; Thu, 08 Aug 2019 06:52:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59388) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvg1a-00069l-Kd for guix-patches@gnu.org; Thu, 08 Aug 2019 06:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hvg1a-0005Bf-Hc for guix-patches@gnu.org; Thu, 08 Aug 2019 06:52:02 -0400 Subject: [bug#36952] [PATCH v2] machine: Implement 'roll-back-machine'. Resent-Message-ID: References: <87v9v94067.fsf@sdf.lonestar.org> <87v9v8ohvq.fsf@dustycloud.org> <87v9v8k82l.fsf_-_@sdf.lonestar.org> From: Ricardo Wurmus In-reply-to: <87v9v8k82l.fsf_-_@sdf.lonestar.org> Date: Thu, 08 Aug 2019 12:50:58 +0200 Message-ID: <87v9v8vskt.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: "Jakob L. Kreuze" Cc: 36952@debbugs.gnu.org Hi Jakob, > +(define (roll-back-managed-host machine) > + "Internal implementation of 'roll-back-machine' for MACHINE instances = with > +an environment type of 'managed-host." > + (define remote-exp > + (with-extensions (list guile-gcrypt) > + (with-imported-modules (source-module-closure '((guix config) > + (guix profiles))) > + #~(begin > + (use-modules (guix config) > + (guix profiles)) > + > + (define %system-profile > + (string-append %state-directory "/profiles/system")) > + > + (define target-generation > + (relative-generation-spec->number %system-profile "-1")) Can we use =E2=80=9Crelative-generation=E2=80=9D or =E2=80=9Cprevious-gener= ation-number=E2=80=9D here? I think the stringified =E2=80=9C-1=E2=80=9D is kinda ugly, and the =E2=80= =9C*-spec=E2=80=9D procedure only exists to handle user input, which is provided as a string. > + (mlet* %store-monad ((boot-parameters (machine-boot-parameters machine= )) > + (_ -> (if (< (length boot-parameters) 2) > + (raise roll-back-failure))) > + (entries -> (map boot-parameters->menu-entry > + (list (second boot-parameters)))) > + (old-entries -> (map boot-parameters->menu-entry > + (drop boot-parameters 2))) > + (bootloader -> (operating-system-bootloader > + (machine-operating-system machine= ))) > + (bootcfg (lower-object > + ((bootloader-configuration-file-generat= or > + (bootloader-configuration-bootloader > + bootloader)) > + bootloader entries > + #:old-entries old-entries))) > + (eval -> (cut machine-remote-eval machine <>)) > + (remote-result (machine-remote-eval machine > + > remote-exp))) Is it on purpose that you aren=E2=80=99t using the previously defined =E2= =80=9Ceval=E2=80=9D here? -- Ricardo