restructure desktop/wm and remove nur

This commit is contained in:
2024-05-19 17:57:35 +02:00
parent a3f253bd53
commit 0249d17ac1
36 changed files with 98 additions and 186 deletions

16
modules/wm/default.nix Normal file
View File

@@ -0,0 +1,16 @@
{ pkgs, lib, config, ... }:
{
options = {
desktop = {
wm = lib.mkOption { type = types.str; default = "sway"; };
taskbar = lib.mkOption { type = types.str; default = "waybar"; };
launcher = lib.mkOption { type = types.str; default = "bemenu"; };
};
};
config = {
imports =
(import ./ + (desktop.wm)) ++
};
}

View File

@@ -0,0 +1,49 @@
#
# Gnome configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ default.nix
# └─ ./modules
# └─ ./desktop
# └─ ./gnome
# └─ default.nix *
#
{ config, lib, user, pkgs, ... }:
{
hardware.pulseaudio.enable = lib.mkForce false;
environment.systemPackages = with pkgs; [
gnome.gnome-terminal
gnomeExtensions.dash-to-dock
gnomeExtensions.appindicator
flatpak
rocmPackages.clr.icd
rocmPackages.clr
clinfo
];
services = {
xserver = {
enable = true;
desktopManager.gnome.enable = true;
displayManager = {
gdm.wayland = true;
gdm.enable = true;
gdm.autoLogin.delay = 5;
gdm.settings = {
security = {
DisallowTCP=true;
};
};
defaultSession = "steam-wayland";
autoLogin.enable = true;
autoLogin.user = "kabbone";
};
};
flatpak.enable = true;
udev.packages = with pkgs; [ gnome.gnome-settings-daemon ];
};
}

53
modules/wm/gnome/home.nix Normal file
View File

@@ -0,0 +1,53 @@
#
# Gnome NixOS & Home manager configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./steamdeck
# │ └─ home.nix
# └─ ./modules
# └─ ./desktop
# └─ ./gnome
# └─ home.nix *
#
{ config, lib, pkgs, ... }:
{
dconf.settings = {
# Enable on-screen keyboard
"org/gnome/desktop/a11y/applications" = {
screen-keyboard-enabled = true;
};
"org/gnome/shell" = {
enabled-extensions = [
"dash-to-dock@micxgx.gmail.com"
];
favorite-apps = [
"firefox.desktop"
"thunderbird.desktop"
"element-desktop.desktop"
"keepassxc"
"yubioath-flutter.desktop"
"alacritty.desktop"
];
};
# Dash to Dock settings for a better touch screen experience
"org/gnome/shell/extensions/dash-to-dock" = {
background-opacity = 0.80000000000000004;
custom-theme-shrink = true;
dash-max-icon-size = 48;
dock-fixed = true;
dock-position = "LEFT";
extend-height = true;
height-fraction = 0.60999999999999999;
hot-keys = false;
preferred-monitor = -2;
preferred-monitor-by-connector = "eDP-1";
scroll-to-focused-application = true;
show-apps-at-top = true;
show-mounts = true;
show-show-apps-button = true;
show-trash = false;
};
};
}

View File

@@ -0,0 +1,65 @@
#
# Sway configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ default.nix
# └─ ./modules
# └─ ./desktop
# └─ ./hyprland
# └─ hyprland.nix *
#
{ config, lib, user, pkgs, ... }:
{
imports = [ ../../programs/waybar.nix ];
hardware.opengl = {
enable = true;
};
environment = {
loginShellInit = ''
if [ -z $DISPLAY ] && [ $UID != 0 ] && [ "$(tty)" = "/dev/tty1" ]; then
exec Hyprland
fi
''; # Will automatically open sway when logged into tty1
variables = {
MOZ_ENABLE_WAYLAND = "1";
MOZ_WEBRENDER = "1";
MOZ_USE_XINPUT2 = "2";
MOZ_DBUS_REMOTE = "1";
#GDK_BACKEND = "wayland";
LIBVA_DRIVER_NAME = "iHD";
VDPAU_DRIVER = "iHD";
XDG_SESSION_TYPE = "wayland";
XDG_CURRENT_DESKTOP = "Unity";
#QT_QPA_PLATFORMTHEME = "wayland-egl";
GST_VAAPI_ALL_DRIVERS = "1";
GTK_THEME = "Arc";
_JAVA_AWT_WM_NONREPARENTING = "1";
#LIBCL_ALWAYS_SOFTWARE = "1"; # For applications in VM like alacritty to work
#WLR_NO_HARDWARE_CURSORS = "1"; # For cursor in VM
};
systemPackages = with pkgs; [
xdg-desktop-portal-wlr
swaylock
swayidle
slurp
grim
];
};
programs = {
hyprland.enable = true;
};
security.pam.services.swaylock = {};
xdg.portal = { # Required for flatpak with windowmanagers
#enable = true;
wlr.enable = true;
};
}

View File

