fictionbecomesfact / fictionbecomesfact_comments

0 stars 0 forks source link

Comments: NixOS - Add Virtual Machines UI to Cockpit #70

Open fictionbecomesfact opened 8 months ago

fictionbecomesfact commented 8 months ago

Comments for NixOS - Add Virtual Machines UI to Cockpit

inhumantsar commented 3 months ago

hey! this page was super helpful and i was able to use it to get cockpit-machines running. you were missing libvirt-dbus. i haven't actually tried creating any VMs yet, but everything seems happy atm so i thought i'd share.

this is how i went about it:

/etc/nixos/packages/libvirt-dbus/default.nix From https://github.com/X01A/nixos/blob/master/packages/libvirt-dbus/pkg.nix ``` { lib , stdenv, fetchFromGitLab, meson, pkg-config, glib, libvirt, libvirt-glib, docutils, ninja, pkgs, ...}: pkgs.stdenv.mkDerivation rec { pname = "libvirt-dbus"; version = "1.4.1"; src = fetchFromGitLab { owner = "libvirt"; repo = "libvirt-dbus"; rev = "v${version}"; sha256 = "sha256:112jbkp2b0pk6dpb0p68zg1ba196f4i0y57s1jzjn5vl4f11fv3g"; }; mesonFlags = [ "-Dsystem_user=root" ]; nativeBuildInputs = [ meson pkg-config docutils ninja ]; buildInputs = [ glib libvirt libvirt-glib ]; meta = with lib; { description = "DBus protocol binding for libvirt native C API"; license = licenses.lgpl2Plus; homepage = src.meta.homepage; platforms = platforms.linux; maintainers = with maintainers; [ ]; }; } ```
/etc/nixos/packages/cockpit-machines/default.nix From https://github.com/X01A/nixos/blob/master/packages/cockpit-machines/pkg.nix ``` { lib, stdenv, fetchzip, gettext, gobject-introspection, osinfo-db-tools, python3Packages, pkgs, ... }: pkgs.stdenv.mkDerivation rec { pname = "cockpit-machines"; version = "309"; src = fetchzip { url = "https://github.com/cockpit-project/cockpit-machines/releases/download/${version}/cockpit-machines-${version}.tar.xz"; sha256 = "sha256-sVjP3KFmZH3c2tGzlEohAue0u2e7+vAmXBBA+5uuass="; }; # gobject-introspection works now, thanks to the post below. but... # https://discourse.nixos.org/t/getting-things-gnome-modulenotfounderror-no-module-named-gi/8439/4 # ...the python script that cockpit-machines runs is failing with a "No such file or directory" error. # the script loads properly and i'm not getting an import or gi "Namespace Libosinfo is not available" # error, so i'm thinking that the OSINFO_DATA_DIR env var needs to be set. however... nativeBuildInputs = [ gettext gobject-introspection osinfo-db-tools ]; # ...osinfo-db doesn't show up in nix-support/propagated-build-inputs, and... propagatedBuildInputs = with pkgs; [ python3Packages.pygobject3 libosinfo osinfo-db ]; makeFlags = [ "DESTDIR=$(out)" "PREFIX=" ]; postPatch = '' touch pkg/lib/cockpit.js touch pkg/lib/cockpit-po-plugin.js touch dist/manifest.json ''; postFixup = '' gunzip $out/share/cockpit/machines/index.js.gz sed -i "s#/usr/bin/python3#/usr/bin/env python3#ig" $out/share/cockpit/machines/index.js sed -i "s#/usr/bin/pwscore#/usr/bin/env pwscore#ig" $out/share/cockpit/machines/index.js gzip -9 $out/share/cockpit/machines/index.js # ...this doesn't work either osinfo-db-import --dir "$out/share/osinfo" "${pkgs.osinfo-db.src}" ''; dontBuild = true; meta = with lib; { description = "Cockpit UI for virtual machines"; license = licenses.lgpl21; homepage = "https://github.com/cockpit-project/cockpit-machines"; platforms = platforms.linux; maintainers = with maintainers; [ ]; }; } ```

and finally install in configuration.nix

let
  cockpit-machines = pkgs.callPackage packages/cockpit-machines/default.nix { inherit pkgs; };
  libvirt-dbus = pkgs.callPackage packages/libvirt-dbus/default.nix { inherit pkgs; };
in
{
  ...
  environment.systemPackages = with pkgs; [
    cockpit
    cockpit-machines
    virt-manager # needed for cockpit-machines
    libvirt-dbus # needed for cockpit-machines
  ];
  ...
inhumantsar commented 3 months ago

well i was never able to get a VM created. can't get the oslibinfo call it makes to populate the OS list to work.

there's a request open for this and i commented on my progress there in case you want to try again.

fictionbecomesfact commented 3 months ago

Too bad it didn't work out. But good to know, thank you! I'll keep an eye on the package request, if it works I'll definitely give it a try