From patchwork Tue Apr 8 12:24:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 41446 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DFDF327BC4B; Tue, 8 Apr 2025 13:26:36 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0918827BC49 for ; Tue, 8 Apr 2025 13:26:35 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u2829-0007ld-7z; Tue, 08 Apr 2025 08:26:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u281q-0007kL-3T for guix-patches@gnu.org; Tue, 08 Apr 2025 08:26:10 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u281j-0007mI-52 for guix-patches@gnu.org; Tue, 08 Apr 2025 08:26:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=EyzGZCC0CqeI9Jz31AlhReOZsMSlgZJ4CGhAy8uu+zk=; b=KJl2gtIsSCvmvIePUfdePtLuqy0Tn3DMUJfabBpYveC9LEwIW5FvRnxFYklJw602NX5Lx5rPBQnCu4YAc8bFq2hrewJPhivzMalamIw/wFKY4cTOcLIRxwZ2BgzcBXmK4vJPmOHRUI2txhuQdJuKxc+WkbRpohAdZ2VD0Uoxk9tEz/gTmOjokRwwevv18E5tTiAHcDBYnBN0G9uD6KXv6gpdpGBHQaRWyh10k9wCUsZCKyzCOoJNs+p0/7CXQ5IHqYvP4M/HbwVEsXusi4E/I4Kr0KoElkCFG6c1fEPsWWUQX+XHA6ZVmizG+ZAvwJdPmXRVeY7TmmyLBOsWJ26uew==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u281i-0001Hy-Sz for guix-patches@gnu.org; Tue, 08 Apr 2025 08:26:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77638] [PATCH 1/8] linux-container: Add #:mounts to =?utf-8?b?4oCYZXZhbC9jb250YWluZXLigJku?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 08 Apr 2025 12:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77638 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77638@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 77638-submit@debbugs.gnu.org id=B77638.17441151324784 (code B ref 77638); Tue, 08 Apr 2025 12:26:02 +0000 Received: (at 77638) by debbugs.gnu.org; 8 Apr 2025 12:25:32 +0000 Received: from localhost ([127.0.0.1]:59671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u281D-0001Ex-B0 for submit@debbugs.gnu.org; Tue, 08 Apr 2025 08:25:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57068) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2819-0001E6-RE for 77638@debbugs.gnu.org; Tue, 08 Apr 2025 08:25:28 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2813-0007c9-W6; Tue, 08 Apr 2025 08:25:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=EyzGZCC0CqeI9Jz31AlhReOZsMSlgZJ4CGhAy8uu+zk=; b=NgGrsy0872szfvu9+JYq wsdHkS+c71l2wNctp01/jgQ4naQ8v7n/edq8seIQeQQ8gXd4iYH08L2KfQZDVmEg9+jTI7zSjsS7u MA2nSZnVeHwNRIvPPlmNrGZV5+gUSnnx/i6HOWe9sRUPVYLG2jxbXJex4Wn6yCcBNqF8NguOU0h8n 4FMQvkMyRXJvUIh17V6K3M9FH7+uCIUjS0bhtmeHv6s4wETzpCRss76OrO/38ubSUEiDPpB+op7Qi d6hZGKJ2aXk9DCGVeUz3puWuuwcFO26lYUy5vRjHR98GDMz+5Tu0MJKaPMevmiW/i68j/4WaSYSCf edhdzzcwGAKbPQ==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 8 Apr 2025 14:24:41 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/system/linux-container.scm (eval/container): Add #:mounts parameter and honor it. Change-Id: I1d5970f53a3d67db93e937e392f9bf36e75d1573 --- gnu/system/linux-container.scm | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index c1705f491c..3622328500 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 David Thompson -;;; Copyright © 2016-2017, 2019-2023 Ludovic Courtès +;;; Copyright © 2016-2017, 2019-2023, 2025 Ludovic Courtès ;;; Copyright © 2019 Arun Isaac ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2020 Google LLC @@ -319,13 +319,14 @@ (define* (container-script os #:key (mappings '()) shared-network?) (define* (eval/container exp #:key (mappings '()) + (mounts '()) (namespaces %namespaces) (guest-uid 0) (guest-gid 0)) "Evaluate EXP, a gexp, in a new process executing in separate namespaces as -listed in NAMESPACES. Add MAPPINGS, a list of , to the -set of directories visible in the process's mount namespace. Inside the -namespaces, run code as GUEST-UID and GUEST-GID. Return the process' exit -status as a monadic value. +listed in NAMESPACES. Add MOUNTS, a list of , and MAPPINGS, a +list of , to the set of directories visible in the +process's mount namespace. Inside the namespaces, run code as GUEST-UID and +GUEST-GID. Return the process' exit status as a monadic value. This is useful to implement processes that, unlike derivations, are not entirely pure and need to access the outside world or to perform side @@ -342,13 +343,14 @@ (define* (eval/container exp (mbegin %store-monad (built-derivations inputs) (mlet %store-monad ((closure ((store-lift requisites) items))) - (return (call-with-container (map file-system-mapping->bind-mount - (append (map (lambda (item) - (file-system-mapping - (source item) - (target source))) - closure) - mappings)) + (return (call-with-container (append mounts + (map file-system-mapping->bind-mount + (append (map (lambda (item) + (file-system-mapping + (source item) + (target source))) + closure) + mappings))) (lambda () (apply execl (string-append (derivation-input-output-path