From 35fa5b6bdae02a316c93d2ddd442e092536d91b5 Mon Sep 17 00:00:00 2001 From: tristan Date: Sat, 6 Jan 2024 22:35:25 +0000 Subject: [PATCH] setup sway vm --- .gitignore | 2 +- flake.nix | 33 +++++++++---- hardware/vm.nix | 22 +++++++++ home/default.nix | 5 +- home/modules/menu.nix | 6 +++ home/programs/hyprland.nix | 95 +++++++++++++++++++------------------ home/programs/scripts.nix | 15 +++--- home/programs/sway.nix | 38 --------------- nixos/programs/hyprland.nix | 4 +- nixos/programs/sway.nix | 9 ++-- 10 files changed, 118 insertions(+), 111 deletions(-) diff --git a/.gitignore b/.gitignore index c7e1460..87a3018 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ result -nixos.qcow2 +*.qcow2 diff --git a/flake.nix b/flake.nix index 356b9fb..c283e69 100644 --- a/flake.nix +++ b/flake.nix @@ -36,17 +36,32 @@ ./home/programs/personal.nix ]; - vm = mkConf [ + FCS-Tristan-Nixbook = + mkConf [ + ./hardware/fcs-tristan-nixbook.nix + ./nixos/programs/hyprland.nix + ./nixos/modules/work.nix + ] [ + ./home/programs/work.nix + ]; + + vm-sway = + builtins.trace '' + I haven't finished configuring sway yet. + use alt+enter to start a terminal. + use alt+d to launch applications + + start the vm with '-vga qxl' + '' + mkConf + [ + ./hardware/vm.nix + ./nixos/programs/sway.nix + ] []; + + vm-tty = mkConf [ ./hardware/vm.nix ] []; - - FCS-Tristan-Nixbook = mkConf [ - ./hardware/fcs-tristan-nixbook.nix - ./nixos/programs/hyprland.nix - ./nixos/modules/work.nix - ] [ - ./home/programs/work.nix - ]; }; }; } diff --git a/hardware/vm.nix b/hardware/vm.nix index ddcf7e4..3db51c7 100644 --- a/hardware/vm.nix +++ b/hardware/vm.nix @@ -1,11 +1,33 @@ {config, ...}: let user = config.user; in { + hardware.opengl.enable = true; + boot.kernelModules = ["qxl" "bochs_drm"]; + system.stateVersion = "24.05"; home-manager.users.${user}.imports = [ { home.stateVersion = "24.05"; + + # so it won't conflict with the host + windowManager.modifierKey = "ALT"; } ]; + + displays.displays = { + Virtual-1 = { + enable = true; + name = "Virtual-1"; + workspaces = { + start = 1; + end = 10; + }; + resolution = { + x = 1920; + y = 1080; + freq = 60; + }; + }; + }; } diff --git a/home/default.nix b/home/default.nix index 9200c65..ef57ba0 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,6 +1,7 @@ { config, pkgs, + lib, ... }: # https://nix-community.github.io/home-manager/options.xhtml @@ -14,13 +15,15 @@ ./modules/menu.nix ./modules/scripts.nix - ./programs/hyprland.nix ./programs/graphical.nix ./programs/scripts.nix ./programs/neovim/. ./programs/git.nix ./programs/lf/. ./programs/shell.nix + { + options.windowManager.modifierKey = lib.mkOption {default = "SUPER";}; + } ]; roles.mpd.enable = true; diff --git a/home/modules/menu.nix b/home/modules/menu.nix index fc50dd6..c244a1b 100644 --- a/home/modules/menu.nix +++ b/home/modules/menu.nix @@ -7,6 +7,7 @@ cfg = config.programs.menu; terminal = config.programs.terminal; termcmd = "${terminal}/bin/${terminal.pname}"; + menucmd = "${config.programs.menu.package}${config.programs.menu.drunCommand}"; in { options.programs = with lib; { menu = { @@ -17,6 +18,9 @@ in { default = "/bin/wofi --show dmenu"; example = "/bin/dmenu"; }; + drunCommand = mkOption { + default = "/bin/wofi --show drun"; + }; }; }; @@ -29,6 +33,8 @@ in { }; }; + wayland.windowManager.sway.config.menu = menucmd; + home.packages = [cfg.package]; }; } diff --git a/home/programs/hyprland.nix b/home/programs/hyprland.nix index b632476..d9abf41 100644 --- a/home/programs/hyprland.nix +++ b/home/programs/hyprland.nix @@ -1,8 +1,11 @@ { lib, pkgs, + config, ... -}: { +}: let + modifier = config.windowManager.modifierKey; +in { imports = [ (import ./swaylock.nix) (import ./swayidle.nix) @@ -51,52 +54,52 @@ ]; }; bind = [ - "SUPER, h, movefocus,l" - "SUPER, l, movefocus,r" - "SUPER, j, layoutmsg,cyclenext" - "SUPER, k, layoutmsg,cycleprev" - "SUPER, space, layoutmsg,swapwithmaster master" - "SUPER, F, fullscreen," - "SUPER, V, togglefloating," - "SUPER, W, layoutmsg, orientationprev" - "SUPER_SHIFT, W, layoutmsg, orientationnext" - "SUPER_SHIFT, V, togglegroup," - "SUPER_SHIFT, h, changegroupactive,b" - "SUPER_SHIFT, h, moveintogroup,l" - "SUPER_SHIFT, l, moveintogroup,r" - "SUPER_SHIFT, l, changegroupactive,f" - "SUPER, Y, togglespecialworkspace" - "SUPER_SHIFT, Y, movetoworkspace, special" - "SUPER_SHIFT, X, killactive" - "SUPER, slash, focuswindow, brave-browser" - "SUPER, n, focuswindow, Logseq" - "SUPER, R, submap, resize" - "SUPER,1,workspace,1" - "SUPER,2,workspace,2" - "SUPER,3,workspace,3" - "SUPER,4,workspace,4" - "SUPER,5,workspace,5" - "SUPER,6,workspace,6" - "SUPER,7,workspace,7" - "SUPER,8,workspace,8" - "SUPER,9,workspace,9" - "SUPER,0,workspace,10" - "SUPER,left,workspace,r-1" - "SUPER,right,workspace,r+1" - "SUPER_SHIFT,1,movetoworkspace,1" - "SUPER_SHIFT,2,movetoworkspace,2" - "SUPER_SHIFT,3,movetoworkspace,3" - "SUPER_SHIFT,4,movetoworkspace,4" - "SUPER_SHIFT,5,movetoworkspace,5" - "SUPER_SHIFT,6,movetoworkspace,6" - "SUPER_SHIFT,7,movetoworkspace,7" - "SUPER_SHIFT,8,movetoworkspace,8" - "SUPER_SHIFT,9,movetoworkspace,9" - "SUPER_SHIFT,0,movetoworkspace,10" + "${modifier}, h, movefocus,l" + "${modifier}, l, movefocus,r" + "${modifier}, j, layoutmsg,cyclenext" + "${modifier}, k, layoutmsg,cycleprev" + "${modifier}, space, layoutmsg,swapwithmaster master" + "${modifier}, F, fullscreen," + "${modifier}, V, togglefloating," + "${modifier}, W, layoutmsg, orientationprev" + "${modifier}_SHIFT, W, layoutmsg, orientationnext" + "${modifier}_SHIFT, V, togglegroup," + "${modifier}_SHIFT, h, changegroupactive,b" + "${modifier}_SHIFT, h, moveintogroup,l" + "${modifier}_SHIFT, l, moveintogroup,r" + "${modifier}_SHIFT, l, changegroupactive,f" + "${modifier}, Y, togglespecialworkspace" + "${modifier}_SHIFT, Y, movetoworkspace, special" + "${modifier}_SHIFT, X, killactive" + "${modifier}, slash, focuswindow, brave-browser" + "${modifier}, n, focuswindow, Logseq" + "${modifier}, R, submap, resize" + "${modifier},1,workspace,1" + "${modifier},2,workspace,2" + "${modifier},3,workspace,3" + "${modifier},4,workspace,4" + "${modifier},5,workspace,5" + "${modifier},6,workspace,6" + "${modifier},7,workspace,7" + "${modifier},8,workspace,8" + "${modifier},9,workspace,9" + "${modifier},0,workspace,10" + "${modifier},left,workspace,r-1" + "${modifier},right,workspace,r+1" + "${modifier}_SHIFT,1,movetoworkspace,1" + "${modifier}_SHIFT,2,movetoworkspace,2" + "${modifier}_SHIFT,3,movetoworkspace,3" + "${modifier}_SHIFT,4,movetoworkspace,4" + "${modifier}_SHIFT,5,movetoworkspace,5" + "${modifier}_SHIFT,6,movetoworkspace,6" + "${modifier}_SHIFT,7,movetoworkspace,7" + "${modifier}_SHIFT,8,movetoworkspace,8" + "${modifier}_SHIFT,9,movetoworkspace,9" + "${modifier}_SHIFT,0,movetoworkspace,10" ]; bindm = [ - "SUPER, mouse:272, movewindow" - "SUPER, mouse:273, resizewindow" + "${modifier}, mouse:272, movewindow" + "${modifier}, mouse:273, resizewindow" ]; env = [ "GDK_BACKEND,wayland,x11" @@ -151,7 +154,7 @@ bind = , escape, submap,reset bind = , enter, submap,reset - bind = SUPER, R, submap,reset + bind = ${modifier}, R, submap,reset bind = CONTROL, C, submap,reset submap = reset ''; diff --git a/home/programs/scripts.nix b/home/programs/scripts.nix index 165b3fc..4950d16 100644 --- a/home/programs/scripts.nix +++ b/home/programs/scripts.nix @@ -3,6 +3,7 @@ pkgs, ... }: let + modifier = config.windowManager.modifierKey; terminal = config.programs.terminal; termcmd = "${terminal}/bin/${terminal.pname}"; my-deps = { @@ -64,7 +65,7 @@ in { ''; hotkeys = [ { - modifier = "SUPER_SHIFT"; + modifier = "${modifier}_SHIFT"; key = "P"; } ]; @@ -84,7 +85,7 @@ in { ''; hotkeys = [ { - modifier = "SUPER_SHIFT"; + modifier = "${modifier}_SHIFT"; key = "S"; } ]; @@ -159,7 +160,7 @@ in { ''; hotkeys = [ { - modifier = "SUPER"; + modifier = "${modifier}"; key = "EQUAL"; } ]; @@ -172,7 +173,7 @@ in { ''; hotkeys = [ { - modifier = "SUPER"; + modifier = "${modifier}"; key = "MINUS"; } ]; @@ -213,7 +214,7 @@ in { ''; hotkeys = [ { - modifier = "SUPER_SHIFT"; + modifier = "${modifier}_SHIFT"; key = "period"; } { @@ -230,7 +231,7 @@ in { ''; hotkeys = [ { - modifier = "SUPER_SHIFT"; + modifier = "${modifier}_SHIFT"; key = "comma"; } { @@ -285,7 +286,7 @@ in { hotkeys = [ { key = "C"; - modifier = "SUPER_SHIFT"; + modifier = "${modifier}_SHIFT"; } ]; } diff --git a/home/programs/sway.nix b/home/programs/sway.nix index a32d452..63015e5 100644 --- a/home/programs/sway.nix +++ b/home/programs/sway.nix @@ -45,46 +45,8 @@ enable = true; settings = { mainBar = { - layer = "top"; - position = "top"; - height = 36; modules-left = ["sway/workspaces" "sway/window"]; - modules-right = ["mpris" "pulseaudio" "clock" "tray" "battery"]; - clock = { - format = "πŸ“… {:%a %b-%d %I:%M %p}"; - }; - pulseaudio = { - format-muted = "πŸ”‡ {volume}"; - format = "{icon} {volume}"; - format-icons.default = ["πŸ”ˆ" "πŸ”‰" "πŸ”Š"]; - on-click = "${pkgs.pavucontrol}/bin/pavucontrol"; - }; - mpris = { - format = "{player_icon} {artist} - {title}"; - format-paused = "{status_icon} {player_icon} {artist} - {title}"; - player-icons = { - default = "▢️"; - mpd = "🎡"; - kdeconnect = "☎️"; - }; - status-icons = { - paused = "⏸️"; - }; - }; - battery = { - format = "{icon} {capacity}%"; - format-icons = ["🀏" "πŸͺ«" "πŸ”‹" "πŸ”‹"]; - format-charging = "πŸ”Œ {capacity}%"; - states = { - warning = 30; - critical = 15; - }; - }; }; }; - systemd = { - enable = true; - target = "graphical-session.target"; - }; }; } diff --git a/nixos/programs/hyprland.nix b/nixos/programs/hyprland.nix index 7e5fa1f..dfe83df 100644 --- a/nixos/programs/hyprland.nix +++ b/nixos/programs/hyprland.nix @@ -13,8 +13,6 @@ in { }; home-manager.users.${user}.imports = [ - { - wayland.windowManager.hyprland.enable = true; - } + ../../home/programs/hyprland.nix ]; } diff --git a/nixos/programs/sway.nix b/nixos/programs/sway.nix index 8b66c5b..5748c73 100644 --- a/nixos/programs/sway.nix +++ b/nixos/programs/sway.nix @@ -1,9 +1,6 @@ -{user}: { - lib, - pkgs, - config, - ... -}: { +{config, ...}: let + user = config.user; +in { services.greetd = { enable = true; settings = rec {