From 86bc20fca0fc5de0bbc12037ec0bb6d092a29568 Mon Sep 17 00:00:00 2001 From: NullBite Date: Tue, 30 Jan 2024 20:59:21 +0100 Subject: [PATCH] Add start of supergfxd.nix i have the option definition and the config derivations, but i still need to actually write the configs and figure out how to assert that the config is valid --- hosts/slab/supergfxd.nix | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 hosts/slab/supergfxd.nix diff --git a/hosts/slab/supergfxd.nix b/hosts/slab/supergfxd.nix new file mode 100644 index 0000000..f5f888c --- /dev/null +++ b/hosts/slab/supergfxd.nix @@ -0,0 +1,77 @@ +{ pkgs, lib, config, options, ... }@args: +let + gfx = { + Integrated = { + supergfxd = pkgs.writeText "supergfxd-integrated" '' +{ + "mode": "Integrated", + "vfio_enable": false, + "vfio_save": false, + "always_reboot": false, + "no_logind": false, + "logout_timeout_s": 180, + "hotplug_type": "None" +} + ''; + modprobe = pkgs.writeText "supergfxd-integrated-modprobe" '' +# Automatically generated by supergfxd +blacklist nouveau +alias nouveau off +blacklist nvidia_drm +blacklist nvidia_uvm +blacklist nvidia_modeset +blacklist nvidia +alias nvidia off + +options nvidia-drm modeset=1 + + ''; + }; + Hybrid = { + supergfxd = pkgs.writeText "supergfxd-hybrid" '' +{ + "mode": "Hybrid", + "vfio_enable": false, + "vfio_save": false, + "always_reboot": false, + "no_logind": false, + "logout_timeout_s": 180, + "hotplug_type": "None" +} + ''; + modprobe = pkgs.writeText "supergfxd-hybrid-modprobe" '' +# Automatically generated by supergfxd +blacklist nouveau +alias nouveau off +options nvidia NVreg_DynamicPowerManagement=0x02 + +options nvidia-drm modeset=1 + + ''; + }; + }; + cfg = config.nixfiles.supergfxd; + + isKeyInAttrset = let + getKeys = attrset: lib.mapAttrsToList (name: _: name) attrset; + isInList = key: list: lib.any (x: x == key) list; + in key: attrset: isInList key (getKeys attrset); + + inherit (lib) mkIf mkOption types; +in { + options = { + nixfiles.supergfxd.profile = mkOption { + type = types.str; + default = ""; + example = "Integrated"; + description = "supergfxd profile to use"; + }; + }; + + config = { + etc = mkIf (!(cfg.profile == "")) { + # TODO figure out here how to assert if the value is in the gfx attrset + # TODO actually configure the system settings here + }; + }; +}