Alternative to .config/nixpkgs/config.nix:packageOverrides

Not sure it’s meant to be used with flox, but since now I have installed flox, nix-env no longer works. That’s fine. But I would need to migrate from these settings somehow:

$ cat .config/nixpkgs/config.nix
{
  packageOverrides = pkgs: with pkgs; {
    myPackages = pkgs.buildEnv {
      name = "my-packages";
      paths = [
# utilities
        nixfmt
        nix-direnv
        jq
        tig
...

Either I finally setup nix home manager, or what would be the flox way of doing it?

(So many ways of doing things in nix, as a beginner, I’m at lost)

I was probably speaking nonsense…

My ignorance blocks me at that my home nix-profile can not work with neither nix-env and nix profile, no idea what should I do (in this particular case, I am using nix on wsl):

$ cat $(readlink -f ~/.nix-profile)/manifest.json | jq
{
  "elements": [
    {
      "active": true,
      "priority": 5,
      "storePaths": [
        "/nix/store/g2n1lgslmfji6kz0h18387vm77nxb4lm-my-packages"
      ]
    },
    {
      "active": true,
      "priority": 5,
      "storePaths": [
        "/nix/store/nmq5zcd93qb1yskx42rs910ff0247nn2-nix-2.11.0"
      ]
    },
    {
      "active": true,
      "attrPath": "evalCatalog.x86_64-linux.stable.flox",
      "originalUrl": "github:flox/floxpkgs",
      "outputs": null,
      "priority": 5,
      "storePaths": [
        "/nix/store/cxfnamy93n94kbs7nm7w72pa6yglgjlg-flox-0.0.6-r43"
      ],
      "url": "github:flox/floxpkgs/656bffc634c6445cb8ed53e68b3987145a8cf635"
    }
  ],
  "version": 2
}
$ nix-env -q
warning: unknown setting 'nix.settings.trusted-public-keys'
warning: unknown setting 'nix.settings.trusted-substituters'
error: profile '/nix/var/nix/profiles/per-user/hellwolf/profile' is incompatible with 'nix-env'; please use 'nix profile' instead
$ nix profile install what
warning: unknown setting 'nix.settings.trusted-public-keys'
warning: unknown setting 'nix.settings.trusted-substituters'
error: cannot find flake 'flake:what' in the flake registries

This sort of problem is a big part of why we created flox in the first place. There exist many ways to use Nix, and the fast pace of change in the Nix world means that conventions change quickly and things can stop working, particularly if you inadvertently revert to a previous Nix version.

That said, there are three things I’ll note from what you’ve said above:

  1. nix-env is deprecated. It didn’t record the original attrPath used to install a package so it was fundamentally broken from the start, and has been replaced by the nix profile command(s).
  2. nix profile is experimental and unstable. You may be running into problems between the use of different versions of Nix which employ different manifest “version” numbers, and once a profile has been accessed (even once) by a newer version of Nix it can no longer be read/used by an older version.
  3. flox environments fully replace Nix profiles, supporting full change management and sharing features not possible with Nix profiles. These are discussed in detail in the flox tutorials, so if you haven’t already I’d suggest reading through the Using Package tutorial and don’t stop until you’ve finished the “Sharing Environments” section.

In summary, I believe you should find that flox install nixfmt nix-direnv jq tig followed by flox activate should get you the environment you’re looking for, after which you can flox push and flox pull it to other machines, and/or share with a team by inviting them to flox pull -e hellwolf/default.

One final note: we’re working on a flox installer for WSL which should help avoid such Nix version mismatches in future, but in the meantime you may find that running alias nix="flox nix" may provide some relief in the meantime.

Hope this helps!