diff --git a/.gitignore b/.gitignore index fb0b6e93..5bfded21 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ # created when `just run ` is used /test/data +/nix/cargo-doc-live/target + # created when `just run ex-*` is used /example/share-services/pgweb/data/ /example/simple/data/ diff --git a/nix/cargo-doc-live/Cargo.lock b/nix/cargo-doc-live/Cargo.lock new file mode 100644 index 00000000..a56d7e2c --- /dev/null +++ b/nix/cargo-doc-live/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "simple" +version = "0.0.0" diff --git a/nix/cargo-doc-live/Cargo.toml b/nix/cargo-doc-live/Cargo.toml new file mode 100644 index 00000000..f6ae897e --- /dev/null +++ b/nix/cargo-doc-live/Cargo.toml @@ -0,0 +1,2 @@ +[package] +name = "simple" diff --git a/nix/cargo-doc-live_test.nix b/nix/cargo-doc-live/cargo-doc-live_test.nix similarity index 100% rename from nix/cargo-doc-live_test.nix rename to nix/cargo-doc-live/cargo-doc-live_test.nix diff --git a/nix/cargo-doc-live.nix b/nix/cargo-doc-live/default.nix similarity index 55% rename from nix/cargo-doc-live.nix rename to nix/cargo-doc-live/default.nix index 12d8a833..dd474c98 100644 --- a/nix/cargo-doc-live.nix +++ b/nix/cargo-doc-live/default.nix @@ -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. @@ -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"; }; diff --git a/nix/cargo-doc-live/src/main.rs b/nix/cargo-doc-live/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/nix/cargo-doc-live/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/nix/default.nix b/nix/default.nix index 45e89d24..3828370d 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -22,6 +22,6 @@ in ./tempo.nix ./weaviate.nix ./searxng.nix - ./cargo-doc-live.nix + ./cargo-doc-live ]; } diff --git a/test/flake.nix b/test/flake.nix index 7bc7a035..fce64adf 100644 --- a/test/flake.nix +++ b/test/flake.nix @@ -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"