NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.3k stars 13.54k forks source link

Snap support #30336

Open alesya-h opened 6 years ago

alesya-h commented 6 years ago

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

buildFlatpakPackage {
  src = fetchUrl {
    url = "https://git.gnome.org/browse/gnome-apps-nightly/plain/gnome-builder.flatpakref?h=stable
    sha="..."
  }
}
io12 commented 9 months ago

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.

Sepero commented 9 months ago

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. https://github.com/nextcloud-snap/nextcloud-snap/wiki/Why-Ubuntu-is-the-only-supported-distro

tuxflo commented 9 months ago

@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. Still sad that some applications are only shipped as snap (I'm looking at you, microk8s).

iavael commented 9 months ago

@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.

io12 commented 9 months ago

I have a draft PR to add AppArmor support but I haven't gotten it fully working yet. https://github.com/io12/nix-snapd/pull/2

arbv commented 9 months ago

@io12 Thank you! It is very important, as it complements GUI-oriented flatpaks nicely.

sehe commented 5 months ago

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)

jotapesse commented 4 months ago

Skype is another example of being currently available (updated) only as a SNAP package. References:

  1. skypeforlinux 8.110.76.107 says there is new versions available;
  2. Skype for Linux Updates;
Sepero commented 4 months ago

From the link above:

Hello, Skype users!

We have some important news to share with you today. As you may know, Skype is available on various platforms, including Windows, Mac, Linux, Android, iOS, and web. However, maintaining different versions of Skype for different operating systems can be challenging and time-consuming. That's why we have decided to discontinue the distribution of Skype as DEB and RPM packages for Linux users, and instead focus on delivering Skype as a SNAP package.

jotapesse commented 4 months ago

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.