-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compare to similar tools #135
Conversation
cc @roberth for ideas, especially in regards to the aspects. Currently, we have 'pure flakes', 'multiple services', 'sharing' and 'flake apps' (devenv doesn't produce runnable packages, as far as I can tell), etc. |
@shivaraj-bh To substantiate our "share services across flakes", we probably need to document it first. |
README.md
Outdated
| --- | --- | --- | | ||
| macOS support | ✔️ | ✔️ | | ||
| Pure Flakes | ✔️ | ❌[^1] | | ||
| Share services across flakes | ✔️[^2] | ❌ | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This maybe inaccurate.
cf. https://devenv.sh/guides/using-with-flake-parts/#import-a-devenv-module
But I haven't used devenv enough to say if its module system works without any idiosyncratic shortcomings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on what I see, if you are able to import
a module, you should be able to share services even using devenv
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it allows sharing modules between flakes like above, you can’t really share it within the flake to an extent we do in Nammayatri, to provide nix run #load-test-dev
, which adds a bunch of processes of its own after sharing the entire backend configuration of nammayatri that is started via nix run .#run-mobility-stack-dev
.
In short, devenv
allows you to create and merge processes declaratively but all these processes belong to the same group, you can’t define two sets of different groups with a few/all distinct processes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The screenshots you posted above show modular import of devenv config, not devenv services. ie., we can't do the following, right?
devenv.shells.default = {
services = {
imports = [ ./mymod.nix ];
myservice.enable = true;
};
};
Which explains why you can't compose and share services per se, and must create modules for whole devenv config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't do the following, right?
Yes, hope I haven’t missed something. Let me give it one more shot to be certain, don’t want to make false claims because of missing some details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't gotten any clear and unambiguous response from the devenv community, so let's just merge this. If they correct us by providing an example, we can change the README obviously.
README.md
Outdated
| macOS support | ✔️ | ✔️ | | ||
| Pure Flakes | ✔️ | ❌[^1] | | ||
| Share services across flakes | ✔️[^2] | ❌ | | ||
| Services as flake apps | ✔️ | ❌[^3] | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://devenv.sh/guides/using-with-flake-parts/
If you're familiar with the Nix language and ecosystem, devenv can be used without the devenv CLI by integrating into Nix Flakes using flake-parts.
But the page doesn't explain how exactly one starts devenv services without using its CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the flake I created here, I explored the flake in nix repl, and these are the packages it exports:
nix-repl> packages.x86_64-linux.
packages.x86_64-linux.container-processes packages.x86_64-linux.default
packages.x86_64-linux.container-shell packages.x86_64-linux.devenv-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I can’t seem to be able to nix run
it:
❯ nix run .#devenv-up --impure
warning: Git tree '/home/shivaraj/oss/devenc' is dirty
trace: warning: getExe: Package "cowsay-3.7.0" does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, use getExe' to specify the name to the program, such as lib.getExe' foo "bar".
error: unable to execute '/nix/store/67lf41ig3sf8z4i6lnigfn4c0icyb830-devenv-up/bin/devenv-up': Not a directory
Probably it doesn’t have a bin output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine: ❯ nix build .#devenv-up —impure
And produces a result whose contents are:
❯ cat /nix/store/67lf41ig3sf8z4i6lnigfn4c0icyb830-devenv-up
#!/nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26/bin/bash
/nix/store/lb2b16q8kc3xynj27d25sahhq95ph43h-process-compose-0.88.0/bin/process-compose --config /nix/store/vhxxz7j5bjlyi0ggfx4dlcf9an61p09q-process-compose.yaml \
--port ${PC_HTTP_PORT:-9999} \
--tui=${PC_TUI_ENABLED:-1} \
up "$@" &
if [[ ! -d "$DEVENV_STATE" ]]; then
mkdir -p "$DEVENV_STATE"
fi
stop_up() {
echo "Stopping processes..."
kill -TERM $(cat "$DEVENV_STATE/devenv.pid")
rm "$DEVENV_STATE/devenv.pid"
wait
echo "Processes stopped."
}
trap stop_up SIGINT SIGTERM
echo $! > "$DEVENV_STATE/devenv.pid"
wait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But when I try to run it, postgres
service never starts, it just times out and fails with:
❯ ./result
mkdir: cannot create directory ‘’: No such file or directory
./result: line 25: /devenv.pid: Permission denied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the same configuration works (including postgres
starting successfully) when I do nix develop —impure
and then devenv up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I run ./result
after removing process.implementation = “process-compose”
, it uses honcho by default , which seems to work fine.
I was able to execute queries using psql
:
shivaraj=# create table id(id int);
CREATE TABLE
shivaraj=# \dt
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | id | table | shivaraj
(1 row)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But when I try to run it,
postgres
service never starts, it just times out and fails with:❯ ./result mkdir: cannot create directory ‘’: No such file or directory ./result: line 25: /devenv.pid: Permission denied
This is because of not exporting DEVENV_STATE
, because I am no longer in devShell, I will have to do it manually:
DEVENV_STATE=$(pwd) ./result
But even after that I couldn’t get it running using the process-compose
implementation without being in the devShell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In conclusion, we can confidently say that devenv doesn't support running services (nevermind individual process groups) as a flake app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it, yes
IMO adding an example each for “Share services” and “Reusable services” would be useful. |
Right, you had mentioned this earlier: #135 (comment) That’s something I can work on adding. |
Here’s an example: #137 Once we confirm on the example, I will also flesh out the a doc for this. |
Merging. Let's make follow-up edits in separate PRs. |
Rendered
This table is just a start, and not complete.