From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id IERxJRTjU2Z0jAAAA41jLg (envelope-from ) for ; Mon, 27 May 2024 03:34:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id oMg2HxTjU2b8sgAA62LTzQ (envelope-from ) for ; Mon, 27 May 2024 03:34:12 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=hoo3R1g0; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1716773652; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=CYZ+WMXtMglG61lVcueF2U5Wf65dEsTCepWl0FpyHOo=; b=OxUlR11Lcd5kW/eKztCIQ7CRNyk29DGBQzM6XvRY+t1LWmqTkISn+SPv0wQW5eK1vk7MQv hB5A6qPIEvVpVzIvUonp/xLE4sVd7qwAPcAqvGVIinOErx3ruzStAiAiLzJy8z3B33KD1Y gKaiJtNPuz71Zm+tSW+8A4pdtfLg1Vbiaubz6FUrPHuUpXpvRKTqtemx35PZa3WC7x5vUN d6/3T0kQlUxpkxl+4qgmf0/usft/qBSWB6NQrGa2TMqI1288N59Eh6rOWtgPx4mvvVzTNV 6AjRl0c4Q1AQxzUapm7pU1gDZN+xajOx1paa8qfEPuo2AsblBD+UaYcgBQcUCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1716773652; a=rsa-sha256; cv=none; b=H67RHzOMSt4NhdeygsrT6GLD0hhV5uvWTarMYz+W6bmAAXBHR7yZdw9elHl2+Pngg7Dsaw YAnvQZ4s8/Q7NPfJ7s34rkf2A3X9QxRgTNjPiOrGq2EilnmJaKhkOL60yJ6ekfslgRApTu WJf9yJuz8RIpAINbf9+ClHmxim4OV5uhIC0xs50iJCQaUipT9a+OiJPm4lvX51CRAug54x Z6JMIsB511m/7XaAU+J3Uu3RWpInpvOTyhgUhPE5U6eeC/wVfZQwrD5gALOsrrnXzQ9xiM DtZ6Hvh8ogXIRtnK/RZ2Nn8+chvAgFRazf9S/kf1kEtQsh0AL9+8A33Ynx2u2w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=hoo3R1g0; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1F2AD72992 for ; Mon, 27 May 2024 03:34:12 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBPFM-0002N0-C5; Sun, 26 May 2024 21:33:56 -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 1sBPFK-0002Mi-LE for guix-patches@gnu.org; Sun, 26 May 2024 21:33:54 -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 1sBPFK-00034S-DP for guix-patches@gnu.org; Sun, 26 May 2024 21:33:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sBPFS-0006QE-Iw for guix-patches@gnu.org; Sun, 26 May 2024 21:34:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71071] [PATCH] services: nix: Mount Nix store read only. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 27 May 2024 01:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71071 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Oleg Pykhalov Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 71071@debbugs.gnu.org Received: via spool by 71071-submit@debbugs.gnu.org id=B71071.171677361824628 (code B ref 71071); Mon, 27 May 2024 01:34:02 +0000 Received: (at 71071) by debbugs.gnu.org; 27 May 2024 01:33:38 +0000 Received: from localhost ([127.0.0.1]:42768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sBPF3-0006PA-JQ for submit@debbugs.gnu.org; Sun, 26 May 2024 21:33:37 -0400 Received: from mail-qv1-f51.google.com ([209.85.219.51]:44422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sBPF0-0006Om-V0 for 71071@debbugs.gnu.org; Sun, 26 May 2024 21:33:35 -0400 Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6ab9d00f727so15302846d6.1 for <71071@debbugs.gnu.org>; Sun, 26 May 2024 18:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716773541; x=1717378341; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CYZ+WMXtMglG61lVcueF2U5Wf65dEsTCepWl0FpyHOo=; b=hoo3R1g0JNuQq3pO82ZPuiYLVHh3TSzPqc8f+ztha2qm70aShTOk0gjUpiiCJscB/T c/fhea/Mg25jBbWZHV/lBG8pn2BrPskts4NVA+9DEoU44AivFrLomxW9rfefsOAiAZB5 ToBnq56AwqLv+mJl7nV0cPlrRc2q2dGc38SDUbpYmPSul6IR92C1ZJ2nfUBooqPHZb3H 9ELtCogdB4nonNZ9x+O2Lx/2ahkwUgWDhEcLChI4gWiVDhmWDU2tHHj8euDhmlJFJLEE Mw6GK4Z+VrJsCOlXGq1FcQ+QojP35hsruC2uf+iAUOpRHtOAJ/MXC+cWc4nsQhpclw+Y c/gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716773541; x=1717378341; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CYZ+WMXtMglG61lVcueF2U5Wf65dEsTCepWl0FpyHOo=; b=Te4X7hDNBxRRiFSVwhHe+MqiVZj+W0QL6sakO0QzyUAKh5wUYdg0dr0Xdf4R3J1TiW Fv5XoVZJw9lQ9/xdB8Q1zSOJYNJ9G9mjTek8CHdrcLNWE26E3mb2hmyhx2P0/UqBniNp MNNRAGeBL4/qtBUqv75Z4U9h9TJXLR9IV3yUs/D//tUx0mUwuAH1tEGtJhibkB7ts+j9 i2/cf7oxc9LY7YcfhgJkxFwMlmEaQp0LH7cbXixdciBKvsAMEnRsSQyk1lZgyQJkNlE+ e7IfMUP11BMCuBOM2R0BBQwQU+BZ12pB3EjlXVTq7YHHyEqgHW8Sk9I9b1BmCSUx9ND/ Sq3g== X-Gm-Message-State: AOJu0YyuU8+QKXMskECezodY5Hze4ZT77qTnVv+rWfudYnXs9E4GMP3B /vzRVCcf7TmcxwJ1nZZiXL3nYyAf+IkICwomJwjVtKAb2RrN4Amk X-Google-Smtp-Source: AGHT+IFnVbuxH98RF1TplT7LhymM/CW5NfiwYdIYs8YUnZ+r2mj0X0YDyAbH6orPahXHwNbSMn6VkA== X-Received: by 2002:a05:6214:2b9a:b0:6a3:5d84:e0a8 with SMTP id 6a1803df08f44-6abbbc5e9femr94307306d6.9.1716773540763; Sun, 26 May 2024 18:32:20 -0700 (PDT) Received: from hurd (dsl-153-139.b2b2c.ca. [66.158.153.139]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ad701d4312sm17014416d6.124.2024.05.26.18.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 18:32:20 -0700 (PDT) From: Maxim Cournoyer In-Reply-To: <13d78de1d27742605cf51fc0ed91b832cb5027c9.1716439103.git.go.wigust@gmail.com> (Oleg Pykhalov's message of "Thu, 23 May 2024 07:38:23 +0300") References: <87ttipdf5n.fsf@gnu.org> <13d78de1d27742605cf51fc0ed91b832cb5027c9.1716439103.git.go.wigust@gmail.com> Date: Sun, 26 May 2024 21:32:18 -0400 Message-ID: <87jzjgghul.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -2.24 X-Spam-Score: -2.24 X-Migadu-Queue-Id: 1F2AD72992 X-Migadu-Scanner: mx11.migadu.com X-TUID: QkTriV369GbA Hi Oleg, Oleg Pykhalov writes: > * gnu/services/nix.scm (nix-shepherd-service): Add requirements. > (%nix-store-directory): New variable. > (nix-service-type): Add file-system-service-type extension. > > Change-Id: I73c54ab8699a54be33fac6732d919c4844d1daa4 Nitpick: The Change-Id value shouldn't change between revisions of a change (so it should eb the same as in v1, which was I18a5d58c92c1f2b5b6dcecc3d5b439cc15bf4e49). > --- > gnu/services/nix.scm | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > diff --git a/gnu/services/nix.scm b/gnu/services/nix.scm > index 82853253f6..419e5968fe 100644 > --- a/gnu/services/nix.scm > +++ b/gnu/services/nix.scm > @@ -1,5 +1,5 @@ > ;;; GNU Guix --- Functional package management for GNU > -;;; Copyright =C2=A9 2019, 2020, 2021 Oleg Pykhalov > +;;; Copyright =C2=A9 2019, 2020, 2021, 2024 Oleg Pykhalov > ;;; Copyright =C2=A9 2020 Peng Mei Yu > ;;; > ;;; This file is part of GNU Guix. > @@ -26,6 +26,7 @@ (define-module (gnu services nix) > #:use-module (gnu services shepherd) > #:use-module (gnu services web) > #:use-module (gnu services) > + #:use-module (gnu system file-systems) > #:use-module (gnu system shadow) > #:use-module (guix gexp) > #:use-module (guix packages) > @@ -129,6 +130,20 @@ (define nix-service-etc > '#$build-sandbox-items)) > (for-each (cut display <>) '#$extra-config))))))))))) >=20=20 > +(define %nix-store-directory > + "/nix/store") > + > +(define %immutable-nix-store > + ;; Read-only store to avoid users or daemons accidentally modifying it. > + ;; 'nix-daemon' has provisions to remount it read-write in its own name > + ;; space. > + (list (file-system > + (device %nix-store-directory) > + (mount-point %nix-store-directory) > + (type "none") > + (check? #f) > + (flags '(read-only bind-mount))))) > + > (define nix-shepherd-service > ;; Return a for Nix. > (match-lambda > @@ -137,7 +152,7 @@ (define nix-shepherd-service > (shepherd-service > (provision '(nix-daemon)) > (documentation "Run nix-daemon.") > - (requirement '()) > + (requirement '(user-processes file-system-/nix/store)) > (start #~(make-forkexec-constructor > (list (string-append #$package "/bin/nix-daemon") > #$@extra-options) > @@ -156,7 +171,9 @@ (define nix-service-type > (service-extension activation-service-type nix-activation) > (service-extension etc-service-type nix-service-etc) > (service-extension profile-service-type > - (compose list nix-configuration-package)))) > + (compose list nix-configuration-package)) > + (service-extension file-system-service-type > + (const %immutable-nix-store)))) > (description "Run the Nix daemon.") > (default-value (nix-configuration)))) This LGTM, thanks to Ludo for suggesting this nice improvement in v2. --=20 Thanks, Maxim