From 2d0ccc0ec0850299e9af72e1e34468552b5e48be Mon Sep 17 00:00:00 2001 From: Pasquale Date: Thu, 13 Aug 2020 15:45:46 +0200 Subject: [PATCH 1/2] switcheroo-control: init at 2.3 switcheroo-control: addded to package set --- .../linux/switcheroo-control/default.nix | 58 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 60 insertions(+) create mode 100644 pkgs/os-specific/linux/switcheroo-control/default.nix diff --git a/pkgs/os-specific/linux/switcheroo-control/default.nix b/pkgs/os-specific/linux/switcheroo-control/default.nix new file mode 100644 index 00000000000..38945c70622 --- /dev/null +++ b/pkgs/os-specific/linux/switcheroo-control/default.nix @@ -0,0 +1,58 @@ +{ lib +, ninja +, meson +, fetchFromGitLab +, systemd +, libgudev +, pkg-config +, glib +, python3 +, gobject-introspection +}: + +python3.pkgs.buildPythonApplication rec { + pname = "switcheroo-control"; + version = "2.3"; + + format = "other"; + + src = fetchFromGitLab { + domain = "gitlab.freedesktop.org"; + owner = "hadess"; + repo = pname; + rev = version; + hash = "sha256-1Pze2TJ9mggfcpiLFwJ7/9WhsdJx4G3GoA7+Z47shuc="; + }; + + nativeBuildInputs = [ + ninja + meson + pkg-config + + # needed for glib-compile-resources + glib + ]; + + buildInputs = [ + systemd + libgudev + ]; + + propagatedBuildInputs = [ + python3.pkgs.pygobject3 + ]; + + mesonFlags = [ + "-Dsystemdsystemunitdir=${placeholder "out"}/etc/systemd/system" + "-Dhwdbdir=${placeholder "out"}/etc/udev/hwdb.d" + ]; + + meta = with lib; { + description = "D-Bus service to check the availability of dual-GPU"; + homepage = "https://gitlab.freedesktop.org/hadess/switcheroo-control/"; + changelog = "https://gitlab.freedesktop.org/hadess/switcheroo-control/-/blob/${version}/NEWS"; + license = licenses.gpl3Plus; + maintainers = [ ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bbbefbd8a71..2516c4e9f1c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18432,6 +18432,8 @@ in storm = callPackage ../servers/computing/storm { }; + switcheroo-control = callPackage ../os-specific/linux/switcheroo-control { }; + slurm = callPackage ../servers/computing/slurm { gtk2 = null; }; slurm-spank-x11 = callPackage ../servers/computing/slurm-spank-x11 { }; From f5f9a069d9d95e7f1b2f5f2aea84a1d9b9411e52 Mon Sep 17 00:00:00 2001 From: Pasquale Date: Thu, 13 Aug 2020 15:46:24 +0200 Subject: [PATCH 2/2] nixos/switcheroo-control: added nixos option node/switcheroo-control: better formatting --- .../hardware/video/switcheroo-control.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 nixos/modules/hardware/video/switcheroo-control.nix diff --git a/nixos/modules/hardware/video/switcheroo-control.nix b/nixos/modules/hardware/video/switcheroo-control.nix new file mode 100644 index 00000000000..199adb2ad8f --- /dev/null +++ b/nixos/modules/hardware/video/switcheroo-control.nix @@ -0,0 +1,18 @@ +{ config, pkgs, lib, ... }: + +with lib; +let + pkg = [ pkgs.switcheroo-control ]; + cfg = config.services.switcherooControl; +in { + options.services.switcherooControl = { + enable = mkEnableOption "switcheroo-control, a D-Bus service to check the availability of dual-GPU"; + }; + + config = mkIf cfg.enable { + services.dbus.packages = pkg; + environment.systemPackages = pkg; + systemd.packages = pkg; + systemd.targets.multi-user.wants = [ "switcheroo-control.service" ]; + }; +}