Can I stop NixOS from doublicating Apps after an Update?

Hello everyone

I am really interested in NixOS but probably for the “wrong” reasons :sweat_smile: And one thing actually bothers me:
The new Versions of a Program it creates after updates while keeping the old (I know this is one of the great features for Nix).

So my question is if it is possible to get updates like on most other common Distros.
Example: If Inkscape gets an Update it won’t download and install the whole program again but just the parts for the new version that are new(I don’t know what this update technique is called - Flatpak does it like that)
I only have one (good) laptop with one ssd. And I don’t really need that Rollback feature and want to save that space and the writes to my ssd.

I am not an absolute beginner and can handle most things if I run into something on Linux but I don’t understand dev-terms or programming or how everything works under the hood.

Why do I want NixOS?

  • Pure Gnome
  • Up to Date
  • Low on Ram usage
  • Lots of packages
  • Independent

So is it possible to make NixOS update only the bits of an app that are needed and not re-download all the dependecies and the whole app.

Bonus question: How does NixOS handle updates from other package managers like Flatpak, Snaps? And are Apps from these sources automatically integrated in the App launcher/Menu?

I hope my question is understandable and thanks for the answers in advance.

Flatpak doesn’t really do that. What flatpak does is it bundles an application with all of its dependencies, and it separately bundles a “runtime” which contain some generic dependencies.

The “runtime” doesn’t change often, so there’s a lot of files that don’t have to be updated a lot. The application changes often, so its files need updating a lot.

Both are turned into ostree repositories, which is a clever tool that allows sending around only exactly those files that have actually changed.

It still needs to send around files that have changed in any way, though. And that’s the majority - the actual binary you’re using will be downloaded every time there’s an update, even with flatpak.

Nix is very different. It’s an actual package manager, while flatpak is more of a… bundle mamager? Exe manager?

Rather than bundling a package with its dependencies, and a separate runtime, nix just installs the packages directly to your system.

This has the advantage that it’s easier to make sure everything is using the same version (and gets prompt security updates). Unlike flatpak, the same binary isn’t copied out multiple times either. It also has some minor advantages regarding memory usage and execution speed, because cached copies of the library on disk can be reused.

The downside is that nix packages don’t come with flatpak’s host isolation, which is a neat security help if you’re diligent, and the packages are harder to make work for NixOS, especially GUI applications, but you as a user shouldn’t see that much.

The difference in terms of amount of stuff to download is not that significant, though. Nix does download a bit more on average, I think, but that’s to enable the guarantees you want.

Rather than worrying about the amount downloaded, why not just use (sudo) nix-collect-garbage -d regularly? It will delete any files no longer needed for your system. Flatpak has a similar command you will need to run from time to time.

On a side note, it is actually possible to achieve what you thought flatpak does. It’d be done via a content-addressable store, CAS for short. There is no real CAS in nix yet, but there’s one in the works.

2 Likes

You can achieve a similar result by Garbage Collecting. Either do it manually with nix-collect-garbage (plus the -d flag to delete old generations), or through a service that runs periodically.

Example: If Inkscape gets an Update it won’t download and install the whole program again but just the parts for the new version that are new(I don’t know what this update technique is called - Flatpak does it like that)

Deltas? No, Nix does not use them.

Bonus question: How does NixOS handle updates from other package managers like Flatpak, Snaps?

Nix does not interfere. They will be managed by Flatpak/Snap respectively.

And are Apps from these sources automatically integrated in the App launcher/Menu?

Yes, they will be added.

3 Likes

While this doesn’t really answer your question, you want want to read this thread to learn about NixOS packages distributions process and leads to make it more efficient How to make Nixpkgs more eco-friendly / use less resources

2 Likes

Wow, I am a little bit overwhelmed not just because I don’t understand every bit of your answer (I get the overall message though) but because every answer is so nice :blush: although this was probably a beginner question.

I compared it to Flatpak cause I was watching DorianDotDash and youtube explaining Flatpak.

