-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
Snap support #30336
Comments
We should be able to get flatpak and snap runtimes packaged and have NixOS modules I think. They don’t require anything. On the packaging side it should be possible but maybe not as straightforward as you think. Nix packages are not easily relocatable- it needs to be installed in /nix/store/... and you can’t just move it to another directory. We’d need either provide our own chroot or see if snap/flatpak can provide one for us so that the paths still work in the package. I wonder if it’s easier to just tell users to install Nix and then install from the binary cache? The user friendliness isn’t quite there though. |
It seems like snap and flatpak are very similar to nix/nixpkgs in their goals? I wonder what is the point of supporting snap and flatpak when you could just package the applications for nix itself? Are these containerization technologies? Because if not, my worry for the long run is eventually having reproducibility issues by letting a 'middle man' build a package, and therefore potentially being a waste of time to support anyway? 😬 |
@vyp A way to answer your concern is: what can you do in the short term, when a very complicated software is available as a flatpak/snap but not in NixOS? (I'm thinking of you steam) Being able to pull a flatpak can help. |
@vyp their goals are quite different. Their goal is to create distribution-agnostic packages, so "package the applications for nix itself" is the opposite of that. Also, unlike nix-packaged apps, snap and flatpak apps are sandboxed (chroot/cgroups/namespaces). As far as I understand snap/flatpak apps are designed to not be used as dependencies for other software - apps are self-contained, standalone and independent. In that regard, reproducibility is not more an issue than with other nix packages that fetch/use proprietary binary blobs. |
@alesguzik That makes sense, thank you. My my first thoughts looking at their websites were that nix can already seem to do what they advertise, so I wasn't seeing much advantages, but I see now that the way nix would handle these, and a lot of the potential problems I was thinking about, could be sort of analogous to nix fetching binary applications (e.g. a lot of the unfree packages in nixpkgs), I think. @jpotier Yes of course if flatpak/snap has a package for something that nix doesn't, it has an immediate advantage. The same could be theoretically true the other way, so the argument just comes down to what is currently available. But my point was less practical and more theoretically, what if these package formats don't work well with nix, and then in the end we would have been better off just packaging it with nix, i.e. long term solutions. Currently nix (and nixpkgs) does have a problem with manpower imo (not to say the current team isn't doing great, they are!), and will probably do so for a while at least, so nonetheless it's still a good point you bring up. 👍 |
@vyp One of the advantages that snap could bring is that for example Solus have done extensive work on making Steam work well on their OS. And now they started building a base-snap of Solus to be able to ship a Steam-snap that depends on the Solus base snap. And then all the work that Solus have done would benefit other distros. For sure it's possible to reproduce all the work, but I guess that that's a lot of work... |
Actually we can run any application which expects FHS-based hierarchy in FHS chrootenvs. Our Steam is implemented in this way and it's fairly straightforward. We also have |
Progress on flatpak is now tracked in #32807. |
Flatpak support was just merged in #33371 |
Has anyone started work on supporting Snap? I've run into a few things that more-or-less require it, like https://anbox.io/ so I'm finding myself interested again. (aside: there is also progress on anbox itself in #42076) |
Snap support is also required to run the Aether client. |
I just packaged Tusk.AppImage, and it was trivial (#66710). It seems like we could implement buildAppImagePackage now? Only need url and sha to fill in the derivation template from pull request that is also used by ~5 other AppImage packages. Seems needless to create a new nix pkg for each. |
Anyone working on implementing |
Any progress on snap? It becomes more and more important since there are packages only available in snap and they are pretty much important: microk8s to start with... |
IMO: I think the end goal shouldn't be to be able to re-package software from snap to nix (because we'd be better off just using the standard nix building procedure, so pulling from a snap would be no more different than extracting files from a .deb and replicating the build process because everything would need a rebuild anways to account for the /nix/store prefix), but instead the goal should be to provide a snapd/flaptpak daemon that the user can use to pull apps from the stores. If it becomes an issue that snapd/flatpak is too deterministic for the user, then re-packaging properly for nix is the only good option, everything else just would be a hack. |
From when I last checked one big issue with snap is that it assumes to have a total control over the system it's running on including but probably not limited to ability to manage systemd services, dbus services, global configuration files under /etc which would make it very difficult to integrate with NixOS using the stock snapd daemon. |
From user point of view it is irrelevant if it is hack or not, it should just work and that's it. |
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
Still important to me |
Isn't flatpak supported? So this should be retitled to only be about snap. |
@ptman yes you are right |
I marked this as stale due to inactivity. → More info |
@io12 |
Thanks @iavael. Also, apparently Nix doesn't let build outputs hard link to dependencies (NixOS/nix#1272), so deduplication might be hard. It might be better to just rely on Also, I made a repo at https://github.com/io12/nix-flatpak. I think it mostly works, but it's really slow. It takes ~5 hours for me to install a Flatpak vs a few minutes without Nix. I'm not really sure why, maybe something about how |
I took a bit of a different approach from @io12 (although big inspiration, thanks!!) https://github.com/yawnt/declarative-nix-flatpak seems to work and is quite fast. doesn't really much deal with dedup because if you update a runtime, all apps under that runtime are supposed to be compatible so you only ever need one copy of each "branch" (i think). it's kinda a rough PoC but if there's some interest i'm happy to maybe clean it up? |
Thanks @yawnt. I have interest. What would help me the most is a README detailing how to get this integrated with an existing NixOS configuration and then install some example flatpak using it. |
I've added a readme with a flake example, I don't want to hijack the discussion so if you have any other questions, please kindly open an issue :) |
I couldn't get the majority of my Steam games to work in the "native" Steam install, but they all work fine via the flatpak (or at least, the same ones that are known to work fine on the Steam Deck or via Proton, now work fine on my NixOS install). That's how I found this thread. I'm still holding out hope, though, and to that end I bind-mounted the expected flatpak location to the original "native" steam root 😊 (this also prevented me from having to re-download everything, although I could have just copied/moved...):
|
Hey everyone, fellow n00b here. I am looking to consider using either NixOS or Talos in order to reprovision and redeploy my microk8s home lab cluster. I would like to contribute to building and testing microk8s snap support where possible as I am on the line between choosing to commit to NixOS or Talos as my base OS. It seems Nix can easily do what Talos does plus more. Thoughts? |
@RyzeNGrind What do you need to/intend to install via snap/flatpak/appimage? Note that all those solutions I just mentioned are comparatively weak attempts to solve the problem that Nix/NixOS solves definitively. So there is, fundamentally, a philosophical hurdle to surmount, as any Nix[OS] developer/believer will tell you that any energy spent on bringing better snap/flatpak/appimage compatibility is literally better spent figuring out how to get the relevant apps up natively on It would be like going to the Cadbury chocolate factory and asking when they will have better carob chip support. 😆 "Hey Elon, when will you come out with a car that has a gas generator? We still have a few use cases where gas is more plentiful than high voltage." That all said, like I said recently, I'm currently using Steam via Flatpak. This is absolutely a less than ideal situation, but I was struggling with some games, and I unfortunately don't have the time to help track down the missing configurations that would make those work (context: I have a 17 month old kid. Kiss your freetime goodbye, in case you aren't a parent yet! I hear it gets easier "in a few years"... sigh) Since I now love NixOS AND games, I would absolutely be willing to help the devs responsible for the Steam derivation figure out any remaining hurdles as soon as I have the time (hmmm, is it possible to lend games to steam friends? I have... A LOT of games)... but I don't. Note that the other advantage of figuring out how to get a given app up on Nix[OS] is that once it's up, it's quite possible that it will be up for good, since updates breaking unrelated things ::cough:: glibc, ssl ::cough:: is virtually non-existent (notable exceptions include: things like graphics drivers, which everything in the GUI has to share, or window managers, of which you can only run 1 at a time). Maybe that's why |
This comment was marked as outdated.
This comment was marked as outdated.
@pmarreck thanks for the detailed Q/A Peter. I guess I should have lead with the motivations when asking my initial question so my bad for that, lol. I'm currently running an arm64/amd64 hybrid kubernetes cluster in my homelab thanks to Ubuntu and Canonical's snapcraft microk8s snap. Since it minimizes a lot of overhead to run production ready k8s with minimal to zero ops I was planning to try running a similar micro kubernetes cluster but on NixOS instead. I was able to use microk8s and Ubuntu to date to learn everything I needed to secure my career path into DevOps while attempting to solidify my skillset and play around developing personal projects. I guess based on my current limited understanding of Nix, i can see how valuable a tool it will become as part of the dev toolchain and wanted to see how i could migrate my existing cluster or create a new baremetal m-k8s cluster based on Nix. Hope my comment provided the insight or clarity needed. I guess my end goal is to have a zero-minimal ops k8s cluster out of my homelab for running my self hosted services and maybe exposing a few endpoints or services to the web for friends, family, school stuff, projects, etc. |
@RyzeNGrind Well I can tell you a few things as a guy who's been messing with Nix[OS] for a few months now, to illustrate my perspective. I think your intuition about Nix is largely correct; that's why a lot of us came here, and additionally I think it's cool that you were drawn here as a devops person, because mastering Nix[OS] (or Guix, just to be fair) would be a powerful tool in your toolbox. One possible place to start seeing how K8s might fit into the Nix[OS] picture might be https://nixos.wiki/wiki/Kubernetes (note: I haven't personally messed with k8s on nix, just steering you there!). A few things to keep your expectations realistic:
On the "everything I own needs to run NixOS" front, here's a guy who built his own home router using nixos and loves it: https://skogsbrus.xyz/blog/2022/06/12/router/ Here's someone who came up with a MicroVM scheme that seems to work great: https://github.com/astro/microvm.nix Anyway, I think you'll like it and can make it work for you, just expect to wade into the deep end for a while. Back to regarding snaps specifically, this discussion mentions how Spotify is only reliably distributed as a snap currently, and provides a link to a recipe for it which might be helpful: https://discourse.nixos.org/t/installing-a-snap-package/11468/2 (I have Spotify installed and can attest to the fact that it runs well!) |
The reason we need snapcraft (and flatpak) support is because there are more and more snap packages being added by developers every day. Nix does not have the human power to repackage and stay up to date with all the programs that developers are releasing as prepackaged |
At the very least, I think a simple option of I don't think it should be that hard either -- for flatpak, you can do Snaps are probably more challenging, because of the specific orders they may ask for install / uninstall. A user may install firefox through snap (maybe for testing) and then remove it -- the unusued snap dependencies that came with firefox would need to be uninstalled but it has to be done in order, which is a bit more complex. I'm mostly a home-manager user, but an option to declaratively install flatpak, snap, and maybe even AppImages would be very convenient and useful. |
@bayazidbh that approach implies that nix would manage flatpak/snap storage. But nix manages only it's own /nix/store. And anyway making nix change installed flatpak apps doesn't look very robust. |
Well, my main desire is for a simple way to manage flatpak declaratively, having everything be done declaratively makes it very convenient for me. But other than that, I was thinking of it more as a tentative support. I'd love to have Nix be able to use flatpak-build and have a way to automatically build flatpak apps instead of just installing them from flathub or other repo. But for some apps, I'd probably not care and just want it to pull a binary from a repo -- just that the install process be declarative so I can put them inside my home-manager config. Edit: Found someone who've made a module for declarative-flatpak, though not soon enough that I didn't spend a day trying to work out my own way of doing it (oh, well, I learned a lot at least). |
We already got flatpaks but now we need a way to install snaps. |
Flatpaks are working.. how about snaps? |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/enable-snap-and-install-snap-applications/32834/2 |
I have an initial attempt at https://github.com/io12/nix-snapd. So far it works with most of the snaps I've been using for testing. |
I think it's now in a state where it works really well. Lots of people in this thread mentioned wanting snap support because microk8s requires it, but microk8s seems like a very complicated snap that deploys multiple systemd services, expects FHS, but also expects the FHS to contain more entries in /etc than buildFHSEnvChroot creates, and also apparently expects /usr to be writable. It might be possible to improve buildFHSEnvChroot or create an ad-hoc version just for snap, and mount an overlayfs over /usr so that it's writable, but even after this there might be other compatibility issues. I think that if people need microk8s it should probably be packaged directly for NixOS so that it can have source patches to fix compatibility issues. Most other snaps work fine, though. |
A message from Nextcloud developers stating that they only support snaps in Ubuntu, and that using snaps in other distros has greater security vulnerabilities. This may be considered a warning. |
@Sepero thanks for mentioning that. I didn't know that snap is such a Ubuntu focused thing. To be honest I don't really get the whole point of snaps if they are supposed to be just property executed on Ubuntu. |
@Sepero snapd on Ubuntu uses ubuntu-specific features of apparmor, that most other distros usually don't. And it overall tied to apparmor, that most distros don't have. If you use nixos, I think you are shouldn't be bothered about running snaps without apparmor, because you don't use it to run any software on your computer anyway. |
I have a draft PR to add AppArmor support but I haven't gotten it fully working yet. nix-community/nix-snapd#2 |
@io12 Thank you! It is very important, as it complements GUI-oriented flatpaks nicely. |
My usecase for snaps is when migrating from other distributions, there can be no other way to rescue data from an old system (e.g. Signal app on Ubuntu is a snap) |
Skype is another example of being currently available (updated) only as a SNAP package. References: |
From the link above:
|
Yes, that's why I mentioned it is "currently available (updated) only as a SNAP package". The previous DEB and RPM packages on which the NixOS skypeforlinux package is built are no longer maintained/updated. I tried it and it works with @io12's nix-snap. Thank you for that! But not that good unfortunately, menus/options get stuck and lag greatly. Not sure if it is due to nix-snap implementation or the skype snap package itself. The web version of Skype works much better by the way. |
Currently, there's no way to either repackage or directly install software packaged in a snap and flatpak formats. Because apps packaged in this formats can run unmodified on all major Linux distributions, their popularity grows, and we seem to be missing out.
Flatpak apps can be installed on Alpine, Arch, Debian, Endless OS, Fedora, Gentoo, Mageia, openSUSE, Solus, and Ubuntu.
Snap apps can be installed on Arch, Debian, Fedora, Gentoo, Mint, Manjaro, OpenEmbedded/Yocto, openSUSE, OpenWrt, Solus, and Ubuntu.
Ideally, I'd wish we can do something like this
The text was updated successfully, but these errors were encountered: