{ config, lib, pkgs, self, ... }: let patchScriptBin = filename: contents: ((pkgs.writeScriptBin filename contents).overrideAttrs (old: { buildCommand = "${old.buildCommand}\n patchShebangs $out"; })); launch_robot_script = ( patchScriptBin "launch_robot" ( builtins.readFile ( pkgs.replaceVars ./files/robot/launch_robot.bash ( let robot_image_package = self.packages.${pkgs.system}.robot.vm_iso; robot_image = "${robot_image_package}/iso/${robot_image_package.isoName}"; in { "OVMFfd" = "${pkgs.OVMF.fd}"; "mountiso" = robot_image; } ) ) ) ); launch_robot_script_wrapped = (pkgs.writeScriptBin "launch_robot" '' #!/usr/bin/env bash export "PATH=${ pkgs.lib.makeBinPath ( with pkgs; [ qemu ] ) }:''${PATH}" exec ${launch_robot_script}/bin/launch_robot "''${@}" '').overrideAttrs (old: { buildCommand = '' ${old.buildCommand} patchShebangs $out ''; }); in { imports = [ ]; options.me = { robot.enable = lib.mkOption { type = lib.types.bool; default = false; example = true; description = "Whether we want to install robot."; }; }; config = lib.mkIf config.me.robot.enable { environment.systemPackages = with pkgs; [ launch_robot_script_wrapped ]; environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) { hideMounts = true; directories = [ { directory = "/robot"; user = "talexander"; group = "talexander"; mode = "0700"; } ]; }; }; }