@@ -0,0 +1,144 @@
#
# Hyprland NixOS & Home manager configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ home.nix
# └─ ./modules
# └─ ./desktop
# └─ ./hyprland
# └─ home.nix *
#
{ config, lib, pkgs, ... }:
{
home.file = {
".config/hypr/hyprland.conf".text = ''
monitor=eDP-1,1920x1080@60,0x0,1
# monitor=HDMI-A-2,1920x1080@60,1920x0,1
# monitor=HDMI-A-1,1280x1028@60,3840x0,1
workspace=eDP-1,1
# workspace=HDMI-A-2,2
# workspace=HDMI-A-1,3
general {
main_mod=SUPER
border_size=4
gaps_in=5
gaps_out=7
col.active_border=0x80ffffff
col.inactive_border=0x66333333
damage_tracking=full # leave it on full unless you hate your GPU and want to make it suffer
layout=dwindle
}
decoration {
rounding=5
multisample_edges=true
active_opacity=1
inactive_opacity=1
fullscreen_opacity=1
blur=false
drop_shadow=false
blur_new_optimizations=true
}
animations {
enabled=true
}
misc {
no_vfr=false
}
input {
kb_layout=us
follow_mouse=1
repeat_delay=250
numlock_by_default=0
force_no_accel=1
sensitivity=0
touchpad {
disable_while_typing=1
natural_scroll=0
}
}
dwindle {
pseudotile=0
}
bind=SUPER,Return,exec,${pkgs.alacritty}/bin/alacritty
bind=SUPER,Q,killactive,
bind=SUPER,Escape,exit,
bind=SUPER,E,exec,${pkgs.pcmanfm}/bin/pcmanfm
bind=SUPER,H,togglefloating,
bind=SUPER,Space,exec,${pkgs.rofi}/bin/rofi -show drun
bind=SUPER,P,pseudo,
bind=SUPER,F,fullscreen,
bind=SUPER,left,movefocus,l
bind=SUPER,right,movefocus,r
bind=SUPER,up,movefocus,u
bind=SUPER,down,movefocus,d
bind=ALT,1,workspace,1
bind=ALT,2,workspace,2
bind=ALT,3,workspace,3
bind=ALT,4,workspace,4
bind=ALT,5,workspace,5
bind=ALT,6,workspace,6
bind=ALT,7,workspace,7
bind=ALT,8,workspace,8
bind=ALT,9,workspace,9
bind=ALT,0,workspace,10
bind=ALT,right,workspace,+1
bind=ALT,left,workspace,-1
bind=ALTSHIFT,1,movetoworkspace,1
bind=ALTSHIFT,2,movetoworkspace,2
bind=ALTSHIFT,3,movetoworkspace,3
bind=ALTSHIFT,4,movetoworkspace,4
bind=ALTSHIFT,5,movetoworkspace,5
bind=ALTSHIFT,6,movetoworkspace,6
bind=ALTSHIFT,7,movetoworkspace,7
bind=ALTSHIFT,8,movetoworkspace,8
bind=ALTSHIFT,9,movetoworkspace,9
bind=ALTSHIFT,0,movetoworkspace,10
bind=ALTSHIFT,right,movetoworkspace,+1
bind=ALTSHIFT,left,movetoworkspace,-1
bind=CTRL,right,resizeactive,20 0
bind=CTRL,left,resizeactive,-20 0
bind=CTRL,up,resizeactive,0 -20
bind=CTRL,down,resizeactive,0 20
bind=,print,exec,${pkgs.flameshot}/bin/flameshot gui
bind=,XF86AudioLowerVolume,exec,${pkgs.pamixer}/bin/pamixer -d 10
bind=,XF86AudioRaiseVolume,exec,${pkgs.pamixer}/bin/pamixer -i 10
bind=,XF86AudioMute,exec,${pkgs.pamixer}/bin/pamixer -t
bind=,XF86AudioMicMute,exec,${pkgs.pamixer}/bin/pamixer --default-source -t
bind=,XF86MonBrightnessDown,exec,${pkgs.light}/bin/light -U 5
bind=,XF86MonBrightnessUP,exec,${pkgs.light}/bin/light -A 5
windowrule=float,^(Rofi)$
windowrule=float,title:^(Picture-in-Picture)$
windowrule=float,title:^(Volume Control)$
exec-once=${pkgs.swaybg}/bin/swaybg -m center -i $HOME/.config/wall
exec-once=${pkgs.waybar}/bin/waybar
exec-once=${pkgs.blueman}/bin/blueman-applet
exec-once=${pkgs.swayidle}/bin/swayidle -w timeout 600 "${pkgs.swaylock}/bin/swaylock -f" timeout 300 "${pkgs.hyprland}/bin/hyprctl dispatch dpms off" resume "${pkgs.hyprland}/bin/hyprctl dispatch dpms on" before-sleep "${pkgs.swaylock}/bin/swaylock -f"
exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec-once=systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
'';
};
programs.swaylock.settings = {
color = "000000";
image = "$HOME/.config/lockwall";
indicator-caps-lock = true;
show-keyboard-layout = true;
};
services.swayidle = {
enable = false;
events = [
{ event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock"; }
{ event = "lock"; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
{ event = "after-resume"; command = "${pkgs.hyprland}/bin/hyprctl dispatch dpms on"; }
];
timeouts = [
{ timeout = 300; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
{ timeout = 600; command = "${pkgs.hyprland}/bin/hyprctl dispatch dpms off"; }
];
};
}

View File

@@ -0,0 +1,48 @@
#
# Gnome configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ default.nix
# └─ ./modules
# └─ ./desktop
# └─ ./gnome
# └─ default.nix *
#
{ config, lib, user, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
flatpak
rocmPackages.clr.icd
rocmPackages.clr
clinfo
libsForQt5.discover
maliit-keyboard
];
services = {
packagekit.enable = true;
xserver = {
enable = true;
desktopManager.plasma5.enable = true;
# displayManager = {
# gdm.wayland = true;
# gdm.enable = true;
# gdm.autoLogin.delay = 5;
# gdm.settings = {
# security = {
# DisallowTCP=true;
# };
# };
# defaultSession = "steam-wayland";
# autoLogin.enable = true;
# autoLogin.user = "kabbone";
# };
};
flatpak.enable = true;
udev.packages = with pkgs; [ gnome.gnome-settings-daemon ];
};
}

16
modules/wm/kde/home.nix Normal file
View File

@@ -0,0 +1,16 @@
#
# Gnome NixOS & Home manager configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./steamdeck
# │ └─ home.nix
# └─ ./modules
# └─ ./desktop
# └─ ./gnome
# └─ home.nix *
#
{ config, lib, pkgs, ... }:
{
}

BIN
modules/wm/scripts/2in1screen Executable file

Binary file not shown.

View File

@@ -0,0 +1,43 @@
#
# Gnome configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ default.nix
# └─ ./modules
# └─ ./desktop
# └─ ./gnome
# └─ default.nix *
#
{ config, lib, user, pkgs, jovian-nixos, ... }:
{
imports = [
(jovian-nixos + "/modules")
];
jovian = {
steam = {
enable = true;
user = "kabbone";
autoStart = true;
desktopSession = "plasmawayland";
};
devices.steamdeck = {
enable = true;
};
decky-loader.enable = true;
};
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
environment.systemPackages = with pkgs; [
steamdeck-firmware
];
}

26
modules/wm/steam/home.nix Normal file
View File

@@ -0,0 +1,26 @@
#
# Gnome NixOS & Home manager configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./steamdeck
# │ └─ home.nix
# └─ ./modules
# └─ ./desktop
# └─ ./steam
# └─ home.nix *
#
{ config, lib, pkgs, ... }:
{
home = {
packages = with pkgs; [
steam
jq
appimage-run
gnome.zenity
unzip
fuse
];
};
}

View File

@@ -0,0 +1,77 @@
#
# Sway configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ default.nix
# └─ ./modules
# └─ ./desktop
# └─ ./hyprland
# └─ hyprland.nix *
#
{ config, lib, user, pkgs, desktop, ... }:
{
imports = [ ../waybar.nix ];
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
environment = {
loginShellInit = ''
if [ -z $DISPLAY ] && [ $UID != 0 ] && [ "$(tty)" = "/dev/tty1" ]; then
exec sway
fi
''; # Will automatically open sway when logged into tty1
systemPackages = with pkgs; [
xdg-desktop-portal-wlr
sway
swaylock
swayidle
slurp
grim
bemenu
lxqt.lxqt-openssh-askpass
rocmPackages.clr.icd
rocmPackages.clr
clinfo
waybar
];
};
programs = {
sway.enable = true;
sway.extraSessionCommands = ''
export MOZ_ENABLE_WAYLAND="1";
export MOZ_WEBRENDER="1";
export MOZ_USE_XINPUT2="2";
export MOZ_DBUS_REMOTE="1";
#export GDK_BACKEND="wayland";
export LIBVA_DRIVER_NAME="iHD";
export VDPAU_DRIVER="iHD";
export XDG_SESSION_TYPE="wayland";
#export XDG_CURRENT_DESKTOP="Unity";
#export QT_QPA_PLATFORMTHEME="wayland-egl";
export GST_VAAPI_ALL_DRIVERS="1";
export GTK_THEME="Arc";
export _JAVA_AWT_WM_NONREPARENTING="1";
#export LIBCL_ALWAYS_SOFTWARE="1"; # For applications in VM like alacritty to work
#export WLR_NO_HARDWARE_CURSORS="1"; # For cursor in VM
'';
ssh.enableAskPassword = true;
ssh.askPassword = "${pkgs.lxqt.lxqt-openssh-askpass}/bin/lxqt-openssh-askpass";
};
security.pam.services.swaylock = {};
xdg.portal = { # Required for flatpak with windowmanagers
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
};
}

287
modules/wm/sway/home.nix Normal file
View File

@@ -0,0 +1,287 @@
#
# Sway NixOS & Home manager configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ home.nix
# └─ ./modules
# └─ ./desktop
# └─ ./sway
# └─ home.nix *
#
{ config, lib, pkgs, ... }:
{
home.file.".config/sway/scripts/2in1screen".source = ../scripts/2in1screen;
wayland.windowManager.sway = {
enable = true;
config = rec {
menu = "${pkgs.bemenu}/bin/bemenu-run -m -1 --hf '#ffff00' --tf '#888888' --nf '#00ff40' --hb '#424242' | xargs ${pkgs.sway}/bin/swaymsg exec --";
left = "m";
down = "n";
up = "e";
right = "i";
modifier = "Mod4";
floating.modifier = "Mod4";
floating.titlebar = true;
input = {
"type:keyboard" = {
xkb_layout = "us";
xkb_variant = "altgr-intl";
};
"type:touchpad" = {
tap = "enabled";
natural_scroll = "disabled";
drag = "enabled";
dwt = "enabled";
middle_emulation = "enabled";
scroll_method = "two_finger";
tap_button_map = "lmr";
};
};
output = {
"*" = {
bg = "$HOME/.config/wall fill";
};
#"HDMI-A-1" = {
# mode = "2560x1440";
# pos = "0,0";
# #scale = "1.1";
#};
"DP-2" = {
mode = "2560x1440";
pos = "0,0";
};
"DP-3" = {
mode = "1920x1200";
pos = "2560,120";
};
#"eDP-1" = {
# mode = "1920x1080";
# #pos = "4480,0";
# pos = "2560,0";
# subpixel = "none";
# scale = "1.3";
#};
};
terminal = "${pkgs.alacritty}/bin/alacritty";
fonts = {
names = [ "Cascadia Code" ];
size = 10.0;
};
colors.focused = {
background = "#212121";
border = "#999999";
childBorder = "#999999";
indicator = "#999999";
text = "#FFFFFF";
};
startup = [
#{ command = "$HOME/.config/sway/scripts/2in1screen"; }
{ command = "xrdb -load ~/.Xresources"; }
{ command = "gsettings set org.gnome.desktop.interface gtk-theme Arc"; }
{ command = "gsettings set org.gnome.desktop.interface icon-theme ePapirus"; }
{ command = "gsettings set org.gnome.desktop.interface cursor-theme Adwaita"; }
#{ command = "exec ${pkgs.networkmanagerapplet}/bin/nm-applet --indicator"; }
{ command = "${pkgs.thunderbird}/bin/thunderbird"; }
{ command = "${pkgs.firefox}/bin/firefox"; }
{ command = "${pkgs.element-desktop}/bin/element-desktop"; }
];
workspaceAutoBackAndForth = true;
gaps.inner = 8;
gaps.outer = 4;
gaps.smartGaps = true;
gaps.smartBorders = "on";
assigns = {
"workspace number 1" = [{ app_id = "thunderbird"; }];
"workspace number 2" = [{ app_id = "firefox"; }];
"workspace number 3" = [{ class = "Element"; }];
};
window.commands = [
{ command = "floating enable"; criteria = { app_id = ".yubioath-flutter-wrapped"; }; }
{ command = "floating enable"; criteria = { app_id = "pavucontrol"; }; }
{ command = "floating enable"; criteria = { app_id = "galculator"; }; }
{ command = "floating enable"; criteria = { app_id = "com.nitrokey."; }; }
{ command = "floating enable"; criteria = { app_id = "org.keepassxc.KeePassXC."; }; }
{ command = "floating enable"; criteria = { app_id = "virt-manager"; }; }
{ command = "floating enable"; criteria = { class = "lxqt-openssh-askpass"; }; }
{ command = "floating enable"; criteria = { class = "pop-up"; }; }
];
bars = [
{ command = "${pkgs.waybar}/bin/waybar"; }
];
defaultWorkspace = "workspace number 2";
keybindings =
let
mod = config.wayland.windowManager.sway.config.modifier;
alt = "Mod1";
left = config.wayland.windowManager.sway.config.left;
down = config.wayland.windowManager.sway.config.down;
up = config.wayland.windowManager.sway.config.up;
right = config.wayland.windowManager.sway.config.right;
in
{
"${mod}+Escape" = "exec swaymsg exit"; # Exit Sway
"${mod}+Return" = "exec ${terminal}"; # Open terminal
"${mod}+d" = "exec ${menu}"; # Open menu
"${mod}+l" = "exec ${pkgs.swaylock}/bin/swaylock"; # Lock Screen
"${mod}+r" = "reload"; # Reload environment
"${mod}+q" = "kill"; # Kill container
"${mod}+Shift+f" = "exec ${pkgs.pcmanfm}/bin/pcmanfm"; # File Manager
"${alt}+${left}" = "workspace prev_on_output"; # Navigate to previous or next workspace on output if it exists
"${alt}+${right}" = "workspace next_on_output";
"${alt}+Shift+${left}" = "move container to workspace prev, workspace prev"; # Move container to next available workspace and focus
"${alt}+Shift+${right}" = "move container to workspace next, workspace next";
"XF86TouchpadToggle" = "input type:touchpad events toggle enabled disabled";
"XF86AudioRaiseVolume" = "exec pulsemixer --change-volume +5 && ${config.cmds.notifications.volume}";
"XF86AudioLowerVolume" = "exec pulsemixer --change-volume -5 && ${config.cmds.notifications.volume}";
"XF86AudioMute" = "exec pulsemixer --toggle-mute && ${config.cmds.notifications.volume}";
#"XF86AudioRaiseVolume" = "exec pulsemixer --change-volume +5";
#"XF86AudioLowerVolume" = "exec pulsemixer --change-volume -5";
#"XF86AudioMute" = "exec pulsemixer --toggle-mute";
"XF86AudioMicMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86MonBrightnessDown" = "exec light -s sysfs/backlight/intel_backlight -U 5% && ${config.cmds.notifications.brightness}";
"XF86MonBrightnessUp" = "exec light -s sysfs/backlight/intel_backlight -A 5% && ${config.cmds.notifications.brightness}";
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
"XF86AudioStop" = "exec playerctl stop";
#XF86AudioMute = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
#XF86AudioRaiseVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
#XF86AudioLowerVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
#XF86AudioPlay = "exec ~/.config/waybar/scripts/toggle-play";
#XF86AudioNext = "exec playerctl --player=spotify next";
#XF86AudioPrev = "exec playerctl --player=spotify previous";
"${mod}+${left}" = "focus left";
"${mod}+${down}" = "focus down";
"${mod}+${up}" = "focus up";
"${mod}+${right}" = "focus right";
"${mod}+Shift+${left}" = "move left";
"${mod}+Shift+${down}" = "move down";
"${mod}+Shift+${up}" = "move up";
"${mod}+Shift+${right}" = "move right";
"${mod}+${alt}+${left}" = "resize grow width 10px";
"${mod}+${alt}+${down}" = "resize shrink height 10px";
"${mod}+${alt}+${up}" = "resize grow height 10px";
"${mod}+${alt}+${right}" = "resize shrink width 10px";
"${mod}+1" = "workspace number 1";
"${mod}+2" = "workspace number 2";
"${mod}+3" = "workspace number 3";
"${mod}+4" = "workspace number 4";
"${mod}+5" = "workspace number 5";
"${mod}+6" = "workspace number 6";
"${mod}+7" = "workspace number 7";
"${mod}+8" = "workspace number 8";
"${mod}+9" = "workspace number 9";
"${mod}+0" = "workspace number 10";
"${mod}+Shift+1" = "move container to workspace number 1";
"${mod}+Shift+2" = "move container to workspace number 2";
"${mod}+Shift+3" = "move container to workspace number 3";
"${mod}+Shift+4" = "move container to workspace number 4";
"${mod}+Shift+5" = "move container to workspace number 5";
"${mod}+Shift+6" = "move container to workspace number 6";
"${mod}+Shift+7" = "move container to workspace number 7";
"${mod}+Shift+8" = "move container to workspace number 8";
"${mod}+Shift+9" = "move container to workspace number 9";
"${mod}+Shift+0" = "move container to workspace number 10";
"${mod}+Tab" = "workspace next";
"${mod}+Alt+Tab" = "workspace prev";
"${mod}+k" = "splith";
"${mod}+v" = "splitv";
"${mod}+b" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+p" = "layout toggle split";
"${mod}+f" = "fullscreen";
"${mod}+Shift+space" = "floating toggle";
"${mod}+h" = "focus mode_toggle";
"${mod}+a" = "focus parent";
"${mod}+Shift+minus" = "move scratchpad";
"${mod}+minus" = "scratchpad show";
};
};
systemd.enable = true;
wrapperFeatures.gtk = true;
extraSessionCommands = ''
export MOZ_ENABLE_WAYLAND="1";
export MOZ_WEBRENDER="1";
export MOZ_USE_XINPUT2="2";
export MOZ_DBUS_REMOTE="1";
#export GDK_BACKEND="wayland";
export LIBVA_DRIVER_NAME="iHD";
export VDPAU_DRIVER="iHD";
export XDG_SESSION_TYPE="wayland";
export XDG_CURRENT_DESKTOP="sway";
export QT_QPA_PLATFORMTHEME="wayland-egl";
export GST_VAAPI_ALL_DRIVERS="1";
export GTK_THEME="Arc";
export _JAVA_AWT_WM_NONREPARENTING="1";
#export LIBCL_ALWAYS_SOFTWARE="1"; # For applications in VM like alacritty to work
#export WLR_NO_HARDWARE_CURSORS="1"; # For cursor in VM
'';
extraConfig = ''
set $output-primary DP-2
set $output-secondary DP-3
workspace 1 output $output-secondary
workspace 2 output $output-primary
workspace 3 output $output-secondary
'';
};
programs.swaylock = {
enable = true;
settings = {
color = "000000";
image = "$HOME/.config/lockwall";
indicator-caps-lock = true;
show-keyboard-layout = true;
};
};
services.swayidle = {
enable = true;
events = [
{ event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock"; }
{ event = "lock"; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
{ event = "after-resume"; command = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; }
{ event = "unlock"; command = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; }
];
timeouts = [
{ timeout = 300; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
{ timeout = 600; command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'"; resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; }
];
};
}

View File

@@ -0,0 +1,17 @@
#
# Specific system configuration settings for desktop
#
# flake.nix
# ├─ ./hosts
# │ └─ ./desktop
# │ └─ default.nix
# └─ ./modules
# └─ ./desktop
# └─ ./virtualisation
# └─ default.nix *
#
[
./docker.nix
./qemu.nix
]

View File

@@ -0,0 +1,52 @@
#
# Docker
#
{ config, pkgs, user, ... }:
{
virtualisation = {
podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
};
};
users.groups.docker.members = [ "${user}" ];
#environment = {
# interactiveShellInit = ''
# alias rtmp='docker start nginx-rtmp'
# ''; # Alias to easily start container
#};
# environment.systemPackages = with pkgs; [
# docker-compose
# ];
}
# USAGE:
# list images (that can be run as container): docker images
# list containers (that are active): docker container ls
# run images as container: docker run <repository name>
# run with port binding (ports can be accessed over internet): docker run -p <host port>:<docker-port> <repository name>
#
# 1: Portainer
# Create volume: docker volume create portainer_data
# Create and start: docker run -d -p 8000:8000 -p 9443:9443 --name portainer \
# --restart=always \
# -v /var/run/docker.sock:/var/run/docker.sock \
# -v portainer_data:/data \
# portainer/portainer-ce:latest
#
# 2: RTMP Server for OBS Studio
# Create: docker run -d -p 1935:1935 --name nginx-rtmp --restart=always tiangolo/nginx-rtmp
#
# 3: Homer
# Create: docker run -d \
# -p 8080:8080 \
# -v </your/local/assets/>:/www/assets \
# --restart=always \
# b4bz/homer:latest
#

View File

@@ -0,0 +1,12 @@
#
# KVM module options amd
#
{ config, pkgs, user, ... }:
{ # Add libvirtd and kvm to userGroups
boot.extraModprobeConfig = ''
options kvm_amd nested=0 avic=1 npt=1
''; # Needed to run OSX-KVM
}

View File

@@ -0,0 +1,13 @@
#
# KVM module options intel
#
{ config, pkgs, user, ... }:
{ # Add libvirtd and kvm to userGroups
boot.extraModprobeConfig = ''
options kvm_intel nested=1
options kvm_intel emulate_invalid_guest_state=0
options kvm ignore_nsrs=1
''; # Needed to run OSX-KVM
}

View File

@@ -0,0 +1,227 @@
#
# Qemu/KVM with virt-manager
#
{ config, pkgs, user, ... }:
{ # Add libvirtd and kvm to userGroups
users.groups.libvirtd.members = [ "root" "${user}" ];
virtualisation = {
libvirtd = {
enable = true; # Virtual drivers
onShutdown = "shutdown";
#qemuPackage = pkgs.qemu_kvm; # Default
qemu = {
runAsRoot = false;
ovmf.enable = true;
# ovmf.packages = [ pkgs.OVMFFull ];
# verbatimConfig = ''
# nvram = [ "${pkgs.OVMF}/FV/OVMF_CODE.fd:${pkgs.OVMF}/FV/OVMF_VARS.fd" ]
# '';
};
};
spiceUSBRedirection.enable = true; # USB passthrough
};
programs.dconf.enable = true;
environment = {
systemPackages = with pkgs; [
virt-manager
virt-viewer
qemu
OVMF
gvfs # Used for shared folders between linux and windows
];
};
services = { # Enable file sharing between OS
gvfs.enable = true;
};
#boot ={
# kernelParams = [ "intel_iommu=on" "vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd" ]; # or amd_iommu (cpu)
# kernelModules = [ "vendor-reset" "vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd"];
# extraModulePackages = [ config.boot.kernelPackages.vendor-reset ]; # Presumably fix for GPU Reset Bug
# extraModprobeConfig = "options vfio-pci ids=1002:67DF,1002:AAF0"; # grep PCI_ID /sys/bus/pci/devices/*/uevent
# kernelPatches = [
# {
# name = "vendor-reset-reqs-and-other-stuff";
# patch = null;
# extraConfig = ''
# FTRACE y
# KPROBES y
# FUNCTION_TRACER y
# HWLAT_TRACER y
# TIMERLAT_TRACER y
# IRQSOFF_TRACER y
# OSNOISE_TRACER y
# PCI_QUIRKS y
# KALLSYMS y
# KALLSYMS_ALL y
# '';
# }
# ];
#};
}
#SHARED FOLDER
#FOR WINDOWS
# 3 options:
#
# 1. Make use of host samba server
# 1.0 Samba is installed by default. The network-shared folder is at /home/<user>/share.
# 1.1 On host, set a password for the autentication of the samba server
# 1.2 $ smbpasswd -a <user>
# 1.3 Give password twice
# 1.4 On windows, open file explorer, right click "This PC", Map network drive...
# 1.5 fill in address: \\<ip-address>\share
# 1.6 Log in with details entered beforehand
#
# 2. Since this setup make use of iommu, you can pass through external usb hard drives or a specific PCI storage devices
# 2.1 Open details of virtual desktop in virt-manager
# 2.2 Add hardware
# 2.3 USB Host Device
# 2.4 Select device and launch virtual desktop
#
# 3. Set up shared folders in windows guest that can be accessed by host
# 3.0. Enable above service gvfs (this is used in the file manager to actually connect to the windows directory)
# 3.1. Log in to Windows
# 3.2. Go to "Network and Sharing Center"
# 3.3. Click "Change advanced sharing settings" and enable all settings for Private, Guest or Public and All Networks
# 3.3.1. Under "All Networks" you can disable "Password protected sharing" but it seems for optimal use, it's better to still give the password in the file manager
# 3.4. (possibly optional), select a folder and click "Properties", "Sharing", "Advanced Sharing"
# 3.4.1. Enable "Share this file"
# 3.4.2. Under "Permissions", allow full control. Apply
# 3.5. Click "Share" and use de drop down to add "Everyone" and change "Permission Level" to "Read/Write". Share, Done
# 3.6. Search for services and open menu
# 3.6.1. Search for below serices. Right click and select "Properties". "Startup type" = Automatic
# 3.6.1.1. SSDP Discovery
# 3.6.1.2. uPnPDevice Host
# 3.6.1.3. Functions Discovery Provider Host
# 3.6.1.4. Functions Discovery Resource Publication
# 3.7. Find IP of virtual device and make sure you can ping it.
# 3.8. In file manager add connection
# 3.8.1. For example in PCManFM
# 3.8.2. Search for smb://*ip*/
# 3.8.3. You can even specify specific folder smb://*ip*/users/Matthias/Desktop/share
# 3.8.4. If prompted to log in, do it, otherwise it might close on its own.
# 3.9. If there are any issues, maybe disable firewall on guest
# 3.10. Recommended to bookmark location for later
# Note:
# There is no passthrough, its recommended to install the windows kvm guest drivers.
# Can be found on github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md
# Add this as CD storage in virt manager
# It can than be accest in the windows and the guest driver exe's can be run.
# Also, change video in virt-manager to virtio. This will fix the resolution
#FOR LINUX
# 2 options
#
# 1. Make use of host samba server
# 1.0 Samba is installed by default. The network-shared folder is at /home/<user>/share.
# 1.1 On host, set a password for the autentication of the samba server
# 1.2 $ smbpasswd -a <user>
# 1.3 Give password twice
# 1.4 On virtual machine open file manager
# 1.5 Search for smb://<ip-address>/share
# 1.6 Log in with details entered beforehand
#
# 2. Passing through a filesystem
# 2.1 Open details of virtual desktop on virt-manager
# 2.2 Add hardware
# 2.3 Select Filesystem: Type = mount / Mode = mapped / Source path = /home/<user>/share / Target path = /sharepoint
# 2.4 Boot into virtual machine
# 2.5 Create a directory to mount /sharepoint
# 2.6 $ sudo mount -t 9p -o trans=virtio /sharepoint /<mountpoint>
#SINGLE GPU PASSTHROUGH
# General Guide: gitlab.com/risingprismtv/single-gpu-passthrough/-/wikis/home
# 1. Download ISO
# 2. Download latest Video BIOS from techpowerup.com/vgabios (Sapphire RX580 8Gb)
# 2.1. $ Sudo mkdir /var/lib/libvirt/vbios/
# 2.2. $ Sudo mv ~/Downloads/*.rom /var/lib/libvirt/vbios/GPU.rom
# 2.3. $ Cd /var/lib/libvirt/vbios/
# 2.4. $ Sudo chmod -R 660 GPU.rom
# 3. Launch virt-manager
# 4. File - Add Connection
# 5. Create Virtual Machine
# 5.1 Select ISO and mark it as win10
# 5.2 Give temporary RAM
# 5.3 Customize configuration before install
# 5.4 Overview - Firmware - UEFI x86_64: /usr/*/OVMF_CODE.fd
# 5.5 Allow XML Editing via Edit - Preferences
# 5.6 Edit XML - Remove rtc & pit line. Change hpet to "yes"
# 6. Start Installation (let it run without interference and do steps below)
# 6.1 Press Esc, type exit, select boot-manager DVD ROM
# 6.2 Do installation, select Pro version.
# 6.3 Install hooks (Step 7 in guide)
# 7. Close VM
# 8. Edit VM
# 8.1 Remove everything spice (Display, Video QXL, Serial, Channel Spice)
# 8.2 Remove CD Rom
# 8.3 Add PCI hardware (GPU: 01:00:0 & 01:00:1 (most likely))
# 8.3 Add Mouse, Keyboard (PCI USB Controller in PCI Host Device or USB Host Device)
# 9. Select GPU and open XML
# 9.1 Add line "<rom file='/var/lib/libvirt/vbios/GPU.rom'/>" under "</source>"
# 9.2 Do for both 01:00:0 and 01:00:1
# 10. Edit CPU
# 10.1 Disable "Copy host CPU configuration" and select "host-passthrough"
# 10.2 Edit topology: Sockets=1 Cores=Total/2 Threads=2
# 10.3 Edit XML cpu under topology
# 10.3.1 Add "<feature policy='require' name='topoext'/>" for AMDCPU
# 10.3.2 Add "<feature policy='disable' name='smep'/>" for Intel CPU
# 11 Change memory to prefered (12GB for 16GB Total)
# 12 Start VM
# 13 Install correct video drivers
#MACOS ON VIRT-MANAGER
# General Guide: nixos.wiki/wiki/OSX-KVM
# Repository: github.com/kholia/OSX-KVM
# IMPORTANT: if you wish to start the virtual machine with virt-manager gui, clone to /home/<user>/.
# 1. git clone https://github.com/kholia/OSX-KVM
# 2. create a shell.nix (maybe best to store inside cloned directory)
# 3. shell.nix content:
# with import <nixpkgs> {};
# mkShell {
# buildInputs = [
# qemu
# python3
# iproute2
# ];
# }
# 4. In nixos configuration add:
# virtualisation.libvirtd.enable = true;
# users.extraUsers.<user>.extraGroups = [ "libvirtd" ];
# boot.extraModprobeConfig = ''
# options kvm_intel nested=1
# options kvm_intel emulate_invalid_guest_state=0
# options kvm ignore_msrs=1
# '';
# 5. Run the shell: $ nix-shell
# 6. As mentioned in the README, run ./fetch-macOS.py
# 6.1 Can be a specific version
# 7. Create base image for the macOs installer
# 8. $ qemu-img convert BaseSystem.dmg -O raw BaseSystem.img
# 9. Create disk for macOS
# 9.1 $ qemu-img create -f qcow2 mac_hdd_ng.img 128G
# 10. Set up networking. If something like virbr0 does not get detected start virt-manager. Commands:
# $ sudo ip tuntap add dev tap0 mode tap
# $ sudo ip link set tap0 up promisc on
# $ sudo ip link set dev virbr0 up
# $ sudo ip link set dev tap0 master virbr0
# 11. Boot the system
# 11.1 $ ./OpenCore-Boot.sh
# 12. Choose the first option to start the MacOS installer: macOS Base Systen
# 12.1 Use Disk Utility to esase the correct drive.
# 13. Go back and select the option to reinstall macOS
# 13.1 After the initial installation, a reboot will happen. Do nothing and wait or select the second option 'MacOs install'.
# 13.2 This will finalize the installaton but it will probably reboot multiple times. The second option will now have changed to the name of your drive. Use this as the boot option
# 14. To add the installation to virt-manager:
# 14.1 $ sed "s/CHANGEME/$USER/g" macOS-libvirt-Catalina.xml > macOS.xml
# 14.2 Inside macOS.xml change the emulator from /usr/bin/qemu-system-x86_64 to /run/libvirt/nix-emulators/qemu-system-x86_64
# 14.3 $ virt-xml-validate macOS.xml
# 15. $ virsh --connect qemu:///system define macOS.xml
# 16.(optional if permission is needed to the libvirt-qemu user)
# 16.1 $ sudo setfacl -m u:libvirt-qemu:rx /home/$USER
# 16.2 $ sudo setfacl -R -m u:libvirt-qemu:rx /home/$USER/OSX-KVM

275
modules/wm/waybar.nix Normal file
View File

@@ -0,0 +1,275 @@
#
# Bar
#
{ config, lib, user, pkgs, ...}:
{
environment.systemPackages = with pkgs; [
waybar
];
home-manager.users.${user} = { # Home-manager waybar config
programs.waybar = {
enable = true;
#systemd = {
# enable = true;
# target = "sway-session.target"; # Needed for waybar to start automatically
#};
style = ''
* {
border: none;
border-radius: 0;
font-family: FiraCode Nerd Font Mono;
font-size: 11px;
min-height: 0;
}
window#waybar {
background: rgba(43, 48, 59, 0.3);
border-bottom: 3px solid transparent;
color: white;
}
#workspaces button {
padding: 0 5px;
margin: 0 3px;
color: white;
border-bottom: 3px solid transparent;
}
#workspaces button.focused {
background: rgba(100, 114, 125, 0.2);
border-bottom: 2px solid gray;
}
#mode {
background: transparent;
border-bottom: 2px solid gray;
}
#clock, #battery, #cpu, #memory, #network, #pulseaudio, #temperature, #backlight, #idle_inhibitor, #custom-spotify {
color: white;
padding: 0 6px;
margin: 0 5px;
}
#custom-vkeyboard, #custom-appkill {
padding: 0px 50px;
margin: 0px 0px;
font-size: 20px;
}
#clock {
background-color: transparent;
color: white;
}
#battery {
color: white;
}
#battery.charging {
color: white;
}
@keyframes blink {
to {
background-color: rgba(1, 1, 1, 0);
}
}
#battery.warning:not(.charging) {
background: #f53c3c;
color: white;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#cpu {
background: transparent;
border-bottom: 2px solid yellow;
color: white;
}
#memory {
background: transparent;
border-bottom: 2px solid green;
color: white;
}
#network {
background: transparent;
color: white
}
#network.disconnected {
background: transparent;
color: crimson;
}
#pulseaudio {
background: transparent;
color: white;
}
#pulseaudio.muted {
border-bottom: 2px solid red;
}
#tray {
background-color: transparent;
}
#custom-sl.good {
border-bottom: 3px solid green;
}
#custom-sl.other {
border-bottom: 3px solid #F4AF39;
}
#custom-appkill {
color: red;
background-color: black;
}
'';
settings = [{
layer = "bottom";
position = "top";
height = 22;
tray = { spacing = 10; };
modules-center = [ "clock" "custom/appkill" ];
modules-left = [ "sway/mode" "sway/workspaces" "sway/window" ];
#modules-left = [ "wlr/workspaces" ];
modules-right = [ "idle_inhibitor" "pulseaudio" "network" "cpu" "memory" "backlight" "temperature" "battery" "tray" ];
#modules-right = [ "cpu" "memory" "pulseaudio" "clock" "tray" ];
"sway/workspaces" = {
format = "<span font='14'>{icon}</span>";
format-icons = {
"1"="";
"2"="";
"3"="";
"4"="";
"5"="";
};
all-outputs = false;
persistent_workspaces = {
"1" = [];
"2" = [];
"3" = [];
"4" = [];
"5" = [];
};
};
"wlr/workspaces" = {
format = "{icon}";
format-icons = {
"1"="";
"2"="";
"3"="";
"4"="";
"5"="";
};
all-outputs = true;
active-only = false;
on-click = "activate";
};
clock = {
format = "{:%b %d %H:%M}";
tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
format-alt = "{:%A, %B %d, %Y}";
};
idle_inhibitor = {
format = "{icon}";
format-icons = {
activated = "";
deactivated = "";
};
};
cpu = {
format = "{usage}% ";
tooltip = false;
interval = 2;
};
disk = {
format = "{percentage_used}% ";
path = "/";
interval = 30;
};
memory = {
format = "{}% ";
interval = 5;
};
temperature = {
states = {
"good" = 50;
"warning" = 70;
"critical" = 80;
};
"thermal-zone" = 2;
"hwmon-path" = "/sys/class/hwmon/hwmon3/temp1_input";
"format" = "{temperatureC}°C {icon}";
"format-icons" = ["" "" "" "" ""];
};
backlight = {
"format" = "{percent}% {icon}";
"format-icons" = ["" ""];
"on-scroll-up" = "light -A +5%";
"on-scroll-down" = "light -U -5%";
};
battery = {
interval = 60;
states = {
good = 95;
warning = 20;
critical = 5;
};
format = "{capacity}% {icon}";
format-charging = "{capacity}% ";
format-plugged = "{capacity}% ";
format-alt = "{time} {icon}";
format-icons = ["" "" "" "" ""];
};
network = {
format-wifi = " {ipaddr}";
format-ethernet = "{ifname}: {ipaddr}/{cidr} ";
format-linked = "{ifname} (No IP) ";
format-disconnected = "Not connected ";
format-alt = "{ifname}: {ipaddr}/{cidr}";
tooltip-format = "{essid} {signalStrength}%";
on-click-right = "${pkgs.alacritty}/bin/alacritty -e nmtui";
};
pulseaudio = {
scroll-step = 1;
format = "{volume}% {icon} {format_source}";
format-bluetooth = "{volume}% {icon} {format_source}";
format-bluetooth-muted = "{volume}% {icon} {format_source}";
format-muted = " {format_source}";
format-source = "{volume}% ";
#format-source = "<span font='14'></span>";
format-source-muted = "";
format-icons = {
default = [ "" "" "" ];
headphones = "";
handsfree = "";
headset = "";
};
tooltip-format = "{desc}, {volume}%";
on-click-right = "${pkgs.pamixer}/bin/pamixer --default-source -t";
on-click = "${pkgs.pavucontrol}/bin/pavucontrol";
};
"custom/appkill" = {
format = " ";
icon-size = 20;
#on-click = "${pkgs.hyprland}/bin/hyprctl dispatch killactive .";
on-click = "${pkgs.sway}/bin/swaymsg kill";
tooltip = false;
};
}];
};
};
}