jail.nix/lib/combinators/network.nix
Alex David 6181276ae1 Split combinators into files
The `lib/combinators.nix` file was getting quite long and some ideas I
have for future combinators may even require ancillary files. To help
scale these changes, this commit breaks each combinator into its own
file under the `lib/combinators` directory.
2025-10-10 16:28:43 -07:00

37 lines
861 B
Nix

{ combinators, ... }:
let
inherit (combinators)
compose
escape
include-once
runtime-deep-ro-bind
share-ns
time-zone
unsafe-add-raw-args
write-text
;
in
{
sig = "Permission";
doc = ''
Grants network access to the jail.
This also exposes everything required to allow TLS connections.
You can set your desired hostname with [set-hostname](#set-hostname). The
default is `jail`.
'';
impl = include-once "network" (
state:
compose [
time-zone
(share-ns "net")
(runtime-deep-ro-bind "/etc/hosts")
(runtime-deep-ro-bind "/etc/nsswitch.conf")
(runtime-deep-ro-bind "/etc/resolv.conf")
(runtime-deep-ro-bind "/etc/ssl")
(write-text "/etc/hostname" "${state.hostname}\n")
(unsafe-add-raw-args "--hostname ${escape state.hostname}")
] state
);
}