Skip to content

Conversation

minijackson
Copy link
Member

Description of changes

This removes the package 'libguestfs-with-appliance', and adds the package 'libguestfsMinimal' without the appliance.

This makes nixpkgs packages use the appliance by default,
which fixes the user experienc of having the "no appliance" error
message in certain cases, for example the 'guestmount' command, and
running 'diffoscope' on disk images.

I'm proposing this because I just kept running into #37540-style issues, often without an easy way out (e.g. diffoscope using the guestfs Python package).

This also re-enables building the libguestfs with appliance on Hydra.

Note: the appliance was disabled by default in #56448 (cc @grahamc if you think this PR is acceptable), and disabled on Hydra a long time ago in ac52817. We should test if Hydra is fine with it now, but I'm not sure how.

cc @offlinehacker

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Result of nixpkgs-review run on x86_64-linux 1

1 package blacklisted:
  • nixos-install-tools
13 packages built:
  • diffoscope
  • diffoscope.dist
  • diffoscope.man
  • diffoscopeMinimal
  • diffoscopeMinimal.dist
  • diffoscopeMinimal.man
  • libguestfs
  • libguestfsMinimal
  • python310Packages.guestfs
  • python310Packages.guestfs.dist
  • python311Packages.guestfs
  • python311Packages.guestfs.dist
  • vagrant

Add a 👍 reaction to pull requests you find important.

this removes the package 'libguestfs-with-appliance',
and adds the package 'libguestfsMinimal' without the appliance.

This makes nixpkgs packages use the appliance by default,
which fixes the user experienc of having the "no appliance" error
message in certain cases, for example the 'guestmount' command, and
running 'diffoscope' on disk images.
They seem to be broken upstream
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog This PR adds or changes release notes labels Jan 5, 2024
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Jan 5, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jan 5, 2024
Copy link
Member

@wegank wegank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libguestfs-appliance is not compatible with non-x86 platforms, so this PR breaks diffoscope on aarch64-linux.

@minijackson
Copy link
Member Author

@wegank good catch! Do you know if it's just our package, or if the upstream code really isn't compatible with other architectures?

@wegank
Copy link
Member

wegank commented Jan 5, 2024

I am not aware of how other distros do, but our own libguestfs-appliance simply fetches and extracts the prebuilt appliance from upstream (which is x86).

@minijackson
Copy link
Member Author

I'll work on building the appliance from source, then. I think I'm close to succeeding, but there's still a weird issue where augeas.c can't find a libxml2 include…

@minijackson minijackson marked this pull request as draft January 5, 2024 23:11
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 20, 2024
@Et7f3
Copy link
Contributor

Et7f3 commented Mar 27, 2024

@minijackson I am also interested in supermin support. Have you a branch/something I could look at and try to fix ?

@minijackson
Copy link
Member Author

@Et7f3 I've pushed what I have in the guestfs-default-appliance-wip branch of my fork:

https://github.com/minijackson/nixpkgs/tree/guestfs-default-appliance-wip

But it's more complicated than I initially thought. Building the appliance is about building a small image of a given Linux distribution, with some tools installed.

How supermin does it is by using the host's package manager to create a small rootfs, and install extra packages in it. The call to the host's package manager needs internet connection, and assumes the host is configured with repos and such.

That doesn't work for us. I think the best we could do would be to create our own small NixOS appliance with the same tools installed, and the same init script.

For more info in the libguestfs source code:

  • m4/guestfs-appliance.m4 search for the --with-distro option
  • appliance/Makefile.am search for:
    • the HAVE_RPM conditional
    • the guestfsd.deps target
  • appliance/packagelist.in
  • appliance/make.sh.in (the script that builds the appliance)
  • appliance/init (the init script for the appliance)

On another note, I don't think supermin can work on NixOS without either upstream support for NixOS, or using something like Distrobox. But both would only work in the Nix sandbox by using a fixed-output derivation and fixed repos (like CentOS/Rocky's vault repos), or by using impure derivations.

