home-manager does not really work for most multi-user systems for non-technical reasons. E.g., we have Nix on some of our compute machines because I use it and colleagues find it practical that I can share software with them by sending them the right nix-env invocation. Some of them may do an occasional nix run to use something that is not available on Ubuntu or will not be installed system-wide. But for most colleagues it’s very unlikely that they will want to learn Nix, let alone home-manager. So, you end up with a lot of old stuff in the Nix store, because things get installed once and are never updated.
I think this is a missed opportunity, they may not (want to) be Nix users now, but could be in the future because what they have seen. It would be nice to have the tooling to do system-wide updates of user profiles (whatever they have installed with nix-env).
To be honest, I consider it a big plus of nix, to not force everyone to be on the same version.
But if OP really wants to, I’m pretty sure it will just work when they provide a systemd timer + service, that does run the exact two commands from the OP.
I’d still never suggest to do unsupervised updates. If stuff breaks, its hard to find out why and when that happened.
Besides of that, nix-env -i doesn’t really work for a lot of things, as further tweaking of configuration is required through nix, or by hand, where other package managers might do more “magic” behind the curtains when installing stuff.
nix-env -i won’t setup systemd units, it won’t add users necessary to run services, it won’t configure anything. To achive those installations properly one needs to describe them declaratively in a nix file at a central place or per project in a shell.nix and this still doesn’t work for all programs (postgres database in a shell.nix? Not sure how that should work…)
apt, snap, or even brew might be in an advantage here, as they take care for such stuff in their imperative forms.
snap even does automatic updates, no need to ask for it… It will break totally on its own… Without user interaction, isn’t that progress?
Agreed. Probably a system-wide unit to run nix-channel --update and a user unit to run nix-env -u. With a user unit, users could even decide themselves whether they want to run automatic updates and how often.
I think this argumentation is centered around specific use cases. There is a very large number of packages in nixpkgs that do not require that kind of setup. To take an example from our field, say that someone needs fastText. There is no package in Ubuntu for fastText. They could hand compile it, or they could just do nix-env -i fastText and be done with it, the same is true for probably 90% of the software in nixpkgs.
I don’t see the need to be cynical about this. Apparently, (sometimes containerized) user installs is something that people need and want. Despite their faults, snap and flatpak have been trying to address this use case. Coming back to nixpkgs I don’t see why one should expect updates on a stable branch to break.
(Note: personally I don’t even use nix-env, but I think that it’s a ‘gateway drug’ for new people to Nix.)