Skip to content

Commit

Permalink
Add missing inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
leomayleomay committed Jun 22, 2024
1 parent 7e2eb09 commit 109a6db
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# created when `just run <service>` is used
/test/data

/nix/cargo-doc-live/target

# created when `just run ex-*` is used
/example/share-services/pgweb/data/
/example/simple/data/
Expand Down
7 changes: 7 additions & 0 deletions nix/cargo-doc-live/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions nix/cargo-doc-live/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[package]
name = "simple"
File renamed without changes.
43 changes: 26 additions & 17 deletions nix/cargo-doc-live.nix → nix/cargo-doc-live/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@ in
readOnly = true;
default = {
processes =
let
browser-sync = lib.getExe pkgs.nodePackages.browser-sync;
cargo-watch = lib.getExe pkgs.cargo-watch;
cargo = lib.getExe pkgs.cargo;
in
{
"${name}-cargo-doc" = {
command = builtins.toString (pkgs.writeShellScript "cargo-doc" ''
run-cargo-doc() {
${cargo} doc --document-private-items --all-features
${browser-sync} reload --port ${toString config.port} # Trigger reload in browser
}; export -f run-cargo-doc
${cargo-watch} watch -s run-cargo-doc
'');

command = pkgs.writeShellApplication {
name = "cargo-doc";
runtimeInputs = with pkgs; [ cargo cargo-watch nodePackages.browser-sync ];
text =
let
browser-sync = lib.getExe pkgs.nodePackages.browser-sync;
cargo-watch = lib.getExe pkgs.cargo-watch;
cargo = lib.getExe pkgs.cargo;
in
''
run-cargo-doc() {
${cargo} doc --document-private-items --all-features
${browser-sync} reload --port ${toString config.port} # Trigger reload in browser
}; export -f run-cargo-doc
${cargo-watch} watch -s run-cargo-doc
'';
};
readiness_probe = {
period_seconds = 1;
failure_threshold = 100000; # 'cargo doc' can take quite a while.
Expand All @@ -55,10 +59,15 @@ in
availability.restart = "on_failure";
};
"${name}-browser-sync" = {
command = ''
${browser-sync} start --port ${toString config.port} --ss target/doc -s target/doc \
--startPath /${config.crateName}/
'';
command = pkgs.writeShellApplication {
name = "browser-sync";
runtimeInputs = with pkgs; [ nodePackages.browser-sync ];
text =
''
${lib.getExe pkgs.nodePackages.browser-sync} start --port ${toString config.port} --ss target/doc -s target/doc \
--startPath /${config.crateName}/
'';
};
namespace = name;
depends_on."${name}-cargo-doc".condition = "process_healthy";
};
Expand Down
3 changes: 3 additions & 0 deletions nix/cargo-doc-live/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
2 changes: 1 addition & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ in
./tempo.nix
./weaviate.nix
./searxng.nix
./cargo-doc-live.nix
./cargo-doc-live
];
}
2 changes: 1 addition & 1 deletion test/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"${inputs.services-flake}/nix/cassandra_test.nix"
"${inputs.services-flake}/nix/tempo_test.nix"
"${inputs.services-flake}/nix/weaviate_test.nix"
"${inputs.services-flake}/nix/cargo-doc-live_test.nix"
"${inputs.services-flake}/nix/cargo-doc-live/cargo-doc-live_test.nix"
] ++ lib.optionals pkgs.stdenv.isLinux [
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/316954
"${inputs.services-flake}/nix/grafana_test.nix"
Expand Down

0 comments on commit 109a6db

Please sign in to comment.