Thanks for reaching out, I'm quite busy these days, but still open for discussion if you're still interested.

@Et7f3
Copy link
Contributor

Et7f3 commented Mar 28, 2024

I thought about patching supermin upstream like suggested by main dev or bypass supermin and use out tooling to directly create an image.

filename = "nixos." + {
qcow2 = "qcow2";
vdi = "vdi";
vpc = "vhd";
raw = "img";
}.${format} or format;

with this second solution we could have even smaller images than with supermin.

EDIT: thanks for those hints through codebase.

@malte-v
Copy link
Contributor

malte-v commented Apr 3, 2024

I think porting supermin to NixOS will be quite difficult; the code is very much distro-specific and the currently supported distros (Fedora, Debian, ...) are nothing like NixOS. Another option would be to build a fixed appliance (like the ones being distributed at https://download.libguestfs.org/binaries/appliance/) in a debian guest using vmTools.runInLinuxImage and libguestfs-make-fixed-appliance. I've implemented this because I needed an aarch64 libguestfs appliance, which is currently not available as a binary, and it works quite well. The downside is that we'll depend on Debian (or another distro supported by supermin) to package new versions of libguestfs, but the maintenance burden for us would be minimal. I could make a PR using that approach, although the builder is currently a little bit hacky because libguestfs-make-fixed-appliance fails to test the appliance it has built due to nested KVM virtualization not being supported in the vmTools VM (probably due to #300084). What do you think?

@lukts30 lukts30 mentioned this pull request Oct 3, 2024
13 tasks
@MrQubo
Copy link
Contributor

MrQubo commented Nov 28, 2024

I think porting supermin to NixOS will be quite difficult; the code is very much distro-specific and the currently supported distros (Fedora, Debian, ...) are nothing like NixOS. Another option would be to build a fixed appliance (like the ones being distributed at https://download.libguestfs.org/binaries/appliance/) in a debian guest using vmTools.runInLinuxImage and libguestfs-make-fixed-appliance. I've implemented this because I needed an aarch64 libguestfs appliance, which is currently not available as a binary, and it works quite well. The downside is that we'll depend on Debian (or another distro supported by supermin) to package new versions of libguestfs, but the maintenance burden for us would be minimal. I could make a PR using that approach, although the builder is currently a little bit hacky because libguestfs-make-fixed-appliance fails to test the appliance it has built due to nested KVM virtualization not being supported in the vmTools VM (probably due to #300084). What do you think?

Fixed appliance is what is currently packaged. According to the docs the performance is the same. If you try grepping debian in nixpkgs you can see there are already many dependencies.
As a side note, won't container or even chroot be enough to run libguestfs-make-fixed-appliance? This should improve build times. Building in container would be a lot of work, but building in debian chroot might be feasible by using existing code from buildFHSEnv.

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 2, 2025
@malte-v
Copy link
Contributor

malte-v commented Feb 11, 2025

I think porting supermin to NixOS will be quite difficult; the code is very much distro-specific and the currently supported distros (Fedora, Debian, ...) are nothing like NixOS. Another option would be to build a fixed appliance (like the ones being distributed at https://download.libguestfs.org/binaries/appliance/) in a debian guest using vmTools.runInLinuxImage and libguestfs-make-fixed-appliance. I've implemented this because I needed an aarch64 libguestfs appliance, which is currently not available as a binary, and it works quite well. The downside is that we'll depend on Debian (or another distro supported by supermin) to package new versions of libguestfs, but the maintenance burden for us would be minimal. I could make a PR using that approach, although the builder is currently a little bit hacky because libguestfs-make-fixed-appliance fails to test the appliance it has built due to nested KVM virtualization not being supported in the vmTools VM (probably due to #300084). What do you think?

I've made a PR using this approch here: #381224

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 11, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants