flakes: Migrate the config and miku to flakes

This commit is contained in:
2021-11-01 21:33:21 +01:00
parent 09d385806a
commit 1d8f2f8053
64 changed files with 2612 additions and 1739 deletions

View File

@@ -1,7 +1,14 @@
{ pkgs, ... }:
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [ virglrenderer ];
let
cfg = config.ptw.virtualisation;
in {
options.ptw.virtualisation = {
enable = lib.mkEnableOption "Enable and configure virtualisation";
};
services.spice-vdagentd.enable = true;
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ virglrenderer ];
services.spice-vdagentd.enable = true;
};
}

View File

@@ -1,8 +1,15 @@
{ pkgs, ... }:
{ config, lib, pkgs, ... }:
{
environment.etc = {
"evdev-proxy/config.toml".source = pkgs.writeText "config.toml" ''
let
cfg = config.ptw.virtualisation.gaming;
in {
options.ptw.virtualisation.gaming = {
enable = lib.mkEnableOption "Configure virtualisation for gaming purposes";
};
config = lib.mkIf cfg.enable {
environment.etc = {
"evdev-proxy/config.toml".source = pkgs.writeText "config.toml" ''
log_level = "INFO"
[[device]]
@@ -27,9 +34,9 @@
[[device.Simple.selector]]
EVDEVClass = {phys="\"key-mapper\""}
'';
"libvirt/hooks/qemu".source = let
vfio-isolate-state = "/tmp/vfio-isolate-state";
in pkgs.writeScript "qemu" ''
"libvirt/hooks/qemu".source = let
vfio-isolate-state = "/tmp/vfio-isolate-state";
in pkgs.writeScript "qemu" ''
#!${pkgs.stdenv.shell}
guest=$1
action=$2
@@ -65,14 +72,14 @@
esac
fi
'';
};
};
virtualisation.libvirtd = {
enable = true;
#qemuRunAsRoot = false;
qemuOvmf = true;
qemuPackage = pkgs.unstable.qemu;
qemuVerbatimConfig = ''
virtualisation.libvirtd = {
enable = true;
#qemuRunAsRoot = false;
qemuOvmf = true;
qemuPackage = pkgs.unstable.qemu;
qemuVerbatimConfig = ''
seccomp_sandbox = 0
cgroup_device_acl = [
"/dev/null", "/dev/full", "/dev/zero",
@@ -84,28 +91,29 @@
"/dev/input/by-id/virtual-event-EvdevProxyMouse",
"/dev/input/by-id/virtual-event-EvdevProxyTartarus",
"/dev/input/by-id/usb-Razer_Razer_BlackWidow_Ultimate-event-kbd"
]
]
'';
};
};
# NOTE: Workaround for libvirt's SYSCONFDIR being set to /var/lib
# (See https://github.com/NixOS/nixpkgs/issues/51152#issuecomment-899374407)
system.activationScripts.libvirt-hooks.text = ''
# NOTE: Workaround for libvirt's SYSCONFDIR being set to /var/lib
# (See https://github.com/NixOS/nixpkgs/issues/51152#issuecomment-899374407)
system.activationScripts.libvirt-hooks.text = ''
ln -Tfs /etc/libvirt/hooks /var/lib/libvirt/hooks
'';
#services.udev.packages = with pkgs; [ evdev-proxy ];
systemd = {
services.libvirtd.path = with pkgs; [ vfio-isolate systemd bash ];
#user.services.evdev-proxy = {
# description = "Creates virtual device to proxy evdev devices events";
# #wantedBy = [ "default.target" ];
# serviceConfig = {
# Type = "simple";
# ExecStart = "${pkgs.evdev-proxy}/bin/evdev-proxy";
# Restart = "always";
# };
#};
#services.udev.packages = with pkgs; [ evdev-proxy ];
systemd = {
services.libvirtd.path = with pkgs; [ vfio-isolate systemd bash ];
#user.services.evdev-proxy = {
# description = "Creates virtual device to proxy evdev devices events";
# #wantedBy = [ "default.target" ];
# serviceConfig = {
# Type = "simple";
# ExecStart = "${pkgs.evdev-proxy}/bin/evdev-proxy";
# Restart = "always";
# };
#};
};
};
}