From 1fa05e98225e43df09162b0993d1341fafc80a4b Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Fri, 11 Feb 2022 14:01:52 +0100 Subject: [PATCH] virtiofsd: Implement --- hosts/miku.nix | 27 ++++++++-- modules/services/greetd/default.nix | 53 +++++++++++++++++++ modules/virtualisation/gaming.nix | 16 +++++- .../virtualisation/virtiofsd/default.nix | 32 +++++++++++ 4 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 modules/services/greetd/default.nix create mode 100644 packages/tools/virtualisation/virtiofsd/default.nix diff --git a/hosts/miku.nix b/hosts/miku.nix index 75eaf5b..6439247 100644 --- a/hosts/miku.nix +++ b/hosts/miku.nix @@ -16,7 +16,7 @@ }; "/mnt/Storage" = { device = "/dev/disk/by-label/storage"; - fsType = "ext4"; + fsType = "btrfs"; }; }; @@ -39,14 +39,23 @@ anki #psst ]; - + ptw = { programs = { mpv = { primaryScreen = "C27F398"; enable = true; }; - sway.enable = true; + sway = { + enable = true; + extraSessionCommands = '' + # Pick the dGPU as the first one + #DGPU_DRM_NODE=$(ls /sys/bus/pci/devices/0000:01:00.0/drm | grep card) + #IGPU_DRM_NODE=$(ls /sys/bus/pci/devices/0000:08:00.0/drm | grep card) + + #WLR_DRM_DEVICES=/dev/dri/$DGPU_DRM_NODE:/dev/dri/$IGPU_DRM_NODE + ''; + }; alacritty.enable = true; emacs.enable = true; firefox.enable = true; @@ -66,6 +75,16 @@ services = { gamemode.enable = true; gnome.enable = true; + greetd = { + enable = true; + /* + swayExtra = '' + output HDMI-A-3 transform 90 anticlockwise + + workspace 1 output HDMI-A-3 + ''; + */ + }; kanshi = let horizontal = "Samsung Electric Company C27F398 H4ZR101145"; vertical = "Goldstar Company Ltd IPS235 305NDPHKN600"; @@ -181,7 +200,7 @@ libinput.enable = true; displayManager.gdm = { wayland = true; - enable = true; + enable = false; }; }; }; diff --git a/modules/services/greetd/default.nix b/modules/services/greetd/default.nix new file mode 100644 index 0000000..3438d49 --- /dev/null +++ b/modules/services/greetd/default.nix @@ -0,0 +1,53 @@ +{ lib, config, ... }: + +let + cfg = config.ptw.services.greetd; +in { + options.ptw.services.greetd = { + enable = lib.mkEnableOption "Enable greetd with gtkgreet"; + swayExtra = lib.mkOption { + description = "Extra options to include in the sway config"; + default = ""; + }; + }; + + config = lib.mkIf cfg.enable { + users.users.greeter = { + isSystemUser = lib.mkForce false; + isNormalUser = true; + createHome = true; + uid = 992; + }; + + services = { + greetd = { + enable = true; + restart = true; + settings = { + default_session = let + swayConfig = pkgs.writeText "login-sway-config" '' + exec ${pkgs.greetd.gtkgreet}/bin/gtkgreet -l; ${pkgs.sway}/bin/swaymsg exit; + + bindsym Mod4+shift+e exec swaynag \ + -t warning \ + -m 'What do you want to do?' \ + -b 'Poweroff' 'systemctl poweroff' \ + -b 'Reboot' 'systemctl reboot' + + input "*" { + xkb_layout de + } + + ${cfg.swayExtra} + + include /etc/sway/config.d/* + ''; + in { + command = "${pkgs.sway}/bin/sway --config ${swayConfig}"; + user = "greeter"; + }; + }; + }; + }; + }; +} diff --git a/modules/virtualisation/gaming.nix b/modules/virtualisation/gaming.nix index e1bbc90..7554b3a 100644 --- a/modules/virtualisation/gaming.nix +++ b/modules/virtualisation/gaming.nix @@ -83,10 +83,22 @@ in { services.udev.packages = with pkgs; [ evdev-proxy ]; systemd = { - services.libvirtd.path = with pkgs; [ vfio-isolate systemd bash ]; + services = { + libvirtd.path = with pkgs; [ vfio-isolate systemd bash ]; + virtiofsd = { + description = "vhost-user virtio-fs device backend written in Rust"; + wantedBy = [ "default.target" "libvirtd.service" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.virtiofsd}/bin/virtiofsd --socket-path=/tmp/vfsd.sock --shared-dir /mnt/Storage/Games --announce-submounts --inode-file-handles=mandatory"; + Restart = "always"; + }; + }; + }; + user.services.evdev-proxy = { description = "Creates virtual device to proxy evdev devices events"; - #wantedBy = [ "default.target" ]; + wantedBy = [ "default.target" ]; serviceConfig = { Type = "simple"; ExecStart = "${pkgs.evdev-proxy}/bin/evdev-proxy"; diff --git a/packages/tools/virtualisation/virtiofsd/default.nix b/packages/tools/virtualisation/virtiofsd/default.nix new file mode 100644 index 0000000..9372d42 --- /dev/null +++ b/packages/tools/virtualisation/virtiofsd/default.nix @@ -0,0 +1,32 @@ +{ + lib +, rustPlatform +, pkgconfig, libcap_ng, libseccomp +, fetchFromGitLab +}: + +rustPlatform.buildRustPackage rec { + pname = "virtiofsd"; + version = "1.1.0"; + + src = fetchFromGitLab { + owner = "virtio-fs"; + repo = "virtiofsd"; + rev = "a31ad19efc302836a364fd6d79bda63160404b01"; + sha256 = "12nxm40sjx2jzl1j2czzanmk9b922dvfh64ndvgf5z4g4cviv33x"; + }; + + cargoSha256 = "sha256-uRPmZE/xc0yeurBZ4rnrZua5d4lbPwStMUacFgbquuk="; + + nativeBuildInputs = [ pkgconfig ]; + + buildInputs = [ libcap_ng libseccomp ]; + + meta = with lib; { + description = "vhost-user virtio-fs device backend written in Rust"; + homepage = "https://gitlab.com/virtio-fs/virtiofsd"; + license = licenses.bsd3; + maintainers = []; + platforms = platforms.linux; + }; +}