My Home Manager setup broke, any alternatives?

The other day my Home Manager setup broke and I failed to restore it to working order :disappointed:

I’m using Nix on ArchLinux and I switched to Home Manager from nix-env a few months ago. I’ve only ever used it to manage a few extra tools that I prefer to get from Nix rather than Arch/AUR. (I have a setup for my dot-files that predates my use of Nix and I’m so far very happy with it, even after reading up on Home Manager.)

I have to admit I only spent about 20-30 minutes on getting it working before giving up, removing it all and returning to nix-env. It does pain me a little though as it seems nix <cmd> is the way of the future and I was using some custom tools for work that come in the form of Flakes. (I’m sure I can find some way of cajoling nix-env into dealing with Flakes, but I thought I’d see if there are other options first.

So, is there some other, hopefully less complex, solution for managing my “user-level packages” that I should look at, ideally one that allows me to use Flakes?

nix profile would be the only I know.

1 Like

It’s probably your historical use of nix-env that broke it, frankly, nix-env likes haunting you like that. It’d make sense to share that error too, it’s not unlikely that it will haunt you when switching to flakes/some home-manager alternative instead.

There is the declarative package management section in the nixpkgs manual, but it uses nix-env currently. You can probably do the same with a package in a flake and nix profile, something like:

# flake.nix
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";

  outputs = {nixpkgs, ...}: let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
  in {
    packages.${system}.default = pkgs.buildEnv {
      name = "my-packages";
      paths = with pkgs; [
        # Some packages

And then you install it with nix profile install .#.

1 Like

It might have been my combination of nix-env and Home Manager that did it, but then to get Nix installed at all I end up with at least this

❯ nix-env -q

Not sure how I’d do to get around that…

home-manager can install nix for you once it’s set up, as can nix profile, at which point you can just remove the version installed by nix-env. You would want to add nix to your package list to do that.

I also notice you’re using unstable, which may contribute to, well, instability. If you want a system where wasting 30 minutes fixing things at least happens at predictable intervals, stable is probably more your thing.

Switching between them isn’t really clear though.

Once I’ve added a single package using nix profile install I can no longer use nix-env, so I don’t see how I can remove the “old nix”.

Switching back to nix-env should be doable by rm -rf /nix/var/nix/profiles/per-user/$USER/profile (found here), but that removes all Nix packages from my path, including nix and nix-env, so I’m not sure I’d call that switching at all :grin: