diff --git a/.editorconfig b/.editorconfig index 96e5188..0cce8f9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -24,6 +24,14 @@ charset = unset indent_style = unset indent_size = unset +[*.rom] +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset +charset = unset +indent_style = unset +indent_size = unset + [*.py] indent_size = 4 diff --git a/flake.lock b/flake.lock index 169c084..b3efea0 100644 --- a/flake.lock +++ b/flake.lock @@ -206,21 +206,6 @@ "type": "github" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1623875721, - "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "home": { "inputs": { "nixpkgs": [ @@ -261,7 +246,9 @@ "naersk": { "inputs": { "nixpkgs": [ - "latest" + "digga", + "deploy", + "nixpkgs" ] }, "locked": { @@ -299,25 +286,6 @@ "type": "github" } }, - "nix-dram": { - "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1628492639, - "narHash": "sha256-ffF/oEhLs/stAsXXobruKHyH9jnMC2rt/SM3ASrs2U8=", - "owner": "dramforever", - "repo": "nix-dram", - "rev": "fba426108ea6bdeb1e362bac9da06cbd33726f41", - "type": "github" - }, - "original": { - "owner": "dramforever", - "repo": "nix-dram", - "type": "github" - } - }, "nixos": { "locked": { "lastModified": 1628203131, @@ -374,22 +342,6 @@ "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 1626556499, - "narHash": "sha256-c2ueMT7fi/yvCNq3nGLEC2v5GklS7eHpB1240LRSW9Y=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b59c06dc92f8d03660eb4155754d93a6c34cda83", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nur": { "locked": { "lastModified": 1626378135, @@ -459,7 +411,6 @@ "home": "home", "latest": "latest", "naersk": "naersk_2", - "nix-dram": "nix-dram", "nixlib": [ "digga", "nixlib" diff --git a/flake.nix b/flake.nix index 4684fc5..7515f93 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,10 @@ # PubSolarOS additions nix-dram.url = "github:dramforever/nix-dram"; + + # b12f additions + b12f-nix-fonts.url = "git+https://git.b12f.io/b12f/nix-fonts?ref=main"; + b12f-nix-fonts.inputs.nixpkgs.follows = "latest"; }; outputs = @@ -65,6 +69,7 @@ , nvfetcher , deploy , nix-dram + , b12f-nix-fonts , ... } @ inputs: digga.lib.mkFlake @@ -83,6 +88,7 @@ nvfetcher.overlay deploy.overlay nix-dram.overlay + b12f-nix-fonts.overlay ./pkgs/default.nix ]; }; @@ -128,6 +134,8 @@ base = [ core users.nixos users.root ]; pubsolaros = [ core base-user users.root ]; anonymous = [ pubsolaros users.nixos ]; + b12f = [ pubsolaros users.ben ]; + biolimo = [ b12f graphical ]; }; }; }; diff --git a/hosts/biolimo.nix b/hosts/biolimo.nix new file mode 100644 index 0000000..64fd4b3 --- /dev/null +++ b/hosts/biolimo.nix @@ -0,0 +1,6 @@ +{ suites, ... }: +{ + imports = [ + ./biolimo + ] ++ suites.biolimo; +} diff --git a/hosts/biolimo/.config/sway/config.d/autostart.conf b/hosts/biolimo/.config/sway/config.d/autostart.conf new file mode 100644 index 0000000..173376b --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/autostart.conf @@ -0,0 +1,6 @@ +# Autostart applications +# +# Example: +# exec swayidle + +exec keepassxc diff --git a/hosts/biolimo/.config/sway/config.d/custom-keybindings.conf b/hosts/biolimo/.config/sway/config.d/custom-keybindings.conf new file mode 100644 index 0000000..4a95431 --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/custom-keybindings.conf @@ -0,0 +1,19 @@ +# Touchpad controls +#bindsym XF86TouchpadToggle exec $HOME/Workspace/ben/toggletouchpad.sh # toggle touchpad + +# Screen brightness controls +bindsym XF86MonBrightnessUp exec "brightnessctl -d intel_backlight set +10%; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ {print $4}')" +bindsym XF86MonBrightnessDown exec "brightnessctl -d intel_backlight set 10%-; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ { print $4}')" + +# Keyboard backlight brightness controls +bindsym XF86KbdBrightnessDown exec "brightnessctl -d smc::kbd_backlight set 10%-; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" +bindsym XF86KbdBrightnessUp exec "brightnessctl -d smc::kbd_backlight set +10%; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" + +# Pulse Audio controls +bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. up' #increase sound volume +bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. down' #decrease sound volume +bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && notify-send 'Mute sound' # mute sound +# Media player controls +bindsym XF86AudioPlay exec "playerctl play-pause; notify-send 'Play/Pause'" +bindsym XF86AudioNext exec "playerctl next; notify-send 'Next'" +bindsym XF86AudioPrev exec "playerctl previous; notify-send 'Prev.'" diff --git a/hosts/biolimo/.config/sway/config.d/input-defaults.conf b/hosts/biolimo/.config/sway/config.d/input-defaults.conf new file mode 100644 index 0000000..426eb5b --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/input-defaults.conf @@ -0,0 +1,9 @@ +input "1739:0:Synaptics_TM3288-011" { + dwt enabled + tap enabled + middle_emulation enabled +} +input * { + xkb_layout us(intl),de + xkb_options ctrl:nocaps +} diff --git a/hosts/biolimo/.config/sway/config.d/screens.conf b/hosts/biolimo/.config/sway/config.d/screens.conf new file mode 100644 index 0000000..64869b6 --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/screens.conf @@ -0,0 +1,21 @@ +set $internal eDP-1 +set $middle "Hewlett Packard HP E231 3CQ4290S5J" +set $standup "Hewlett Packard HP E231 3CQ4251F33" + +output $internal { + scale 1.3 + pos 0 500 +} + +output $middle { + scale 1 + + # 1969 is the 1.3 scaled width of the internal monitor + pos 1969 0 +} + +output $standup { + scale 1 + transform 270 + pos 3889 0 +} diff --git a/hosts/biolimo/.gitattributes b/hosts/biolimo/.gitattributes new file mode 100644 index 0000000..793fb47 --- /dev/null +++ b/hosts/biolimo/.gitattributes @@ -0,0 +1 @@ +secrets/** filter=git-crypt-4406E80E13CD656C diff=git-crypt-4406E80E13CD656C diff --git a/hosts/biolimo/configuration.nix b/hosts/biolimo/configuration.nix new file mode 100644 index 0000000..76207fd --- /dev/null +++ b/hosts/biolimo/configuration.nix @@ -0,0 +1,96 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # networking.hostName = "nixos"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Set your time zone. + # time.timeZone = "Europe/Amsterdam"; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n.defaultLocale = "en_US.UTF-8"; + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # }; + + # Enable the X11 windowing system. + # services.xserver.enable = true; + + + + + # Configure keymap in X11 + # services.xserver.layout = "us"; + # services.xserver.xkbOptions = "eurosign:e"; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + # sound.enable = true; + # hardware.pulseaudio.enable = true; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + # users.users.jane = { + # isNormalUser = true; + # extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + # }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + # environment.systemPackages = with pkgs; [ + # wget vim + # firefox + # ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.05"; # Did you read the comment? + +} + diff --git a/hosts/biolimo/default.nix b/hosts/biolimo/default.nix new file mode 100644 index 0000000..51f2e76 --- /dev/null +++ b/hosts/biolimo/default.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + imports = [ + ./configuration.nix + ]; + + config = { + pub-solar.x-os.keyfile = "/etc/nixos/hosts/biolimo/secrets/keyfile.bin"; + + hardware.cpu.intel.updateMicrocode = true; + + networking.firewall.allowedTCPPorts = [ + 5000 + ]; + + home-manager.users."${psCfg.user.name}".xdg.configFile = mkIf psCfg.sway.enable { + "sway/config.d/10-screens.conf".source = ./.config/sway/config.d/screens.conf; + "sway/config.d/10-autostart.conf".source = ./.config/sway/config.d/autostart.conf; + "sway/config.d/10-input-defaults.conf".source = ./.config/sway/config.d/input-defaults.conf; + "sway/config.d/10-custom-keybindings.conf".source = ./.config/sway/config.d/custom-keybindings.conf; + }; + }; +} diff --git a/hosts/biolimo/hardware-configuration.nix b/hosts/biolimo/hardware-configuration.nix new file mode 100644 index 0000000..dcd0786 --- /dev/null +++ b/hosts/biolimo/hardware-configuration.nix @@ -0,0 +1,36 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/abc3fe04-368e-46eb-8c7a-3a829bb2deab"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/aed21f8d-8e15-4f43-8710-460cb36d488b"; + + fileSystems."/boot/efi" = + { + device = "/dev/disk/by-uuid/3B67-0CAB"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + # high-resolution display + hardware.video.hidpi.enable = lib.mkDefault true; +} diff --git a/hosts/biolimo/secrets/keyfile.bin b/hosts/biolimo/secrets/keyfile.bin new file mode 100644 index 0000000..143d8bc Binary files /dev/null and b/hosts/biolimo/secrets/keyfile.bin differ diff --git a/hosts/chocolatebar/.config/sway/config.d/autostart.conf b/hosts/chocolatebar/.config/sway/config.d/autostart.conf new file mode 100644 index 0000000..173376b --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/autostart.conf @@ -0,0 +1,6 @@ +# Autostart applications +# +# Example: +# exec swayidle + +exec keepassxc diff --git a/hosts/chocolatebar/.config/sway/config.d/custom-keybindings.conf b/hosts/chocolatebar/.config/sway/config.d/custom-keybindings.conf new file mode 100644 index 0000000..4a95431 --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/custom-keybindings.conf @@ -0,0 +1,19 @@ +# Touchpad controls +#bindsym XF86TouchpadToggle exec $HOME/Workspace/ben/toggletouchpad.sh # toggle touchpad + +# Screen brightness controls +bindsym XF86MonBrightnessUp exec "brightnessctl -d intel_backlight set +10%; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ {print $4}')" +bindsym XF86MonBrightnessDown exec "brightnessctl -d intel_backlight set 10%-; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ { print $4}')" + +# Keyboard backlight brightness controls +bindsym XF86KbdBrightnessDown exec "brightnessctl -d smc::kbd_backlight set 10%-; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" +bindsym XF86KbdBrightnessUp exec "brightnessctl -d smc::kbd_backlight set +10%; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" + +# Pulse Audio controls +bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. up' #increase sound volume +bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. down' #decrease sound volume +bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && notify-send 'Mute sound' # mute sound +# Media player controls +bindsym XF86AudioPlay exec "playerctl play-pause; notify-send 'Play/Pause'" +bindsym XF86AudioNext exec "playerctl next; notify-send 'Next'" +bindsym XF86AudioPrev exec "playerctl previous; notify-send 'Prev.'" diff --git a/hosts/chocolatebar/.config/sway/config.d/input-defaults.conf b/hosts/chocolatebar/.config/sway/config.d/input-defaults.conf new file mode 100644 index 0000000..426eb5b --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/input-defaults.conf @@ -0,0 +1,9 @@ +input "1739:0:Synaptics_TM3288-011" { + dwt enabled + tap enabled + middle_emulation enabled +} +input * { + xkb_layout us(intl),de + xkb_options ctrl:nocaps +} diff --git a/hosts/chocolatebar/.config/sway/config.d/screens.conf b/hosts/chocolatebar/.config/sway/config.d/screens.conf new file mode 100644 index 0000000..1337a8d --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/screens.conf @@ -0,0 +1,21 @@ +set $internal eDP-1 +set $middle DP-4 +set $standup DP-5 + +output $internal { + scale 1.3 + pos 0 500 +} + +output $middle { + scale 1 + + # 1969 is the 1.3 scaled width of the internal monitor + pos 1969 0 +} + +output $standup { + scale 1 + transform 270 + pos 3889 0 +} diff --git a/hosts/chocolatebar/.gitattributes b/hosts/chocolatebar/.gitattributes new file mode 100644 index 0000000..793fb47 --- /dev/null +++ b/hosts/chocolatebar/.gitattributes @@ -0,0 +1 @@ +secrets/** filter=git-crypt-4406E80E13CD656C diff=git-crypt-4406E80E13CD656C diff --git a/hosts/chocolatebar/default.nix b/hosts/chocolatebar/default.nix new file mode 100644 index 0000000..8f25b80 --- /dev/null +++ b/hosts/chocolatebar/default.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + imports = [ + ./virtualisation + ]; + + config = { + pub-solar.virtualisation.enable = true; + + hardware.cpu.amd.updateMicrocode = true; + + hardware.opengl.extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + ]; + + home-manager.users."${psCfg.user.name}".xdg.configFile = mkIf psCfg.sway.enable { + "sway/config.d/10-autostart.conf".source = ./.config/sway/config.d/autostart.conf; + "sway/config.d/10-input-defaults.conf".source = ./.config/sway/config.d/input-defaults.conf; + "sway/config.d/10-screens.conf".source = ./.config/sway/config.d/screens.conf; + }; + }; +} diff --git a/hosts/chocolatebar/secrets/.gitkeep b/hosts/chocolatebar/secrets/.gitkeep new file mode 100644 index 0000000..43bd4fb Binary files /dev/null and b/hosts/chocolatebar/secrets/.gitkeep differ diff --git a/hosts/chocolatebar/secrets/crypto_keyfile.bin b/hosts/chocolatebar/secrets/crypto_keyfile.bin new file mode 100644 index 0000000..ca34df9 Binary files /dev/null and b/hosts/chocolatebar/secrets/crypto_keyfile.bin differ diff --git a/hosts/chocolatebar/secrets/hdd_keyfile.bin b/hosts/chocolatebar/secrets/hdd_keyfile.bin new file mode 100644 index 0000000..2c6b25f Binary files /dev/null and b/hosts/chocolatebar/secrets/hdd_keyfile.bin differ diff --git a/hosts/chocolatebar/secrets/keyfile.bin b/hosts/chocolatebar/secrets/keyfile.bin new file mode 100644 index 0000000..38577a0 Binary files /dev/null and b/hosts/chocolatebar/secrets/keyfile.bin differ diff --git a/hosts/chocolatebar/virtualisation/create-service.nix b/hosts/chocolatebar/virtualisation/create-service.nix new file mode 100644 index 0000000..f3eab3b --- /dev/null +++ b/hosts/chocolatebar/virtualisation/create-service.nix @@ -0,0 +1,78 @@ +{ config, pkgs, lib, vm, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + varsFile = "${xdg.dataHome}/libvirt/OVMF_VARS_${vm.name}.fd"; + generateXML = import ./generate-xml.nix; +in +{ + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = "yes"; + Restart = "no"; + }; + + script = + let + networkXML = pkgs.writeText "network.xml" (import ./network-xml.nix { inherit config; inherit pkgs; inherit lib; }); + machineXML = pkgs.writeText "${vm.name}.xml" (generateXML { inherit config; inherit pkgs; inherit lib; inherit vm; varsFile = varsFile; }); + in + '' + echo "Checking if ${vm.name} is already running" + STATUS=$(${pkgs.libvirt}/bin/virsh list --all | grep "${vm.name}" | ${pkgs.gawk}/bin/awk '{ print $3 " " $4 }' ) + if [[ $STATUS != "shut off" && $STATUS != "" ]]; then + echo "Domain ${vm.name} is already running or in an inconsistent state:" + ${pkgs.libvirt}/bin/virsh list --all + exit 0 + fi + + NET_TMP_FILE="/tmp/network.xml" + + NETUUID="$(${pkgs.libvirt}/bin/virsh net-uuid 'default' || true)" + (sed "s/UUID/$NETUUID/" '${networkXML}') > $NET_TMP_FILE + + ${pkgs.libvirt}/bin/virsh net-define $NET_TMP_FILE + ${pkgs.libvirt}/bin/virsh net-start 'default' || true + + VARS_FILE=${varsFile} + if [ ! -f "$VARS_FILE" ]; then + cp /run/libvirt/nix-ovmf/OVMF_VARS.fd $VARS_FILE + fi + + TMP_FILE="/tmp/${vm.name}.xml" + + UUID="$(${pkgs.libvirt}/bin/virsh domuuid '${vm.name}' || true)" + (sed "s/UUID/$UUID/" '${machineXML}') > $TMP_FILE + + USB_DEV=$(${pkgs.usbutils}/bin/lsusb | grep 046d:c52b | grep 'Bus 001' | cut -b 18) + LINE_NUMBER=$(cat $TMP_FILE | grep -n -A 1 0xc52b | tail -n 1 | cut -b 1,2,3) + sed -i "''${LINE_NUMBER}s/\(.\{33\}\)./\1''${USB_DEV}/" $TMP_FILE + + USB_BUS=$(${pkgs.usbutils}/bin/lsusb | grep 046d:c328 | cut -b 7) + USB_DEV=$(${pkgs.usbutils}/bin/lsusb | grep 046d:c328 | cut -b 18) + LINE_NUMBER=$(cat $TMP_FILE | grep -n -A 1 0xc328 | tail -n 1 | cut -b 1,2,3) + sed -i "''${LINE_NUMBER}s/.*/
/" $TMP_FILE + + # TODO: Set correct pci address too + + ${pkgs.libvirt}/bin/virsh define $TMP_FILE + ${pkgs.libvirt}/bin/virsh start '${vm.name}' + ''; + + preStop = + '' + ${pkgs.libvirt}/bin/virsh shutdown '${vm.name}' + let "timeout = $(date +%s) + 10" + while [ "$(${pkgs.libvirt}/bin/virsh list --name | grep --count '^${vm.name}$')" -gt 0 ]; do + if [ "$(date +%s)" -ge "$timeout" ]; then + # Meh, we warned it... + ${pkgs.libvirt}/bin/virsh destroy '${vm.name}' + else + # The machine is still running, let's give it some time to shut down + sleep 0.5 + fi + done + + ${pkgs.libvirt}/bin/virsh net-destroy 'default' || true + ''; +} diff --git a/hosts/chocolatebar/virtualisation/default.nix b/hosts/chocolatebar/virtualisation/default.nix new file mode 100644 index 0000000..a024ab6 --- /dev/null +++ b/hosts/chocolatebar/virtualisation/default.nix @@ -0,0 +1,52 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + createService = import ./create-service.nix; + isolateAnyGPU = psCfg.virtualisation.isolateGPU != null; +in +{ + options.pub-solar.virtualisation.isolateGPU = mkOption { + description = "Which GPU to isolate for virtualisation guests"; + type = with types; nullOr (enum [ "rx5700xt" "rx550x" ]); + default = null; + }; + + config = mkIf psCfg.virtualisation.enable { + boot.extraModprobeConfig = mkIf isolateAnyGPU (concatStringsSep "\n" [ + "softdep amdgpu pre: vfio vfio_pci" + (if psCfg.virtualisation.isolateGPU == "rx5700xt" + then "options vfio-pci ids=1002:731f,1002:ab38" + else "options vfio-pci ids=1002:699f,1002:aae0" + ) + ]); + + systemd.user.services = { + vm-windows = createService { + inherit config; + inherit pkgs; + inherit lib; + vm = { + name = "windows"; + disk = "/dev/disk/by-id/ata-SanDisk_SDSSDA240G_162402455603"; + id = "http://microsoft.com/win/10"; + gpu = true; + mountHome = false; + }; + }; + vm-manjaro = createService { + inherit config; + inherit pkgs; + inherit lib; + vm = { + name = "manjaro"; + disk = "/dev/disk/by-id/ata-KINGSTON_SM2280S3G2240G_50026B726B0265CE"; + id = "https://manjaro.org/download/#i3"; + gpu = true; + mountHome = true; + }; + }; + }; + }; +} diff --git a/hosts/chocolatebar/virtualisation/generate-xml.nix b/hosts/chocolatebar/virtualisation/generate-xml.nix new file mode 100644 index 0000000..69e96ab --- /dev/null +++ b/hosts/chocolatebar/virtualisation/generate-xml.nix @@ -0,0 +1,242 @@ +{ config, pkgs, lib, vm, varsFile, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + home = config.home-manager.users."${psCfg.user.name}".home; +in +'' +