Stream: services-flake

Topic: cargo-doc-live initial PR


view this post on Zulip Hao Liu (Jun 23 2024 at 23:59):

I am trying to integrate cargo-doc-live into services-flake, I added cargo-doc-live for nixci https://github.com/juspay/services-flake/pull/246/commits/7877ddc635eb45ebe0b71f02bc529065f06b6c5f#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0R31-R34, it errors out since it's not running the build in the example/cargo-doc-live directory

the error says:

cargo-doc-live-test> + process-compose --no-server -t=false
cargo-doc-live-test> [cargo-doc-live1-cargo-doc ] error: project root does not exist

any way I could run the nixci in the specified directory instead of top directory of services-flake?

view this post on Zulip Notification Bot (Jun 24 2024 at 00:26):

Srid has marked this topic as unresolved.

view this post on Zulip Srid (Jun 24 2024 at 00:52):

@Hao Liu It should not matter from which directory you run nix build <flake-url> (which is what nixci build does essentially) on, because nix builds are pure anyway.

view this post on Zulip Srid (Jun 24 2024 at 00:53):

error: project root does not exist

Where's this error originating from?

Take a look at how we set project root to the repo root in other places, e.g.: https://github.com/juspay/services-flake/blob/641937bc0f523405fbac4bb89c074de613dcee4d/dev/flake.nix#L26

view this post on Zulip Hao Liu (Jun 24 2024 at 00:54):

@Srid this is how I set the projectRoot in example https://github.com/juspay/services-flake/pull/246/files#diff-1cb9f37420e339a53fbd8b86243c074e2c4a3c93072a31a5ca73133054a63572R26

view this post on Zulip Hao Liu (Jun 24 2024 at 00:55):

the error error: project root does not exist is from cargo-watch when it could find a Rust project to watch on

view this post on Zulip Srid (Jun 24 2024 at 00:56):

This is where the flake check is defined: https://github.com/Platonic-Systems/process-compose-flake/blob/main/nix/process-compose/test.nix

view this post on Zulip Srid (Jun 24 2024 at 00:56):

Looks we need a cd there before running pc

view this post on Zulip Srid (Jun 24 2024 at 00:57):

More generally, what if our process-compose test depends on $PWD being set to something? That sounds like a feature request to https://github.com/Platonic-Systems/process-compose-flake repo

view this post on Zulip Hao Liu (Jun 24 2024 at 00:58):

you mean instead of hardcoded cd $HOME, introduce an option to enter a different directory like $PWD?

view this post on Zulip Srid (Jun 24 2024 at 01:00):

Haven't fully thought about it, but yes maybe something like that.

view this post on Zulip Srid (Jun 24 2024 at 01:00):

Or it could be something like preHook option we already have

view this post on Zulip Hao Liu (Jun 24 2024 at 01:08):

preHook = ''
  cd ${inputs.self}
'';

won't work due to permission issue,

✔ ~/services-flake/example/cargo-doc-live [add-cargo-doc-live|✚ 1…1]
11:07 $ result/bin/cargo-doc-live
+ process-compose --no-server
[cargo-doc-live1-cargo-doc  ] [Running 'run-cargo-doc']
[cargo-doc-live1-cargo-doc  ] error: Permission denied (os error 13) at path "/nix/store/a0vgclrrfn2svimc56k96m0nm0xvlndi-source/example/cargo-doc-live/targetwM02VI"

view this post on Zulip Srid (Jun 24 2024 at 01:11):

preHook = ''
  cp -r ${inputs.self} $HOME/project
  cd ~/project
'';

view this post on Zulip Hao Liu (Jun 24 2024 at 01:15):

image.png

view this post on Zulip Srid (Jun 24 2024 at 01:20):

Yes, writeShellApplication uses shellcheck, so the script should conform to it.

view this post on Zulip Hao Liu (Jun 24 2024 at 01:20):

ahh, no wonder :)

view this post on Zulip Hao Liu (Jun 24 2024 at 01:21):

the same permission issue after copying to my home dir

