!DBFhtjpqmJNENpLDOv:nixos.org

NixOS systemd

599 Members
NixOS ❤️ systemd165 Servers

Load older messages


SenderMessageTime
11 Oct 2024
@emilazy:matrix.orgemilybut there are a variety of ways to phrase that right now & most of them aren't nice18:34:12
@arianvp:matrix.orgArianFeels like we want something like Context in React/SwiftUI18:34:18
@emilazy:matrix.orgemily like I'd prefer services to expose the interface and the policy modules to consume that interface 18:34:32
@emilazy:matrix.orgemilyrather than the interface being implicit as a result of asking modules to interfere with policy18:34:41
@emilazy:matrix.orgemilywhich is bad layering in my view18:34:46
@emilazy:matrix.orgemily (modules are global so this is purely theoretically-justified, but: it's also bad for encapsulation/security; in an ideal object-capability world a module setting up an OpenSSH daemon would have no ability to change your firewall settings) 18:35:22
@emilazy:matrix.orgemily(but the firewall settings would always be able to consume information from the OpenSSH service that it freely offers)18:35:34
@emilazy:matrix.orgemily(this doesn't matter in NixOS as we have it, but drives my intuition for why I don't love the way we currently do it)18:35:53
@raitobezarius:matrix.orgraitobezariusLiminix offers that separation and it doesn't spark joy neither20:00:32
@raitobezarius:matrix.orgraitobezariusI feel like it boils down again to NixOS module being a first class citizen in the language level and introducing ocap in there20:01:07
@emilazy:matrix.orgemilydo you have an example of how Liminix does it?20:05:08
@emilazy:matrix.orgemily(and agreed that we can't solve it without starting over but we can at least use the design principles to drive how we make new APIs)20:05:28
@raitobezarius:matrix.orgraitobezarius
In reply to @emilazy:matrix.org
do you have an example of how Liminix does it?
https://www.liminix.org/doc/configuration.html#writing-services
20:55:07
@emilazy:matrix.orgemilythanks. too global still :(21:07:07
@arianvp:matrix.orgArianAt work we use functions that produce NixOS configs when we don't want global Behaviour. You use the nice type checking from the module system though...21:15:25
@arianvp:matrix.orgArian* At work we use functions that produce NixOS configs when we don't want globaly overridaeable Behaviour. You use the nice type checking from the module system though...21:15:38
@arianvp:matrix.orgArianThose modules can still set read only options for consumption by other modules21:15:53
@arianvp:matrix.orgArianBut they can't be modified by other modules21:16:02
@emilazy:matrix.orgemilyservices not being functions is the original sin of NixOS21:16:03
@emilazy:matrix.orgemilyif NixOS configurations were assembled more like Nix packages, everything would be better21:16:26
@emilazy:matrix.orgemilyinstead everything is a global singleton that has access to everything else21:16:37
@emilazy:matrix.orgemilyit's absurd how many of the good properties we throw away for OS config21:16:48
@arianvp:matrix.orgArianSo we just do `import ./myservice { foo = bar;} `21:17:24
@arianvp:matrix.orgArianAnd then the service will expose foo as options.foo with readOnly true21:17:43
@arianvp:matrix.orgArian* And then the service will expose foo as options.myservice.foo with readOnly true21:17:58
@arianvp:matrix.orgArian

basically this:

{ config, ... }: {
  imports = [
    (import ./hostname { name = "google.com"; })
    (import ./service-a.nix { port = 8080; })
    (import ./service-.bnix {
      port = 9090;
      logLevel = "debug";
    })
    (import ./firewall.nix {
      allowedPorts = [ config.service-a.port config.service-b.port ];
    })
    (import ./nginx.nix {
      virtualHosts = {
        "service-a.${config.hostname.name}" = {
          location = "/";
          proxyPass = "http://localhost:${config.service-a.port}";
        };
      };
    })
  ];
}

21:23:24
@arianvp:matrix.orgArianand we still use module options in some rare cases where there are cross-cutting concerns21:23:57
@arianvp:matrix.orgArian now service-b can not change settings of service-a for example 21:27:29
@emilazy:matrix.orgemilyright21:29:12
@emilazy:matrix.orgemilycool21:29:13

Show newer messages


Back to Room ListRoom Version: 6