-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix-optimise doesn't run in a container of *any* host #63578
Comments
Isn't the whole idea of containers, that they don't change? Having something change during runtime seems like a terrible idea. If you want to dedup, shouldn't that be done at the time of container creation? |
Wow, that claim surprises me a lot! Maybe the whole point of containers as a devops deployment vehicle is that they don't change, but containers have other uses than that! I would say that their ‘whole idea’ is allowing software to run within a custom Linux environment that is isolated from the host, without the overhead of full machine virtualization. That environment doesn't have to be immutable. I keep a long-running NixOS container on my dev machine, as a platform for running NixOps deployments and developing and testing Nix configurations to be pushed to servers. What would I get out of recreating that container every time I want to update its Nix store? As a container, there's so little overhead to keeping it running and managing itself; I just put my NixOps management timers in the container, enable |
Fair enough - I suggest introducing a |
No, it shouldn't be an option. What matters here is whether the container has its own Nix store. It should be possible to detect this automatically (e.g. by looking at whether Or just add |
Great idea. |
I like the idea of doing both—disabling |
We might be inside a NixOS container on a non-NixOS host, so instead of not running at all inside a container, check if the nix-daemon socket is writable as it will tell us if the store is managed from here or outside. Fixes NixOS#63578
We might be inside a NixOS container on a non-NixOS host, so instead of not running at all inside a container, check if the nix-daemon socket is writable as it will tell us if the store is managed from here or outside. Fixes NixOS#63578
We might be inside a NixOS container on a non-NixOS host, so instead of not running at all inside a container, check if the nix-daemon socket is writable as it will tell us if the store is managed from here or outside. Fixes NixOS#63578 (cherry picked from commit 897834f)
Issue description
Since #48098, the
nix-optimise
service contains aConditionVirtualization
attribute that prevents the service from running inside a containerized installation of NixOS. The rationale for this change, as stated, is thatnix-optimise
should run on a NixOS host and not its containers. However, theConditionVirtualization
restriction is too broad, as it disablesnix-optimize
even when running inside a non-NixOS host. Containerization is, after all, an increasingly popular way of sampling less-mainstream Linux distros from inside a more familiar host, and as such NixOS features shouldn't assume that they're being hosted by NixOS whenever they're running in a container.Is testing the host OS from a module possible? Wrapping the
ConditionVirtualization
in amkIf
that does that would satisfy me (just as one example solution—so would other hypothetical solutions that letnix-optimise
run under non-NixOS hosts).Steps to reproduce
nix.optimise.automatic = true;
inconfiguration.nix
nix-optimise
doesn't run (systemctl status nix-optimise
)Workaround
It's a hack, but:
systemd.services.nix-optimise.unitConfig.ConditionVirtualization = pkgs.lib.mkForce null;
will do the trick. (This does still leave an awkwardConditionVirtualization=
empty entry in the resulting service file, if you bother to check withsystemctl cat nix-optimise
... not that it really matters, as far as I can tell, butmkUnset
from #63553 would be cleaner thanmkForce null
.)Technical details
The text was updated successfully, but these errors were encountered: