If you could provide a snippet to reproduce I could help debug.
This seems to work for me, maybe it will help unblock you:
$ mkdir /tmp/foo;
$ cd /foo;
$ flox init -t project -i;
$ flox init -t package-simple -n foo;
# Manually create an env for this package
$ cat <<'EOF' > ./pkgs/foo/flox.nix
{
environmentVariables.envName = baseNameOf ./.;
shell.hook = ''
echo "Welcome to the '$envName' environment" >&2;
'';
}
EOF
# Re-render the changed environment
$ EDITOR=cat flox edit '.#foo';
$ bash -c ". <( flox activate -e '.#foo'; );" 2>/dev/null;
Welcome to the 'foo' environment
# Add a package
$ flox install -e '.#foo' hello;
Installed 'hello' package(s) into '.#foo' environment.
# Rename the env
$ mv ./pkgs/foo ./pkgs/bar;
$ git add ./pkgs/bar;
# Render the new env
$ EDITOR=cat flox edit '.#bar';
$ bash -c ". <( flox activate -e '.#bar'; );" 2>/dev/null;
Welcome to the 'bar' environment
The critical piece here is the “reload”/“re-render”.
You may also find this direnv
snippet useful, which makes it so you don’t need to manually re-render:
# Reload any changes to `flox.nix' file.
# Capture output and check for errors.
_msg="$( EDITOR=cat flox edit -e '.#default' 2>&1; )";
case "$_msg" in
*ERROR*|*error*)
echo "Failed to update flox environment:" >&2;
echo "$_msg" >&2;
exit 1;
;;
*)
# Activate `flox' env.
. <( flox activate -e '.#default'; );
;;
esac