Additionally I was watching what I could find about NixOS on Youtube but most of the things are to deep for me (I wish I had this talent and knowledge).
I hope tutorials get a little more beginner friendly as it now has a graphical installer.

@fufexan
I was also reading into the Nix manual and read about “garbage collect”. But it seems like a waste of unnecessary writes to and ssd if not needed. It seems like wasted “work” for the PC.
So compared to an Ubuntu based Distro or Fedora: Do you also get that much Garbage on these systems just not as in Focus as on Nix.
Cause your side note is to much for me but if this is in the works and will be shipped with the NixOS iso at one point that would be nice.
Thanks for the answer of my bonus question. That even I understood :grinning_face_with_smiling_eyes:

@Solene Thanks for the Link

I am still not 100% sure if I could manage the Nix package manager and how to update/upgrade and install (many show installs in the config file) but apt update/upgrade and install seems much easier. At least until I understand it.

Definitely not as much, but they also don’t guarantee that a sudden poweroff during an update won’t break your system.

But it seems like a waste of unnecessary writes to and ssd if not needed. It seems like wasted “work” for the PC.

Yeah, it can come off as unnecessary, but the previous point I made proves that it’s not unnecessary.
Deltas would be a very complex thing to implement in the current model, for (probably) minimal gains.

2 Likes

CAS will not solve any of this issues!

It can only solve redownloads that would otherwise happen if pure buildtime dependencies have changed, and only if a bit by bit identical outcome was created.

Changes in runtime dependencies will always be reflected in changed of the outcome, be it IAS or CAS.

Hmm, is the CAS not chunking the contents? I should look at it in detail at some point, I’d been assuming it works like casync.

It doesn’t chunk, it still addresses a full path.

I don’t think we will ever be able to “chunk” a single huge path into “subpathes” without also rewriting a lot of nixpkgs, to actually produce the chunks rather and combine them in a Linkfarm.

1 Like

There is already some research into increasing substitution granularity: Nix Substitution: the Way Forward

1 Like

Okay, thanks for that. Like I said in my initial comment I probably like NixOS for the “wrong” reasons. For the moment at least.

So the only solution at the moment would be to install additional programs from other sources (Flatpaks, Debs, Snaps etc)?

As NobbZ says, that is not the case. But there is nix-casync:

1 Like

I think GitHub - input-output-hk/spongix: Proxy for Nix Caching is better than nix-casynx in the current state.

1 Like

want to save that space

If you’re tracking unstable, you will end up with quite a fair amount of space used. That can be mitigated by running frequent GC as also mentioned by a few others in here.

and the writes to my ssd.

This isn’t something you should be concerned about or a case that you should be optimizing for (assuming “regular” desktop usage).

Why do I want NixOS?

  • Pure Gnome

What exactly do you mean by “Pure Gnome”? As in vanilla GNOME without any distribution changes? If so, what kind of changes? Because we do patch things a fair bit. Now it might be in ways that do not matter to you, but in order to say anything that addresses this, we need to know what your concern is.

  • Up to Date
  • Low on Ram usage
  • Lots of packages
  • Independent

As an example, you can get all of these with Arch Linux too (I have no idea how many changes/if at all they do to GNOME).

The point I’m trying to get to is this - NixOS does a few things rather differently in order to achieve different goals. If those goals are not important to you (reproducibility, declarative machine configs, roll-backs, very neat dev environments), the trade-offs you would have to make are probably not worth it at this point, but only you can weigh out the pros and cons.

1 Like

Yeah, I meant Vanilla Gnome. How it works and looks. And I thought that you do things under the hood as it uses very little Ram on a fresh boot (not sure about the average load yet).
My only concern was the bandwidth, storage and (in my case unnecessary) writes to the ssd.
But as you said I should not be concerned about the last point.

I would use the Stable. On unstable in Gnome Boxes I was not able to use my keyboard.

I’d prefer not to use Arch mainly cause of the rolling release. I checked Manjaro and Crystal Linux witch both would be pretty good for me if not based on Arch.

I’m complicated. Fedora seems to have many things I am looking for. Downsides are little heavy on the Ram (more than double of NixOS) and origin usa (I’d prefer Europe).

