diff --git a/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix b/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix index f75ad62..0491e7d 100755 --- a/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix +++ b/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix @@ -146,4 +146,20 @@ in programs = { password-store = enabled; }; + + dconf = { + settings = { + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".name = "Keyboard Backlight +"; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".binding = "MonBrightnessUp"; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".command = "brightnessctl -d kbd_backlight +10"; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".name = "Keyboard Backlight -"; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".binding = "MonBrightnessDown"; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".command = "brightnessctl -d kbd_backlight 10-"; + + "org/gnome/settings-daemon/plugins/media-keys".custom-keybindings = [ + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" + ]; + }; + }; } diff --git a/modules/nixos/system/default.nix b/modules/nixos/system/default.nix index bc2cb35..a9e6a65 100644 --- a/modules/nixos/system/default.nix +++ b/modules/nixos/system/default.nix @@ -8,6 +8,7 @@ in environment.systemPackages = with pkgs; [ + brightnessctl dconf disko nil @@ -28,7 +29,6 @@ in aspellDicts.en aspellDicts.en-computers aspellDicts.en-science - brightnessctl ddcui ddcutil ddccontrol diff --git a/packages/omnissa/default.nix b/packages/omnissa/default.nix new file mode 100644 index 0000000..0ee5b4b --- /dev/null +++ b/packages/omnissa/default.nix @@ -0,0 +1,174 @@ +{ + stdenv, + lib, + buildFHSEnv, + copyDesktopItems, + fetchurl, + gsettings-desktop-schemas, + makeDesktopItem, + makeWrapper, + opensc, + writeTextDir, + configText ? "", +}: +let + version = "2512"; + + sysArch = + if (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "aarch64-linux") then + "x64" + else + throw "Unsupported system: ${stdenv.hostPlatform.system}"; + # The downloaded archive also contains ARM binaries, but these have not been tested. + + # For USB support, ensure that /var/run/omnissa/ + # exists and is owned by you. Then run omnissa-usbarbitrator as root. + + mainProgram = "horizon-client"; + + # This forces the default GTK theme (Adwaita) because Horizon is prone to + # UI usability issues when using non-default themes, such as Adwaita-dark. + # wrapBinCommands = path: name: '' + # makeWrapper "$out/${path}/${name}" "$out/bin/${name}_wrapper" \ + # --set GTK_THEME Adwaita \ + # --suffix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \ + # --suffix LD_LIBRARY_PATH : "$out/lib/omnissa/horizon/crtbora:$out/lib/omnissa" + # ''; + + wrapBinCommands = path: name: '' + makeWrapper "$out/${path}/${name}" "$out/bin/${name}_wrapper" \ + --set GTK_THEME Adwaita \ + --suffix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \ + --suffix LD_LIBRARY_PATH : "$out/lib/omnissa/horizon/crtbora:$out/lib/omnissa:${stdenv.cc.cc.lib}/lib" + ''; + + omnissaHorizonClientFiles = stdenv.mkDerivation { + pname = "omnissa-horizon-files"; + inherit version; + src = fetchurl { + url = "https://download3.omnissa.com/software/CART26FQ4_LIN_2512_TARBALL/Omnissa-Horizon-Client-Linux-2512-8.17.0-20187591429.tar.gz"; + hash = "sha256-dYvP3W/tciqwazuVu4ib9gB98JUJykczd7sPCUih/Ew="; + }; + nativeBuildInputs = [ makeWrapper ]; + installPhase = '' + mkdir ext + find ${sysArch} -type f -print0 | xargs -0n1 tar -Cext --strip-components=1 -xf + + chmod -R u+w ext/usr/lib + mv ext/usr $out + cp -r ext/${sysArch}/include $out/ + cp -r ext/${sysArch}/lib $out/ + + # Horizon includes a copy of libstdc++ which is loaded via $LD_LIBRARY_PATH + # when it cannot detect a new enough version already present on the system. + # The checks are distribution-specific and do not function correctly on NixOS. + # Deleting the bundled library is the simplest way to force it to use our version. + rm "$out/lib/omnissa/gcc/libstdc++.so.6" + + # This opensc library is required to support smartcard authentication during the + # initial connection to Horizon. + mkdir $out/lib/omnissa/horizon/pkcs11 + ln -s ${opensc}/lib/pkcs11/opensc-pkcs11.so $out/lib/omnissa/horizon/pkcs11/libopenscpkcs11.so + + ${wrapBinCommands "bin" "horizon-client"} + ${wrapBinCommands "lib/omnissa/horizon/usb" "horizon-eucusbarbitrator"} + ''; + }; + + omnissaFHSUserEnv = + pname: + buildFHSEnv { + inherit pname version; + + runScript = "${omnissaHorizonClientFiles}/bin/${pname}_wrapper"; + + targetPkgs = + pkgs: with pkgs; [ + at-spi2-atk + atk + cairo + dbus + file + fontconfig + freetype + gcc + gdk-pixbuf + glib + gtk2 + gtk3-x11 + harfbuzz + liberation_ttf + libjpeg + libpng + libpulseaudio + libtiff + libudev0-shim + libuuid + libv4l + pango + pcsclite + pixman + udev + omnissaHorizonClientFiles + openssl + libx11 + libxau + libxcursor + libxext + libxi + libxinerama + libxkbfile + libxrandr + libxrender + libxscrnsaver + libxtst + zlib + libxml2_13 + + (writeTextDir "etc/omnissa/config" configText) + + stdenv.cc.cc.lib + ]; + }; + + desktopItem = makeDesktopItem { + name = "horizon-client"; + desktopName = "Omnissa Horizon Client"; + icon = "${omnissaHorizonClientFiles}/share/icons/horizon-client.png"; + exec = "${omnissaFHSUserEnv mainProgram}/bin/${mainProgram} %u"; + mimeTypes = [ + "x-scheme-handler/horizon-client" + "x-scheme-handler/vmware-view" + ]; + }; + +in +stdenv.mkDerivation { + pname = "omnissa-horizon-client"; + inherit version; + + dontUnpack = true; + + nativeBuildInputs = [ copyDesktopItems ]; + + desktopItems = [ desktopItem ]; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin + ln -s ${omnissaFHSUserEnv "horizon-client"}/bin/horizon-client $out/bin/ + ln -s ${omnissaFHSUserEnv "omnissa-usbarbitrator"}/bin/omnissa-usbarbitrator $out/bin/ + runHook postInstall + ''; + + unwrapped = omnissaHorizonClientFiles; + + meta = { + inherit mainProgram; + description = "Allows you to connect to your Omnissa Horizon virtual desktop"; + homepage = "https://www.omnissa.com/products/horizon-8/"; + license = lib.licenses.unfree; + platforms = [ "x86_64-linux" "aarch64-linux" ]; + maintainers = with lib.maintainers; [ mhutter ]; + }; +} \ No newline at end of file diff --git a/systems/aarch64-linux/macbook-pro-nixos/default.nix b/systems/aarch64-linux/macbook-pro-nixos/default.nix index 8037d08..df405ae 100755 --- a/systems/aarch64-linux/macbook-pro-nixos/default.nix +++ b/systems/aarch64-linux/macbook-pro-nixos/default.nix @@ -61,7 +61,7 @@ hardware = { battery = { enable = true; - battery = " /sys/class/power_supply/macsmc-battery/charge_control_end_threshold"; + battery = "/sys/class/power_supply/macsmc-battery/charge_control_end_threshold"; }; }; network = { @@ -130,7 +130,9 @@ (pkgs.OVMF.override { secureBoot = true; }) - ]; + ] ++ (with pkgs.${namespace}; [ + omnissa + ]); networking.networkmanager.wifi.backend = "iwd"; diff --git a/systems/aarch64-linux/macbook-pro-nixos/hardware-configuration.nix b/systems/aarch64-linux/macbook-pro-nixos/hardware-configuration.nix index a7ba032..0d91dc3 100644 --- a/systems/aarch64-linux/macbook-pro-nixos/hardware-configuration.nix +++ b/systems/aarch64-linux/macbook-pro-nixos/hardware-configuration.nix @@ -35,7 +35,7 @@ fileSystems."/home" = { device = "/dev/mapper/cryptroot"; fsType = "btrfs"; - options = [ "subvol=home" ]; + options = [ "subvol=home" "compress=zstd" ]; }; boot.initrd.luks.devices."cryptroot".device = @@ -44,31 +44,31 @@ fileSystems."/persist" = { device = "/dev/mapper/cryptroot"; fsType = "btrfs"; - options = [ "subvol=persist" ]; + options = [ "subvol=persist" "compress=zstd" ]; }; fileSystems."/etc" = { device = "/dev/mapper/cryptroot"; fsType = "btrfs"; - options = [ "subvol=etc" ]; + options = [ "subvol=etc" "compress=zstd" ]; }; fileSystems."/root" = { device = "/dev/mapper/cryptroot"; fsType = "btrfs"; - options = [ "subvol=root" ]; + options = [ "subvol=root" "compress=zstd" ]; }; fileSystems."/nix" = { device = "/dev/mapper/cryptroot"; fsType = "btrfs"; - options = [ "subvol=nix" ]; + options = [ "subvol=nix" "compress=zstd" ]; }; fileSystems."/var/log" = { device = "/dev/mapper/cryptroot"; fsType = "btrfs"; - options = [ "subvol=log" ]; + options = [ "subvol=log" "compress=zstd" ]; }; swapDevices = [ ];