From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Services and access to the global configuration Date: Sun, 30 Nov 2014 12:34:12 +0100 Message-ID: <87mw78sz0r.fsf_-_@gnu.org> References: <87ppc7106v.fsf@gnu.org> <87r3wm1aoq.fsf@gmail.com> <87y4qtwxaz.fsf@gnu.org> <878uithrsa.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv2lg-0004kU-CA for guix-devel@gnu.org; Sun, 30 Nov 2014 06:34:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xv2lb-00058C-IW for guix-devel@gnu.org; Sun, 30 Nov 2014 06:34:20 -0500 Received: from hera.aquilenet.fr ([2a01:474::1]:44168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv2lb-00057y-3U for guix-devel@gnu.org; Sun, 30 Nov 2014 06:34:15 -0500 In-Reply-To: <878uithrsa.fsf@gmail.com> (=?utf-8?B?IuWui+aWh+atpiIncw==?= message of "Sun, 30 Nov 2014 19:05:57 +0800") 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+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org =E5=AE=8B=E6=96=87=E6=AD=A6 skribis: > Ludovic Court=C3=A8s writes: > >> =E5=AE=8B=E6=96=87=E6=AD=A6 skribis: >> >>> Ludovic Court=C3=A8s writes: >>> >>>> Adam Pribyl skribis: [...] >>> I just put it in my config.scm: >>> >>> (define (console-layout-service layout) >>> (with-monad %store-monad >>> (return >>> (service >>> (document "Setup keyboard layout for console") >>> (provision '(console-layout)) >>> (start #~(lambda _ >>> (system* (string-append #kbd "/bin/loadkeys") #$layou= t))) >>> (stop #~(const #t)) >>> (respawn? #f))))) >> >> Excellent. I was thinking that we should have a keyboard layout setting >> in the OS declaration, that would lead to a service like the one above >> as well as the appropriate X settings. > Currently, operating-system is not declarative, with the setting: > (operating-system > (keymap "dvorak")) > IIUC, the xorg-server service can't see it unless passed explicitly. Right. > In NixOS, declarative configuration is implemented by 'modules': > https://nixos.org/wiki/NixOS:Modules >=20=20=20 > Every module can define some options, access and contrib to the config, > the configuration.nix is just a normal module provided by user. > > Yeah, how all the modules eval toghether is still a mystery for me. Yes, that=E2=80=99s the whole point. I don=E2=80=99t want an =E2=80=98mkIf= =E2=80=99 here. ;-) There are several issues here. 1. Is it desirable for any service to be able to touch any part of the OS configuration, as is the case in NixOS? I=E2=80=99m not sure. On = one hand, it=E2=80=99s useful in situations like the one above; on the oth= er hand, it feels like each service definition would get more authority than it really needed. Currently, the type has fields such as =E2=80=98user-account= s=E2=80=99 and =E2=80=98pam-services=E2=80=99 for that reason: a service can add = new accounts or PAM services, but does not access the global OS config. These would not be needed if services had access to the global config. 2. Services typically need to be able to add files to the store, etc. Currently, that means that services must be monadic values in the store monad. This is slightly annoying, because indeed it makes it feel =E2=80=9Cle= ss declarative.=E2=80=9D 3. In NixOS there=E2=80=99s no type checking: one can just add fields to = the global configuration attribute set, and they may be picked up by service definitions. Here, =E2=80=98operating-system=E2=80=99 is a well-defined type, and service-specific options are passed as arguments to procedures that implement the service. Just random thoughts. :-) I feel there are things we can improve, but it=E2=80=99s not completely cle= ar how yet. Thanks, Ludo=E2=80=99.