kellnr_settings/docs.rs
1use provcfg::{ClapArgs, Configurable};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Clone, Configurable, ClapArgs)]
5#[serde(default)]
6#[configurable(clap_prefix = "docs")]
7pub struct Docs {
8 /// Enable documentation hosting
9 ///
10 /// Building docs runs the build scripts and proc macros of every
11 /// published crate on the Kellnr host. See `build_wrapper` before
12 /// enabling this for publishers you do not fully trust.
13 pub enabled: bool,
14
15 /// Max docs size in MB
16 pub max_size: usize,
17
18 /// Max duration of a single rustdoc build in seconds (0 = unlimited).
19 /// Builds that take longer are killed and the crate is skipped.
20 pub build_timeout_seconds: u64,
21
22 /// Command prefix (comma-separated) for the rustdoc build process.
23 ///
24 /// Building docs compiles the published crate, which runs its build
25 /// scripts and proc macros. Kellnr runs every build in a child process
26 /// with a cleared environment, so no `KELLNR_*` settings or secrets are
27 /// passed on. Cargo's own `CARGO_*` variables are kept, so a registry
28 /// token in `CARGO_REGISTRIES_<NAME>_TOKEN` is visible to build scripts
29 /// and should belong to a dedicated read-only user.
30 /// The build still runs as the Kellnr user: it can read every
31 /// file Kellnr can read (for example the config file or the `SQLite`
32 /// database, e.g. via `include_str!`) and it has network access. Only
33 /// enable docs for crates you trust, or set a wrapper that confines the
34 /// build, e.g. with bubblewrap:
35 /// `["bwrap", "--ro-bind", "/", "/", "--tmpfs", "<data_dir>",
36 /// "--bind", "<data_dir>/doc_queue", "<data_dir>/doc_queue",
37 /// "--bind", "<cargo_home>", "<cargo_home>", "--tmpfs", "/etc/kellnr",
38 /// "--dev", "/dev", "--proc", "/proc", "--tmpfs", "/tmp",
39 /// "--unshare-pid", "--die-with-parent", "--"]`.
40 /// The wrapper is followed by the Kellnr binary and its arguments.
41 #[configurable(env_list)]
42 #[arg(value_delimiter = ',')]
43 pub build_wrapper: Vec<String>,
44}
45
46impl Default for Docs {
47 fn default() -> Self {
48 Self {
49 enabled: false,
50 max_size: 100,
51 build_timeout_seconds: 1800,
52 build_wrapper: Vec::new(),
53 }
54 }
55}