Closed shyim closed 1 year ago
I guess I would add this to devenv up
and call the hostctl remove
when the command gets canceled using a trap
@domenkozar are you okay with the Idea to add pre and post scripts to devenv up
. So we are able to start hostctl and stop it after running the processes. I guess without processes there is not usecase for custom hosts π€
@domenkozar are you okay with the Idea to add pre and post scripts to
devenv up
. So we are able to start hostctl and stop it after running the processes. I guess without processes there is not usecase for custom hosts thinking
It's still better to always set the hosts, as someone might rely on that as part of the scripts, etc.
The problem is when do we remove the hosts. Currently, I am adding a new command. Feels wrong and can be easily forgotten and then the hosts entries says there π .
I would also assume the host entries points to processes running π€
Not sure what you'd like me to cover. Do you have a nix issue for it?
------- Original Message ------- On Monday, December 26th, 2022 at 12:16, Domen KoΕΎar @.***> wrote:
@.***(https://github.com/roberth) could you cover this one for the next Nix team meeting?
β Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Not sure what you'd like me to cover. Do you have a nix issue for it? β¦ ------- Original Message ------- On Monday, December 26th, 2022 at 12:16, Domen KoΕΎar @.> wrote: @.(https://github.com/roberth) could you cover this one for the next Nix team meeting? β Reply to this email directly, [view it on GitHub](#249 (comment)), or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Sorry, I wrote this to the wrong browser tab :)
I'm still unsure how to handle the unloading correctly.
Ideally we'd set a trap
function in bash and expose that via exitShell
for cleanup.
We'd need to fix the whole env loading business, so probably after #191 and #237
Even that would not work. When you have two shells inside it and one leaves the hosts are gone for all π
I still somehow like the Idea to couple it with devenv up
:+1: let's couple it with devenv up
@shyim would be great if you plan to finish :partying_face:
Had no time to look currently in π . maybe weekend
Nice! Looks good π I was wondering whether an attrset has been considered for configuration?
{
hosts = {
"myhost" = "127.0.0.1";
};
}
So that it is easier to override/remove. Or are there features of /etc/hosts that I'm overlooking?
The only problem is that you want to merge all entries by ip to one line as multiple domains with same IP for some reason slow down DNS resolving on Mac
It should still be possible to convert this into the required format with a bit of transformations.
This should be able to convert the structure to a hosts file content.
let
hosts = {
"myhost" = "127.0.0.1";
"otherhost" = "127.0.0.1";
"anotherhost" = "192.168.0.1";
};
entries = lib.mapAttrsToList (hostname: ip: { inherit hostname ip; }) hosts;
entriesByIp = builtins.groupBy ({ ip, ... }: ip) entries;
hostnamesByIp = builtins.mapAttrs (hostname: entries: builtins.map ({ hostname, ...}: hostname) entries) entriesByIp;
lines = lib.mapAttrsToList (ip: hostnames: "${ip} ${lib.concatStringsSep " " hostnames}") hostnamesByIp;
in
lib.concatStringsSep "\n" lines
Sooo I have updated it. First of all @bobvanderlinden thanks <3 it works flawlessly
hosts = {
"foo" = "127.0.0.1";
};
processes.test.exec = "ping foo";
That was my example nix file.
We can use the same base to support mkcert to add like SSL to caddy
Awesome π thanks!
Fixes #227
Config looks like
It will be setup by entering the shell. I did add a proper "caching" so it's calling only hostctl when required because we need to run
sudo
.To deactivate, the user has to run
deactivate-hosts
in the shell and leave the shell. Next opening of the shell readds them