hi everyone, how can i sync clipboard between host and qemu guest? via spice for example
I use virtio because qxl doesn’t work well for me
{
description = "";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-24.url = "github:NixOS/nixpkgs?ref=nixos-24.11";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
nixpkgs-24,
home-manager,
...
} @ inputs: let
vuser = "x";
vhost = "NixOS";
system = "x86_64-linux";
pkgs = import nixpkgs {
config.allowUnfree = true;
};
stable = import nixpkgs-24 {
inherit system;
config.allowUnfree = true;
};
in {
nixosConfigurations.${vhost} = nixpkgs.lib.nixosSystem {
modules = [
(
{
config,
pkgs,
lib,
...
}: {
imports = [];
boot = {
initrd.enable = true;
consoleLogLevel = 3;
tmp.cleanOnBoot = true;
loader = {
};
kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
"net.ipv6.conf.all.forwarding" = 1;
};
extraModprobeConfig = ''
'';
kernelModules = [
];
kernelParams = [
];
extraModulePackages = with config.boot.kernelPackages; [
];
blacklistedKernelModules = [
];
kernelPackages = pkgs.linuxPackages_latest;
};
hardware = {
};
virtualisation = {
vmVariant.virtualisation = {
cores = 3;
memorySize = 4096;
diskSize = 4096;
# useBootLoader = true;
useEFIBoot = true;
graphics = true;
# efi.OVMF =
# (pkgs.OVMF.override {
# secureBoot = true;
# })
# .fd;
resolution = {
x = 1920;
y = 1080;
};
interfaces = {
eth0 = {
vlan = 1;
};
eth1 = {
vlan = 2;
};
eth2 = {
vlan = 3;
};
};
vlans = [1 2 3];
qemu = {
virtioKeyboard = true;
guestAgent.enable = true;
diskInterface = "virtio";
options = [
"-device virtio-gpu-pci"
];
};
sharedDirectories = {
home-shared = {
source = "/home/q/vm-shared"; # Директория на хосте
target = "/home/${vuser}/shared"; # Где она появится в VM
securityModel = "mapped-xattr"; # Оптимально для большинства случаев
};
};
};
};
environment = {
localBinInPath = true; # Add "$HOME/.local/bin" to PATH.
};
nixpkgs = {
hostPlatform = "${system}";
overlays = [
inputs.nur.overlays.default
];
config = {
allowUnfree = true;
allowBroken = true;
allowInsecure = false;
packageOverrides = pkgs: {};
permittedInsecurePackages = [
];
};
};
security = {
sudo = {
enable = true;
execWheelOnly = true;
extraConfig = ''
# Defaults targetpw
'';
};
rtkit.enable = true;
polkit = {
enable = true;
debug = false;
};
};
networking = {
hostName = "${vhost}";
networkmanager.enable = true;
firewall = {
enable = true;
allowPing = true;
allowedTCPPorts = [80 443 4444 8080];
};
nat = {
enable = true;
enableIPv6 = true;
};
};
services = {
openssh = {
enable = true;
ports = [22]; # Стандартный порт SSH
openFirewall = true;
};
logind.extraConfig = ''
# don’t shutdown when power button is short-pressed
# HandlePowerKey=ignore
'';
xserver = {
enable = true;
videoDrivers = ["virtio"];
windowManager.i3.enable = true;
xkb = {
layout = "us,ru";
options = "grp:alt_shift_toggle";
};
excludePackages = with pkgs; [
];
};
displayManager = {
ly = {
enable = true;
settings = {
animation = "doom"; # doom/matrix
clear_password = true; # Очищать пароль при неудачной попытке
clock = "%c"; # Формат отображения времени
load = true; # Загружать сохраненный рабочий стол и имя пользователя
hide_key_hints = true; # Скрыть подсказки клавиш управления питанием
save = true;
save_session = false;
auth_fails = "2"; # Количество попыток до специальной анимации
box_title = "The Gates of Login"; # Надпись над рамкой
asterisk = "x"; # Символ для маскировки пароля
};
};
autoLogin = {
enable = false;
user = "${vuser}";
};
};
spice-vdagentd.enable = true; # Для улучшения интеграции с Spice
spice-autorandr.enable = true; # Автоматическое определение разрешения экрана
qemuGuest.enable = true;
libinput.enable = true;
pulseaudio.enable = false; # Disabling PulseAudio, replace with your desired audio system
pipewire = {
enable = true;
audio.enable = true;
jack.enable = true;
wireplumber.enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
};
users = {
defaultUserShell = pkgs.zsh;
users = {
${vuser} = {
description = "X";
isNormalUser = true;
password = "test";
extraGroups = [
"wheel"
"wireshark"
"networkmanager"
];
};
};
};
xdg = {
mime.enable = true;
portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
];
configPackages = with pkgs; [
];
config = {
common.default = "*";
};
};
};
programs = {
appimage = {
enable = true;
binfmt = true;
};
dconf.enable = true;
firejail.enable = true;
zsh.enable = true;
wireshark = {
enable = true;
package = pkgs.wireshark;
};
proxychains = {
enable = true;
proxyDNS = true;
quietMode = true;
proxies = {
tor = {
enable = true;
type = "socks5";
host = "127.0.0.1";
port = 9050;
};
};
};
};
zramSwap = {
enable = true;
algorithm = "lz4";
memoryPercent = 100;
priority = 999;
};
systemd = {
oomd.enable = true;
};
time.timeZone = "Europe/Kiev";
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "uk_UA.UTF-8";
LC_IDENTIFICATION = "uk_UA.UTF-8";
LC_MEASUREMENT = "uk_UA.UTF-8";
LC_MONETARY = "uk_UA.UTF-8";
LC_NAME = "uk_UA.UTF-8";
LC_NUMERIC = "uk_UA.UTF-8";
LC_PAPER = "uk_UA.UTF-8";
LC_TELEPHONE = "uk_UA.UTF-8";
LC_TIME = "uk_UA.UTF-8";
};
};
fonts = {
enableDefaultPackages = true;
enableGhostscriptFonts = true;
packages = with pkgs; [
];
};
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
auto-optimise-store = true;
trusted-users = ["root" "${vuser}"];
allowed-users = ["${vuser}"];
warn-dirty = true;
substituters = ["https://nix-gaming.cachix.org"];
trusted-public-keys = [
"nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="
];
};
};
system = {
autoUpgrade.enable = true;
autoUpgrade.allowReboot = true;
stateVersion = config.system.nixos.release;
};
}
)
home-manager.nixosModules.home-manager
{
home-manager = {
extraSpecialArgs = {
inherit
stable
;
};
useGlobalPkgs = true;
useUserPackages = true;
users.${vuser} = {
stable,
config,
pkgs,
lib,
...
}: {
imports = [
];
home = {
username = "${vuser}";
homeDirectory = "/home/${vuser}";
stateVersion = "25.05";
sessionVariables = {
GDK_BACKEND = "x11";
NIXOS_OZONE_WL = "1";
XDG_SESSION_TYPE = "x11";
};
file = {
};
packages = with pkgs;
[
nmap
metasploit
burpsuite
aircrack-ng
hashcat
thc-hydra
openvas-scanner
dsniff
tcpdump
arp-scan
netdiscover
whois
tor-browser
pciutils
usbutils
lshw
dmidecode
lsof
killall
wget
keepassxc
hexdump
devenv
gcc
go
cargo
jq
inxi
fastfetch
nitch
ncdu
tree
acpi
]
++ (with stable; [
]);
};
services = {
};
programs = {
fd = {
enable = true;
hidden = true;
};
alacritty = {
enable = true;
settings = {
env.TERM = "xterm-256color";
scrolling.multiplier = 5;
selection.save_to_clipboard = true;
font = {
size = 6.0;
};
colors = {
primary = {
background = "0x000000";
foreground = "0xFFFFFF";
};
};
};
};
chromium.enable = true;
firefox = {
enable = true;
nativeMessagingHosts = [pkgs.firefoxpwa];
policies = {
DisableTelemetry = true;
DisableFirefoxStudies = true;
DisablePocket = true;
};
profiles = {
personal = {
id = 0;
path = "personal";
extensions.packages = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin
privacy-badger
keepassxc-browser
];
settings = {
"browser.tabs.loadInBackground" = true;
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
};
search = {
force = true;
default = "DuckDuckGo";
};
bookmarks = [
{
toolbar = true;
bookmarks = [
{
name = "Documentation";
bookmarks = [
{
name = "The Linux Kernel documentation";
url = "https://www.kernel.org/doc/html/v4.14/index.html#";
}
{
name = "Scapy";
url = "https://scapy.readthedocs.io/en/latest/index.html#";
}
{
name = "Tmux";
url = "https://github.com/tmux/tmux/wiki";
}
{
name = "i3wm";
url = "https://i3wm.org/docs/userguide.html";
}
];
}
{
name = "Code Research";
bookmarks = [
{
name = "GitHub";
url = "https://github.com";
}
{
name = "GitLab";
url = "https://gitlab.com";
}
];
}
{
name = "Security Tools";
bookmarks = [
{
name = "AbuseIPDB";
url = "https://www.abuseipdb.com";
}
{
name = "VPS hosts that accept Bitcoin";
url = "cryto.net/~joepie91/bitcoinvps.html";
}
{
name = "Regex101";
url = "https://regex101.com/";
}
{
name = "Pythex";
url = "https://pythex.org";
}
{
name = "Privacy Tools";
url = "https://www.privacytools.io";
}
{
name = "YOPmail";
url = "https://yopmail.com/ru/";
}
];
}
{
name = "AI";
bookmarks = [
{
name = "Copilot";
url = "https://github.com/copilot";
}
{
name = "ChatGPT";
url = "https://chatgpt.com";
}
{
name = "DDG AI";
url = "https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat&duckai=1";
}
];
}
{
name = "Forum";
bookmarks = [
{
name = "Hacker News";
url = "https://news.ycombinator.com/news";
}
{
name = "unixforum.org";
url = "https://unixforum.org";
}
];
}
{
name = "Hacker Resources";
bookmarks = [
{
name = "Hacker Warehouse";
url = "https://hackerwarehouse.com";
}
{
name = "HackTricks";
url = "https://book.hacktricks.xyz/";
}
{
name = "ExploitDB";
url = "https://www.exploit-db.com/";
}
{
name = "OWASP TOP 10";
url = "https://owasp.org/www-project-top-ten/";
}
];
}
{
name = "NixOS";
bookmarks = [
{
name = "NixOS Search - Options";
url = "https://search.nixos.org/options";
}
{
name = "NixOS Search - Packages";
url = "https://search.nixos.org/packages";
}
{
name = "NUR Search";
url = "https://nur.nix-community.org";
}
{
name = "NixOS Manual";
url = "https://nixos.org/manual/nixos/unstable/";
}
];
}
{
name = "Pentest Tools";
bookmarks = [
{
name = "GTFOBins";
url = "https://gtfobins.github.io/";
}
{
name = "PayloadsAllTheThings";
url = "https://github.com/swisskyrepo/PayloadsAllTheThings";
}
{
name = "CyberChef";
url = "https://gchq.github.io/CyberChef/";
}
{
name = "RevShells";
url = "https://www.revshells.com/";
}
{
name = "Hacktricks";
url = "https://book.hacktricks.xyz/";
}
{
name = "LOLBAS";
url = "https://lolbas-project.github.io/";
}
];
}
];
}
];
};
};
};
zsh = {
enable = true;
autosuggestion.enable = true;
enableCompletion = true;
history.size = 10000;
syntaxHighlighting.enable = true;
};
vscode = {
enable = true;
profiles.default = {
enableUpdateCheck = false;
enableExtensionUpdateCheck = false;
extensions = with pkgs.vscode-extensions; [
bbenoist.nix
jnoortheen.nix-ide
github.copilot
github.copilot-chat
#ms-python.python
#ms-python.debugpy
];
userSettings = {
python.formatting.blackPath = "${pkgs.black}/bin/black";
python.defaultInterpreterPath = "/etc/profiles/per-user/q/bin/python3";
terminal.integrated.shell.linux = "${pkgs.zsh}/bin/zsh";
};
};
};
btop = {
enable = true;
settings = {
color_theme = "TTY";
theme_background = false;
update_ms = 100;
};
};
};
qt = {
enable = true;
platformTheme.name = "gtk3";
style = {
name = "Adwaita-dark";
package = pkgs.adwaita-qt6;
};
};
gtk = {
enable = true;
theme = {
name = "adw-gtk3-dark";
package = pkgs.adw-gtk3;
};
gtk3 = {
extraConfig.gtk-application-prefer-dark-theme = true;
};
gtk4 = {
extraConfig.gtk-application-prefer-dark-theme = true;
};
};
xsession.windowManager.i3 = {
enable = true;
config = {
modifier = "Mod4";
defaultWorkspace = "workspace number 1";
terminal = "alacritty";
window = {
border = 0;
titlebar = false;
};
modes = {
resize = {
Down = "resize grow height 10 px or 10 ppt";
Escape = "mode default";
Left = "resize shrink width 10 px or 10 ppt";
Return = "mode default";
Right = "resize grow width 10 px or 10 ppt";
Up = "resize shrink height 10 px or 10 ppt";
};
};
bars = [
{
position = "bottom";
mode = "dock";
hiddenState = "hide";
statusCommand = "${pkgs.i3status}/bin/i3status";
command = "${pkgs.i3}/bin/i3bar -t";
workspaceButtons = true;
trayOutput = "none";
fonts = {
names = ["monospace"];
size = 8.0;
};
colors = {
background = "#000000";
statusline = "#ffffff";
separator = "#666666";
focusedWorkspace = {
background = "#4c7899";
border = "#285577";
text = "#ffffff";
};
activeWorkspace = {
background = "#333333";
border = "#5f676a";
text = "#ffffff";
};
urgentWorkspace = {
background = "#2f343a";
border = "#900000";
text = "#ffffff";
};
bindingMode = {
background = "#2f343a";
border = "#900000";
text = "#ffffff";
};
inactiveWorkspace = {
background = "#000000";
border = "#000000";
text = "#646464";
};
};
extraConfig = ''
'';
}
];
keybindings = lib.mkOptionDefault {
# Управление звуком через wpctl (напрямую через Wireplumber/Pipewire)
"XF86AudioRaiseVolume" = "exec --no-startup-id wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
"XF86AudioLowerVolume" = "exec --no-startup-id wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
"XF86AudioMute" = "exec --no-startup-id wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"XF86AudioMicMute" = "exec --no-startup-id wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
};
};
};
};
};
}
];
};
};
}