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
This commit is contained in:
parent
d855bfcb3d
commit
86bc20fca0
77
hosts/slab/supergfxd.nix
Normal file
77
hosts/slab/supergfxd.nix
Normal file
@ -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
|
||||
};
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user