From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id gLdkJzvTDWPlMQEAbAwnHQ (envelope-from ) for ; Tue, 30 Aug 2022 11:07:07 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id iJF4JzvTDWNPgQAA9RJhRA (envelope-from ) for ; Tue, 30 Aug 2022 11:07:07 +0200 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 ED89419DF8 for ; Tue, 30 Aug 2022 11:07:06 +0200 (CEST) Received: from localhost ([::1]:40186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSxD7-00025h-Pn for larch@yhetil.org; Tue, 30 Aug 2022 05:07:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSxCf-000248-Nf for guix-devel@gnu.org; Tue, 30 Aug 2022 05:06:37 -0400 Received: from nomad-cl1.staging.muradm.net ([139.162.159.157]:48480 helo=nomad-cl1.muradm.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSxCb-0000R5-7H for guix-devel@gnu.org; Tue, 30 Aug 2022 05:06:34 -0400 Received: from localhost ([127.0.0.1]:59826) by nomad-cl1.muradm.net with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1oSxCY-00017A-04; Tue, 30 Aug 2022 09:06:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=muradm.net; s=mail; h=Content-Type:MIME-Version:Message-ID:In-reply-to:Date:Subject:Cc:To :From:References:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1M7vZk0/shQ7LpbpEc4sD4c9SkU7NGkA7FrTuL7T4m4=; b=vKTWWB1uthrJMQMg638l/oZRe3 VVZe5C8qzffKH9Fk7mW1OabbKu4mQVb0n2sNVN2cQwapaqq/+80+syaR4QasuOp2zV80Bdpxgdi+r 8kdSlryCV4+22XvV5bQhfDb6wGuD679/JCxW33kgOdAOdacMn7jH/OR1mK94jvfg5xNZaDuux99lW E6dealauVFPREIP30ND2Dlj0SDdSlAv9XGyVRfMYy1jbTdDXLJjTMaD1ng3q+UjIHjeawmVVPBf2l RD3TPPRn2e6GaZWms+nuu5mmVqNI3FKIlGeobm7HPrT6qr8sD7qhiJpf2nfEzAUTxy8sCIKwI73QY ziuN5sS0Oaxpo5dS4HpLvSvI9iGv6ZCG76K7pgez+zNZPd39clU+CsmaNVx0tR2s3ecpCiQVNVUNo EMpCULzVv0SHwZi4un1b8SuaA0l81Fv3IN1PC8tb+HLXMIiLq82NWWmbdzJpu51FfV1zcEgW+/o3I gDGJ+JCIMrvBexxDv++kEaxB; Received: from muradm by localhost with local (Exim 4.96) (envelope-from ) id 1oSxCY-0000iq-1r; Tue, 30 Aug 2022 12:06:30 +0300 References: <87edwylxe9.fsf@gmail.com> User-agent: mu4e 1.8.9; emacs 29.0.50 From: muradm To: =?utf-8?Q?Th=C3=A9o?= Maxime Tyburn Cc: guix-devel@gnu.org Subject: Re: Idea: Function composition to declare operating-system Date: Tue, 30 Aug 2022 11:49:35 +0300 In-reply-to: <87edwylxe9.fsf@gmail.com> Message-ID: <87y1v6ksmh.fsf@muradm.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Received-SPF: pass client-ip=139.162.159.157; envelope-from=mail@muradm.net; helo=nomad-cl1.muradm.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661850427; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1M7vZk0/shQ7LpbpEc4sD4c9SkU7NGkA7FrTuL7T4m4=; b=jH5YbSLrwC20BUgja2Qm92nud+KFRf6hns/Xl4jvLVdC0CvzraIGqlZdHzG208QtJsF8BQ Tz1FWdZNsv8+Bb0DcPmma/aQfSn0tu2XsQXr/7yjvVdBidkM1XmrI2UwYjCi4NPAsZYpwm rMkHqsTv48r8svWJ3bZJtrY25eTMdLttM2yMLj1MlAzzX50eh9IV8AwouLLynfJxdy11Il N+lWjr+o1EEwUOI82X7KKM4m7ONiKZfUKA56ll5bGubQOFDMRFfcd+RoXW21SVAjD8rquU ZGB2zt7l4OI17JO9z+xOE3eTNYopbOzcUIhG85dfNk1SeaAv5N7jjN2gGikNCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661850427; a=rsa-sha256; cv=none; b=Pr9E8EoyHjfv5XFR6VnHLtsrx2amcruyGBGSAd+8UJsSoqetRJ1xurlondZIAnUr0/bZ6b FQu371jHCDVUtS022MSolth39/aa//44Kqhijkf226ts2tl9+2obwHmMmzFGdou/QNm+M4 xtpwiAUQdUv9na3Vi/1wNpC2yxr0U24BHPSHUcw3JD1mdGMCl6KljXI7+L1qdJ88dsKlZj gSwYIWxKfPeyCMZDQGazufRyUNJdRpaBFImS4raq9zJ4YDm7kJUVKcmbKHt3Qo3/88rHyZ mv15uXDzCMv72KPZ73tWUf6kTsAI2MlwkGvO0cT5jUsEDl/wtrrAnkZ6+lq+Qw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=muradm.net header.s=mail header.b=vKTWWB1u; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.99 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=muradm.net header.s=mail header.b=vKTWWB1u; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: ED89419DF8 X-Spam-Score: -0.99 X-Migadu-Scanner: scn0.migadu.com X-TUID: of2yrvvDezWM --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi, I had similar problem popping up periodically. So here are my 10 cents.. Th=C3=A9o Maxime Tyburn writes: > Hi guix! > [...] > > --BEGIN USE_CASE > For example to add jackd to my system I need to add the=20 > "realtime" > group, add some users to this group and add a=20 > pam-limits-service. If I > want to remove this functionality from my system using the=20 > declarative > approach I have to look down my config file for places where I=20 > added > these things. Usually I partially solve this problem by putting=20 > comments > to signal the purpose of each code block in the system=20 > declaration. > > But wouldn=E2=80=99t it be better if I just had a function `add-jackd`=20 > that takes an > operating-system instance and returns the os with the extra=20 > functionalities ? > --END USE_CASE To clarify, do you ask that in the end of the day, some where in (gnu services ...) there should be exported `add-jackd` function? If so, I beleive that this will increase cross dependency between things, thus decreasing flexibility. Imagine `add-jackd` maintainer should always keep track on what is being added into guix, that potentially may cause conflict with jackd and/or require adjustments in `add-jackd` function implementation. Also, IMHO, implementation of `add-jackd` would be very much opinionated. > > So that was the purpose of the experimentation. It didn=E2=80=99t turn=20 > out to be > too complicated to implement. At least for my use case, I just=20 > needed to add two helper > functions to extend users and services fields. The rest is=20 > handled directly by > record inheritance and by accessing the fields of the input=20 > operating-system. > > The final declaration looks like this: > > ((apply compose (reverse os-functions)) minimal-os) > [...] > > (define* (extend-operating-system-services os services #:key=20 > (drop '()) (keep '())) > (append (filter (lambda (service) > (not (member (service-type-name (service-kind=20 > service)) > (filter (lambda (s) (not (member=20 > s keep))) > (append drop=20 > %fixed-system-service-types))))) > (operating-system-services os)) > services)) > I suppose this could be useful to have it in guix toolbox, although I would prefer to have (required '(account activate ...)) or (required %fixed-system-service-types) optional argument, instead of refering to global constant=20 %fixed-system-service-types, which might not satisfy everyone requirements. > and also force keeping or dropping of some services if needed.=20 > The list > of services that gets duplicated seems to be this one: > > (define %fixed-system-service-types > '(account activate boot cleanup etc file-systems firmware=20 > fstab guix host-name linux-bare-metal linux-builder pam=20 > profile root-file-system session-environment setuid-program=20 > shepherd-root system user-processes)) > > I generated the list by just checking which services get=20 > duplicated, so I am not > very sure about it. There surely is a better way to get it. > > Anyway I can now define a function adding desktop=20 > functionalities: > > (define (x-os os) > (operating-system > (inherit os) > (services > (extend-operating-system-services > os > (list > ;; slim display manager > (service slim-service-type > (slim-configuration > (display ":0") > (vt "vt7") > (theme %default-slim-theme) > (theme-name %default-slim-theme-name) > (xorg-configuration > (xorg-configuration > (keyboard-layout=20 > (operating-system-keyboard-layout os))))))) > #:drop '(gdm))) > (packages (cons* > ;; window managers > i3-wm python-py3status > emacs-nc-exwm-xdg > (operating-system-packages os) > )))) > > Of course there is room for some macros to make this more=20 > elegant, but > this is the rough idea. > > In a way it feels like treating the operating-system like a=20 > service > you can extend. Maybe it would even make sense to implement this=20 > as a > service ? Not sure about that. > > It seems it would also be reasonable to have something like an > operating-system-configuration record and a way to compose some=20 > before > putting them into an operating-system record (it seems to be the > approach rde `features` are based on). But I felt too lazy to=20 > copy all the > fields from the operating-system record definition. There might=20 > be a > way to get all the fields programatically and define a > record/configuration though. > > Anyway, what do you think about this functionality? Have you=20 > already experimented with similar things? > Did I reinvent the wheel? Is there a better approach? Did you try using (modify-services ...)? Basically, you can achieve similar goal within services list only with it. > Anyway that was a very fun hacking session :) > > Happy Hacking! > > Th=C3=A9o Thanks in advance, muradm --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEESPY5lma9A9l5HGLP6M7O0mLOBeIFAmMN0xYACgkQ6M7O0mLO BeJz4RAAko4okWMcp6Dz6hIkGoj5LmcaoBcT102IqyXLfmtMkxPkBBdElQuRqENW 9ePIQluZ2xDoqZgGIHZqbA3UvFn506dJs6JKKVzlIYxutY6xo0a/pkGPHcvREx8B +TctzcXzhNFqUsZs8hi7Nvmd7/LVHdyB1MOaZkCEiX8W2xG1pN9k2XLlWJlp/rRs +8buITilezLYYZpzbXTRHPEoKRjYnDCsmumtjbxhJsLIdH6zgl2MmMmoH7OnPVkJ cqqYwgcsY2Tk9sxZUbGkiSOR0LmbDJ6J50FMqmNU5Mg9cL8W/GK89Yokz6HEtfnf qoBCVaSvX51mUKMb5Z4Nnlu4lCNpf8wnFaZYeXMyM3Wo61Gx7GxOi53aNf87khmY cREnqSxHOyS7Ey6pKTqq4/AIlx1BZo2NMEC69Ss7DjZDUSdtnHwvLjoS1LWe4S2B fMn9GLSPa5VOt+tgx8ZYcWu67QGr/aZChoH/U/pKUJBdTQXyprn08LcKPNmc3v6a AHiAdJ/0GRUglZF3JbCxjq6g36We6xdXDtPazJ4pNDy49QG1MEQwYnO6A0YQUzij CI0ezwER1oRy2wHEdcBtAI3yje8XNAUuojMM0UisNBT4kDEOJIWBmmQOCtnRokM9 LFo8hhXOUlhXKQumzwglo4DTfNpFidgfaNXIfHSDbfYEx8hBzvQ= =cvu4 -----END PGP SIGNATURE----- --=-=-=--