-
Notifications
You must be signed in to change notification settings - Fork 362
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
hostctl: init module #249
hostctl: init module #249
Conversation
I guess I would add this to |
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'm thinking that hostctl is the implementation detail and the interface should be more like:
hosts = [ "127.0.0.1 foobar" ];
This aligns with how processes work, I don't see any specific reason to have explicit enable
. What do you think?
src/modules/integrations/hostctl.nix
Outdated
|
||
profile = lib.mkOption { | ||
type = lib.types.str; | ||
default = "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.
What happens if you have two devenvs setting different hosts?
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 last one wins. That's why I added the profileName option 😅
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.
What if we use "devenv-${hostHash"
for the profile name?
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.
It needs to be something unique to this devenv to update also the area in the hosts
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.
"devenv-${builtins.hashString "sha256" env.DEVENV_ROOT}"
@domenkozar are you okay with the Idea to add pre and post scripts to |
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](#249 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AADZGP6JC75COHLCPH7DTD3WPF5B5ANCNFSM6AAAAAATIUECDA).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Sorry, I wrote this to the wrong browser tab :) |
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 |
👍 let's couple it with |
@shyim would be great if you plan to finish 🥳 |
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
That was my example nix file. |
We can use the same base to support mkcert to add like SSL to caddy |
Co-authored-by: Domen Kožar <[email protected]>
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