Skip to content

Commit 2176218

Browse files
committed
add man pages
1 parent 9c6218d commit 2176218

8 files changed

Lines changed: 79 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased] - yyyy-mm-dd
99

10+
### Added
11+
12+
- Manpages for `1` & `5`, including subcommands.
13+
1014
### Fixed
1115

1216
- Fix a bug where key permissions where being printed in decimal format instead

Cargo.lock

Lines changed: 19 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cli/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ thiserror = { workspace = true }
2323
enum-display-derive = "0.1.1"
2424
futures = "0.3.31"
2525
clap-num = "1.2.0"
26-
clap-markdown = "0.1.5"
2726
itertools = "0.14.0"
2827
dhat = "0.3.2"
2928
clap_complete = { version = "4.5.60", features = ["unstable-dynamic"] }
3029
owo-colors = { workspace = true }
3130
signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"] }
3231
signal-hook = "0.3.18"
32+
clap-markdown = "0.1.5"
33+
clap_mangen = "0.2.31"

crates/cli/default.nix

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,64 @@
1414
agents = lib.strings.concatMapStrings (
1515
system: "--set WIRE_KEY_AGENT_${cleanSystem system} ${(getSystem system).packages.agent} "
1616
) (import inputs.linux-systems);
17+
18+
options = pkgs.callPackage ../../doc/options.nix { };
19+
20+
cliManpage = pkgs.runCommand "cli-manpage" { } ''
21+
mkdir $out
22+
23+
${lib.getExe' self'.packages.wire-unwrapped-dev "wire"} apply --roff $out
24+
'';
1725
in
1826
{
1927
packages = {
2028
default = self'.packages.wire;
21-
wire-unwrapped = buildRustProgram {
29+
30+
wire-unwrapped-dev = buildRustProgram {
2231
name = "wire";
2332
pname = "wire";
2433
cargoExtraArgs = "-p wire";
2534
doCheck = true;
35+
CARGO_PROFILE = "dev";
2636
nativeBuildInputs = [
27-
pkgs.installShellFiles
2837
pkgs.sqlx-cli
2938
];
3039
preBuild = ''
3140
export DATABASE_URL=sqlite:./db.sqlite3
3241
sqlx database create
3342
sqlx migrate run --source ./crates/core/src/cache/migrations/
3443
'';
44+
};
45+
46+
wire-unwrapped = self'.packages.wire-unwrapped-dev.overrideAttrs (old: {
47+
CARGO_PROFILE = "release";
48+
nativeBuildInputs = old.nativeBuildInputs ++ [
49+
pkgs.installShellFiles
50+
pkgs.ronn
51+
];
3552
postInstall = ''
3653
installShellCompletion --cmd wire \
3754
--bash <(COMPLETE=bash $out/bin/wire) \
3855
--fish <(COMPLETE=fish $out/bin/wire) \
3956
--zsh <(COMPLETE=zsh $out/bin/wire)
40-
'';
41-
};
4257
43-
wire-unwrapped-dev = self'.packages.wire-unwrapped.overrideAttrs {
44-
CARGO_PROFILE = "dev";
45-
};
58+
mkdir -p $out/share/man/man1/
59+
mkdir -p $out/share/man/man5/
60+
61+
cp ${options} wire.5
62+
cp ${cliManpage}/* $out/share/man/man1/
63+
64+
ronn -r \
65+
--manual="Module Options" \
66+
--name="wire" \
67+
--section="5" \
68+
--date="2026-01-1" \
69+
-o $out/share/man/man5/ \
70+
wire.5
71+
72+
rm wire.5
73+
'';
74+
});
4675

4776
wire-unwrapped-perf = buildRustProgram {
4877
name = "wire";

crates/cli/src/cli.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use wire_core::hive::node::{Goal as HiveGoal, HandleUnreachable, Name, SwitchToC
1515
use wire_core::hive::{Hive, get_hive_location};
1616

1717
use std::io::IsTerminal;
18+
#[cfg(debug_assertions)]
19+
use std::path::PathBuf;
1820
use std::{
1921
fmt::{self, Display, Formatter},
2022
sync::Arc,
@@ -58,6 +60,10 @@ pub struct Cli {
5860
#[cfg(debug_assertions)]
5961
#[arg(long, hide = true, global = true)]
6062
pub markdown_help: bool,
63+
64+
#[cfg(debug_assertions)]
65+
#[arg(long, hide = true, global = true)]
66+
pub roff: Option<PathBuf>,
6167
}
6268

6369
#[derive(Clone, Debug)]

crates/cli/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ async fn main() -> Result<()> {
6565
return Ok(());
6666
}
6767

68+
#[cfg(debug_assertions)]
69+
if let Some(path) = args.roff {
70+
clap_mangen::generate_to(Cli::command(), path).unwrap();
71+
return Ok(());
72+
}
73+
6874
if !check_nix_available() {
6975
miette::bail!("Nix is not available on this system.");
7076
}

doc/options.nix

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ let
2020
};
2121
};
2222

23-
optionsMd =
24-
(nixosOptionsDoc {
25-
inherit (eval) options;
26-
}).optionsCommonMark;
23+
options = nixosOptionsDoc {
24+
inherit (eval) options;
25+
};
2726
in
2827
runCommand "options-doc.md" { } ''
29-
cat ${optionsMd} > $out
28+
cat ${options.optionsCommonMark} > $out
3029
sed -i -e '/\*Declared by:\*/,+1d' $out
3130
''

doc/package.nix

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
lib,
3-
nixosOptionsDoc,
4-
runCommand,
2+
callPackage,
53
wire-small-dev,
64
nix,
75
nodejs,
@@ -11,31 +9,7 @@
119
...
1210
}:
1311
let
14-
eval = lib.evalModules {
15-
modules = [
16-
../runtime/module/options.nix
17-
{
18-
options._module.args = lib.mkOption {
19-
internal = true;
20-
};
21-
}
22-
];
23-
specialArgs = {
24-
name = "‹node name›";
25-
nodes = { };
26-
};
27-
};
28-
29-
optionsMd =
30-
(nixosOptionsDoc {
31-
inherit (eval) options;
32-
}).optionsCommonMark;
33-
34-
optionsDoc = runCommand "options-doc.md" { } ''
35-
cat ${optionsMd} > $out
36-
sed -i -e '/\*Declared by:\*/,+1d' $out
37-
'';
38-
12+
optionsDoc = callPackage ./options.nix { };
3913
pkg = builtins.fromJSON (builtins.readFile ./package.json);
4014
in
4115
stdenv.mkDerivation (finalAttrs: {

0 commit comments

Comments
 (0)