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
78 lines
1.7 KiB
Nix
78 lines
1.7 KiB
Nix
{ 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
|
|
};
|
|
};
|
|
}
|