Skip to content

Commit

Permalink
hostctl: set a unique profile name
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Dec 26, 2022
1 parent 7ad6e33 commit a949949
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/modules/integrations/hostctl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ let
in
{
options = {
hostsProfile = lib.mkOption {
hostsProfileName = lib.mkOption {
type = lib.types.str;
default = "devenv";
default = "devenv-${builtins.hashString "sha256" config.env.DEVENV_ROOT}";
description = "Profile name to use.";
};

Expand All @@ -27,14 +27,14 @@ in
packages = [
(pkgs.writeShellScriptBin "deactivate-hosts" ''
rm -f "$DEVENV_STATE/hostctl"
exec sudo ${pkgs.hostctl}/bin/hostctl remove ${config.hostsProfile}
exec sudo ${pkgs.hostctl}/bin/hostctl remove ${config.hostsProfileName}
''
)
];

enterShell = ''
if [[ ! -f "$DEVENV_STATE/hostctl" || "$(cat "$DEVENV_STATE/hostctl")" != "${hostHash}" ]]; then
sudo ${pkgs.hostctl}/bin/hostctl replace ${config.hostsProfile} --from ${file}
sudo ${pkgs.hostctl}/bin/hostctl replace ${config.hostsProfileName} --from ${file}
echo "Hosts file updated. Run 'deactivate-hosts' to revert changes."
mkdir -p "$DEVENV_STATE"
echo "${hostHash}" > "$DEVENV_STATE/hostctl"
Expand Down

0 comments on commit a949949

Please sign in to comment.