11:21 $ result/bin/cargo-doc-live
+ process-compose --no-server
[cargo-doc-live1-cargo-doc  ] [Running 'run-cargo-doc']
[cargo-doc-live1-cargo-doc  ] error: Permission denied (os error 13) at path "/home/hao/project/targetuijuhb"
[cargo-doc-live1-cargo-doc  ] Browsersync not running at http://localhost:8009

view this post on Zulip Hao Liu (Jun 24 2024 at 01:22):

should I introduce a chown?

view this post on Zulip Srid (Jun 24 2024 at 01:25):

Yes.

view this post on Zulip Hao Liu (Jun 24 2024 at 01:29):

chown $USER $HOME/project won't work ...

view this post on Zulip Hao Liu (Jun 24 2024 at 01:29):

and putting preHook in example/cargo-doc-live/flake.nix doesn't feel right since the user of the service should not bother to know that :D

view this post on Zulip Srid (Jun 24 2024 at 01:38):

chmod -R a+...

view this post on Zulip Srid (Jun 24 2024 at 01:38):

https://github.com/srid/haskell-flake/blob/3f76199d42d55e3a36bf8e8e0544e715d6a3f007/nix/modules/project/hls-check.nix#L23-L24

view this post on Zulip Srid (Jun 24 2024 at 01:39):

Hao Liu said:

and putting preHook in example/cargo-doc-live/flake.nix doesn't feel right since the user of the service should not bother to know that :D

I suggest doing this by hand then - i.e., write the flake check yourself, and then we can see how it can be abstracted out.

view this post on Zulip Hao Liu (Jun 24 2024 at 02:07):

@Srid copying the project to HOME will stop the realtime update from happening since the user is updating the doc in example/cargo-doc-live while the BrowserSync is watching the folder in HOME

view this post on Zulip Srid (Jun 24 2024 at 02:08):

When the flake check is built, where is the user involved?

view this post on Zulip Hao Liu (Jun 24 2024 at 02:09):

ahh, indeed, no user will involve at the testing stage

view this post on Zulip Srid (Jun 24 2024 at 02:15):

@Hao Liu This preHook stuff should be added to the test only, of course.

view this post on Zulip Srid (Jun 24 2024 at 02:16):

Which is why I suggested further above as to how this may well be a PR to process-compose-flake

view this post on Zulip Srid (Jun 24 2024 at 02:17):

But better to add flake check manually, because we don't know yet what the best API design here is.

view this post on Zulip Hao Liu (Jun 24 2024 at 02:17):

indeed

view this post on Zulip Srid (Jun 24 2024 at 02:28):

Hao Liu said:

indeed

You realize, this commit adds the preHook stuff to more than the test, right?

view this post on Zulip Srid (Jun 24 2024 at 02:28):

i.e., nix run is impacted too.

view this post on Zulip Hao Liu (Jun 24 2024 at 02:30):

yes, should only the checks to be impacted, right?

view this post on Zulip Srid (Jun 24 2024 at 02:31):

The whole point is to fix this test failure, is it not?

error: project root does not exist

This error occurs only in tests, does it not?

view this post on Zulip Hao Liu (Jun 24 2024 at 02:31):

yes, it's only there for test

view this post on Zulip Srid (Jun 24 2024 at 02:32):

So, do you see how that commit is not doing it only for test?

view this post on Zulip Hao Liu (Jun 24 2024 at 02:33):

I reckon I will move this under test package, will read process-compose-flake for how to

view this post on Zulip Hao Liu (Jun 24 2024 at 02:43):

I am trying to move it under settings.processes.test

view this post on Zulip Hao Liu (Jun 24 2024 at 02:46):

(deleted)

view this post on Zulip Hao Liu (Jun 24 2024 at 04:10):

@Srid there doesn't seem to be a way to have a preHook specifically for test process

view this post on Zulip Srid (Jun 24 2024 at 04:35):

Ya, as I said above.

view this post on Zulip Hao Liu (Jun 24 2024 at 04:36):

a feature request to process-compose-flake?


Last updated: Nov 15 2024 at 12:33 UTC