NixOS just seems to be a really good operating system in general and I thought if there is a possibility to turn off or limit these processes that would be nice.

And I thought that you do things under the hood as it uses very little Ram on a fresh boot

We don’t do anything special that would mean significantly lower memory usage, so I wouldn’t use that as a benchmark for this.

If you are running one of the full-fledged DEs (I happen to be using KDE), there really shouldn’t be any significant difference between distributions.

I would use the Stable. On unstable in Gnome Boxes I was not able to use my keyboard.

Then it looks like you’re going to get an unpleasant surprise when the next stable comes around. If you’re able to provide details of what is not working, that would be very helpful (please open an issue).

I’d prefer not to use Arch mainly cause of the rolling release.

Fair enough.

Fedora seems to have many things I am looking for. Downsides are little heavy on the Ram (more than double of NixOS)

Again, assuming you have enabled a similar set of software, the memory use should be similar. Sure, there might be switches that fedora enables that we don’t, but double sounds highly unusual.

and origin usa> (I’d prefer Europe).

I get what you’re trying to say, but what exactly is the concern here? Sure, fedora is run by Red Hat which is a US company, but a big part of the contributors are from !USA. Besides, the software is the same. GNOME is GNOME and GNU coreutils is GNU coreutils regardless of which distribution you are getting it from. >

NixOS just seems to be a really good operating system in general and I thought if there is a possibility to turn off or limit these processes that would be nice.

It is indeed a very good OS and I wouldn’t want to downgrade to a more traditional distribution but that’s for the reasons I outlined in my earlier message.

I’m not in any way trying to talk you out of NixOS. It’s just that if the key USP/UVPs mean nothing to you, it’s probably not worth it. I will recommend focusing on the selection criteria that truly matter to you.

1 Like

In short, the “duplication” is part of a core foundational choice in the architecture of NixOS. If we changed that, it wouldn’t be NixOS anymore, so no, we’re not changing it, and you can’t get around it and still really be running NixOS.

That core choice was made in order to make certain features possible, and those of us attracted to NixOS generally think the tradeoff is well worth it, but if you’re not interested in those features, then, almost by definition, you’re not interested in NixOS, either.

I used both in Gnome Boxes and NixOS was around 590mb while Fedora started at 1GB going to 1.3GB after 2 Minutes (while doing nothing apart from Terminal with TOP open). Both the official (recommended) iso. Same on Ubuntu based Distros all above 1GB while Arch based are a below and OpenSUSE Tumbelweed as well but all of them not as significant as NixOS.
I am not e Dev. I don’t understand why as most of them (with vanilla Gnome) look and feel exactly the same (with some differences in shipped Apps). That can’t be just cause of 3 or 4 different pre installed programs. I don’t get my head around this and I would not know what to do to lower ram usage that much.
And I need my Ram for Design and Photography related things.

Could you give me the Link. I am not sure where exactly to open that issue on Github.
The funny thing is. Somehow Gnome Boxes now automatically chooses “unstable” although I am running Stable 22.05 and my Keyboard does NOT work.
Only thing I do is running the ISO in Gnome Boxes and opening a Terminal after boot. Trying to write gives no respond (none of the keys). I tried other Apps like the Browser and still nothing.
Not sure how I could provide more info as I am not able to do anything in the Terminal.

No real concern. But I am from the Center of Europe and would prefer to support something from Europe. The Two big Operating System Players come from America plus half of the Internet Services most of us use. I am just not a fan of that much Power coming from there and at least Linus Torvalds was born in Finnland.

I make my mind about things I use - sometimes probably too much…

I agree with you that NixOS uses much less resources, compared to something like Ubuntu.
I didn’t specifically check the RAM usage because I have plenty of that but the lesser CPU usage is something that I noticed quite heavily on my VMs.

1 Like

I would like to know why that is. I mean Ram is not very power hungry or activating the fans but CPU is.
10 to 20% of difference would be negligible but 80 to 100% blows my mind.