From 5505eec77d58c0e8e05fe284104d5b00750fd854 Mon Sep 17 00:00:00 2001 From: Jacob Bachmann Date: Sat, 7 Oct 2023 19:10:14 +0200 Subject: [PATCH] feat: add a lot of stuff --- flake.nix | 1 + modules/aliases.nix | 1 - modules/bluetooth.nix | 1 - modules/default.nix | 3 +- modules/nvidia.nix | 9 ++- modules/packages.nix | 3 +- modules/print.nix | 4 - modules/printing.nix | 11 +++ modules/security.nix | 5 ++ modules/virtualisation.nix | 8 ++ users/gandalf/default.nix | 12 +-- users/gandalf/modules/alacritty.nix | 1 - users/gandalf/modules/chromium.nix | 73 +++++++++++++++++++ users/gandalf/modules/common.nix | 1 + users/gandalf/modules/dconf.nix | 10 +++ users/gandalf/modules/default.nix | 5 +- users/gandalf/modules/flameshot/build.nix | 14 ++++ users/gandalf/modules/flameshot/default.nix | 1 + users/gandalf/modules/flameshot/flameshot.nix | 5 ++ users/gandalf/modules/kanshi.nix | 33 +++++++++ users/gandalf/modules/neovim.nix | 6 +- users/gandalf/modules/packages.nix | 7 ++ users/gandalf/modules/playerctl.nix | 6 -- users/gandalf/modules/spotify-player/app.toml | 47 ------------ .../modules/spotify-player/default.nix | 5 -- .../modules/spotify-player/spotify-player.nix | 9 --- users/gandalf/modules/sway.nix | 26 ++++++- users/gandalf/modules/vscode.nix | 14 ++++ 28 files changed, 224 insertions(+), 97 deletions(-) delete mode 100644 modules/print.nix create mode 100644 modules/printing.nix create mode 100644 modules/virtualisation.nix create mode 100644 users/gandalf/modules/chromium.nix create mode 100644 users/gandalf/modules/dconf.nix create mode 100644 users/gandalf/modules/flameshot/build.nix create mode 100644 users/gandalf/modules/flameshot/default.nix create mode 100644 users/gandalf/modules/flameshot/flameshot.nix create mode 100644 users/gandalf/modules/kanshi.nix delete mode 100644 users/gandalf/modules/spotify-player/app.toml delete mode 100644 users/gandalf/modules/spotify-player/default.nix delete mode 100644 users/gandalf/modules/spotify-player/spotify-player.nix diff --git a/flake.nix b/flake.nix index 3f237a6..fd97432 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,7 @@ ./modules home-manager.nixosModules.home-manager + { imports = [ ./users/gandalf ]; } diff --git a/modules/aliases.nix b/modules/aliases.nix index 1d3495c..1907efc 100644 --- a/modules/aliases.nix +++ b/modules/aliases.nix @@ -15,5 +15,4 @@ nec = "sudo -E nvim -u $HOME/.config/nvim/init.lua --cmd 'cd /etc/nixos'"; ncc = "sudo nixos-rebuild switch --upgrade-all --flake /etc/nixos"; nup = "sudo nix-channel --update && sudo nixos-rebuild switch --upgrade-all --flake /etc/nixos"; - spt = "spotify_player"; } diff --git a/modules/bluetooth.nix b/modules/bluetooth.nix index 44db521..558d8ff 100644 --- a/modules/bluetooth.nix +++ b/modules/bluetooth.nix @@ -6,4 +6,3 @@ services.blueman.enable = true; } - diff --git a/modules/default.nix b/modules/default.nix index 21c4978..b008b4d 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -13,11 +13,12 @@ ./opengl.nix ./power.nix ./packages.nix - ./print.nix + ./printing.nix ./security.nix ./shell.nix ./udisks2.nix ./unfree.nix + ./virtualisation.nix ./xdg-portal.nix ]; } diff --git a/modules/nvidia.nix b/modules/nvidia.nix index f9e389c..7948f0f 100644 --- a/modules/nvidia.nix +++ b/modules/nvidia.nix @@ -1,5 +1,7 @@ -{ ... }: { - /* +{ config, ... }: { + + # services.xserver.videoDrivers = [ "nouveau" ]; + services.xserver.videoDrivers = [ "nvidia" ]; hardware.nvidia = { @@ -10,6 +12,7 @@ open = false; # Enable the nvidia settings menu nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.legacy_390; }; - */ + } diff --git a/modules/packages.nix b/modules/packages.nix index 7ac2be7..f93b0cf 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -1,6 +1,7 @@ { pkgs, ... }: { environment.systemPackages = with pkgs; [ pciutils + qt5.qtwayland qt6.qtwayland xdg-utils # for opening default programs glib # gsettings @@ -20,6 +21,6 @@ javaPackages.openjfx17 gradle_7 python312 - nodejs_20 + nodenv ]; } diff --git a/modules/print.nix b/modules/print.nix deleted file mode 100644 index 8b637c8..0000000 --- a/modules/print.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ ... }: { - # Enable CUPS to print documents. - services.printing.enable = true; -} diff --git a/modules/printing.nix b/modules/printing.nix new file mode 100644 index 0000000..5bd7c69 --- /dev/null +++ b/modules/printing.nix @@ -0,0 +1,11 @@ +{ ... }: { + # Enable CUPS to print documents. + services.printing.enable = true; + + services.avahi = { + enable = true; + nssmdns = true; + openFirewall = true; + }; + +} diff --git a/modules/security.nix b/modules/security.nix index 2923b05..b99a68e 100644 --- a/modules/security.nix +++ b/modules/security.nix @@ -3,4 +3,9 @@ # rtkit is optional but recommended security.rtkit.enable = true; + + # TODO workaround to get swaylock accepting pw + # https://github.com/NixOS/nixpkgs/issues/158025 + security.pam.services.swaylock = {}; + } diff --git a/modules/virtualisation.nix b/modules/virtualisation.nix new file mode 100644 index 0000000..0515dff --- /dev/null +++ b/modules/virtualisation.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: { + + # virt-manager + virtualisation.libvirtd.enable = true; + programs.dconf.enable = true; + environment.systemPackages = with pkgs; [ virt-manager ]; + +} diff --git a/users/gandalf/default.nix b/users/gandalf/default.nix index 63dafd6..78d46aa 100644 --- a/users/gandalf/default.nix +++ b/users/gandalf/default.nix @@ -1,19 +1,11 @@ -{ pkgs, unstable, ... }: +{ unstable, ... }: let aliases = import ../../modules/aliases.nix; in { users.users.gandalf = { isNormalUser = true; - extraGroups = [ "wheel" "networkmanager" ]; - packages = with pkgs; [ - firefox - speechd # https://support.mozilla.org/en-US/kb/speechd-setup - gopass - gopass-jsonapi - gnome.nautilus - gimp - ]; + extraGroups = [ "wheel" "networkmanager" "libvirtd" ]; }; home-manager.useGlobalPkgs = true; diff --git a/users/gandalf/modules/alacritty.nix b/users/gandalf/modules/alacritty.nix index 26c647d..6833696 100644 --- a/users/gandalf/modules/alacritty.nix +++ b/users/gandalf/modules/alacritty.nix @@ -21,4 +21,3 @@ in }; }; } - diff --git a/users/gandalf/modules/chromium.nix b/users/gandalf/modules/chromium.nix new file mode 100644 index 0000000..64029c4 --- /dev/null +++ b/users/gandalf/modules/chromium.nix @@ -0,0 +1,73 @@ +{ config, pkgs, lib, ... }: +let + + icons = { + chromium = pkgs.fetchurl { + url = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Chromium_Logo.svg/240px-Chromium_Logo.svg.png"; + sha256 = "ff6383a5c08745100e1f8720397c3d6e1b30bc6d4a329cf44bbac16ec03948e7"; + meta.licenses = lib.licenses.publicDomain; + }; + spotify = pkgs.fetchurl { + url = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Spotify_icon.svg/232px-Spotify_icon.svg.png"; + sha256 = "0568b108bf4533e7382e0f3526e211308868d2d2aa35ab8f0cc7beb464e70d5f"; + meta.licenses = lib.licenses.publicDomain; + }; + teams = pkgs.fetchurl { + url = "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Microsoft_Office_Teams_%282018%E2%80%93present%29.svg/258px-Microsoft_Office_Teams_%282018%E2%80%93present%29.svg.png"; + sha256 = "a7bf37b6132e45c3c3314e7ed3a465138caabe3d87535a8b82a84be6a5f70dac"; + meta.licenses = lib.licenses.publicDomain; + }; + outlook = pkgs.fetchurl { + url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Microsoft_Office_Outlook_%282018%E2%80%93present%29.svg/258px-Microsoft_Office_Outlook_%282018%E2%80%93present%29.svg.png"; + sha256 = "565fff2ed6a3c4c98daf7a2b56aad386c2d076f4f5b88199785593eb380eb3d4"; + meta.licenses = lib.licenses.publicDomain; + }; + }; + +in +{ + + programs.chromium = { + enable = true; + extensions = [ + { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin + { id = "dbepggeogbaibhgnhhndojpepiihcmeb"; } # vimium + ]; + }; + + xdg.dataFile = { + "applications/chromium-development.desktop".text = '' + [Desktop Entry] + Type=Application + Name=Chromium (Development Modus) + Exec=${pkgs.chromium}/bin/chromium --allow-file-access-from-files --disable-site-isolation-trials --allow-running-insecure-content --no-referrers --unlimited-storage --user-data-dir=${config.xdg.dataHome}/chromium-development/data --disable-web-security + Terminal=false + Icon=${icons.chromium} + ''; + "applications/spotify.desktop".text = '' + [Desktop Entry] + Type=Application + Name=Spotify + Exec=${pkgs.chromium}/bin/chromium --app=https://spotify.com + Terminal=false + Icon=${icons.spotify} + ''; + "applications/teams.desktop".text = '' + [Desktop Entry] + Type=Application + Name=Microsoft Teams + Exec=${pkgs.chromium}/bin/chromium --app=https://teams.microsoft.com + Terminal=false + Icon=${icons.teams} + ''; + "applications/outlook.desktop".text = '' + [Desktop Entry] + Type=Application + Name=Microsoft Outlook + Exec=${pkgs.chromium}/bin/chromium --app=https://outlook.office365.com/mail + Terminal=false + Icon=${icons.outlook} + ''; + }; + +} diff --git a/users/gandalf/modules/common.nix b/users/gandalf/modules/common.nix index f7b0858..d4716cb 100644 --- a/users/gandalf/modules/common.nix +++ b/users/gandalf/modules/common.nix @@ -7,6 +7,7 @@ # https://yeun.github.io/open-color/ active = "#ffdeeb"; # pink1 activeDark = "#f783ac"; # pink4 + _activeDark = "f783ac"; # pink4 inactive = "#495057"; # gray7 inactiveDark = "#212529"; # gray9 alert = "#c92a2a"; # red9 diff --git a/users/gandalf/modules/dconf.nix b/users/gandalf/modules/dconf.nix new file mode 100644 index 0000000..0714dc4 --- /dev/null +++ b/users/gandalf/modules/dconf.nix @@ -0,0 +1,10 @@ +{ ... }: { + + dconf.settings = { + "org/virt-manager/virt-manager/connections" = { + autoconnect = ["qemu:///system"]; + uris = ["qemu:///system"]; + }; + }; + +} diff --git a/users/gandalf/modules/default.nix b/users/gandalf/modules/default.nix index bbd5858..d9b4c69 100644 --- a/users/gandalf/modules/default.nix +++ b/users/gandalf/modules/default.nix @@ -1,15 +1,18 @@ { imports = [ ./alacritty.nix + ./chromium.nix + ./dconf.nix ./fzf.nix ./git.nix ./gnupg.nix + ./kanshi.nix ./keyring.nix ./neovim.nix ./obs.nix ./packages.nix ./playerctl.nix - ./spotify-player + ./spotify ./ssh.nix ./sway.nix ./swaync diff --git a/users/gandalf/modules/flameshot/build.nix b/users/gandalf/modules/flameshot/build.nix new file mode 100644 index 0000000..ce5e17f --- /dev/null +++ b/users/gandalf/modules/flameshot/build.nix @@ -0,0 +1,14 @@ +{ pkgs , cmake , qttools , qtsvg , kguiaddons , wrapQtAppsHook }: + +# https://ryantm.github.io/nixpkgs/using/overrides/ +pkgs.flameshot.overrideAttrs (finalAttrs: previousAttrs: { + + pname = previousAttrs.pname + "-wl"; + + nativeBuildInputs = [ cmake qttools qtsvg kguiaddons wrapQtAppsHook ]; + cmakeFlags = [ + "-DUSE_WAYLAND_CLIPBOARD=1" + "-DUSE_WAYLAND_GRIM=1" + ]; + +}) diff --git a/users/gandalf/modules/flameshot/default.nix b/users/gandalf/modules/flameshot/default.nix new file mode 100644 index 0000000..845b128 --- /dev/null +++ b/users/gandalf/modules/flameshot/default.nix @@ -0,0 +1 @@ +import ./flameshot.nix diff --git a/users/gandalf/modules/flameshot/flameshot.nix b/users/gandalf/modules/flameshot/flameshot.nix new file mode 100644 index 0000000..7cfbf0f --- /dev/null +++ b/users/gandalf/modules/flameshot/flameshot.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: + +# https://nixos.wiki/wiki/Qt +# https://nixos.org/manual/nixpkgs/stable/#sec-language-qt +pkgs.libsForQt5.callPackage ./build.nix { } diff --git a/users/gandalf/modules/kanshi.nix b/users/gandalf/modules/kanshi.nix new file mode 100644 index 0000000..19d6561 --- /dev/null +++ b/users/gandalf/modules/kanshi.nix @@ -0,0 +1,33 @@ +{ ... }: { + + services.kanshi = { + enable = true; + + profiles = { + + home = { + outputs = [ + { + criteria = "DP-3"; + mode = "1920x1080"; + position = "0,0"; + } + { + criteria = "DP-2"; + mode = "1920x1080"; + position = "1920,0"; + } + { + criteria = "LVDS-1"; + mode = "1920x1080"; + position = "3840,0"; + scale = 1.33; + } + ]; + }; + + }; + + }; + +} diff --git a/users/gandalf/modules/neovim.nix b/users/gandalf/modules/neovim.nix index ab5392d..c8e579e 100644 --- a/users/gandalf/modules/neovim.nix +++ b/users/gandalf/modules/neovim.nix @@ -76,9 +76,9 @@ indent = { enable = true }, - highlight = { - enable = true - }, + -- highlight = { + -- enable = true + -- }, } -- nvim-lspconfig diff --git a/users/gandalf/modules/packages.nix b/users/gandalf/modules/packages.nix index 9c833e3..290c5fc 100644 --- a/users/gandalf/modules/packages.nix +++ b/users/gandalf/modules/packages.nix @@ -1,7 +1,14 @@ { pkgs, ... }: { home.packages = with pkgs; [ + firefox + speechd # https://support.mozilla.org/en-US/kb/speechd-setup + gopass + gopass-jsonapi + gnome.nautilus + gimp vlc + gnome.simple-scan ]; } diff --git a/users/gandalf/modules/playerctl.nix b/users/gandalf/modules/playerctl.nix index 11a93be..55f1521 100644 --- a/users/gandalf/modules/playerctl.nix +++ b/users/gandalf/modules/playerctl.nix @@ -4,10 +4,4 @@ playerctl ]; - /* - services.playerctld = { - enable = true; - }; - */ - } diff --git a/users/gandalf/modules/spotify-player/app.toml b/users/gandalf/modules/spotify-player/app.toml deleted file mode 100644 index 74ea4c7..0000000 --- a/users/gandalf/modules/spotify-player/app.toml +++ /dev/null @@ -1,47 +0,0 @@ -theme = "dracula" -client_id = "65b708073fc0480ea92a077233ca87bd" -client_port = 8080 -playback_format = """ -{track} • {artists} -{album} -{metadata}""" -tracks_playback_limit = 50 -app_refresh_duration_in_ms = 32 -playback_refresh_duration_in_ms = 0 -cover_image_refresh_duration_in_ms = 2000 -page_size_in_rows = 20 -track_table_item_max_len = 32 -play_icon = "▶" -pause_icon = "▌▌" -liked_icon = "♥" -border_type = "Plain" -progress_bar_type = "Rectangle" -playback_window_position = "Top" -cover_img_length = 9 -cover_img_width = 5 -cover_img_scale = 1.0 -playback_window_width = 6 -enable_media_control = true -enable_streaming = true -enable_cover_image_cache = true -default_device = "spotify-player" - -[copy_command] -command = "xclip" -args = [ - "-sel", - "c", -] - -[notify_format] -summary = "{track} • {artists}" -body = "{album}" - -[device] -name = "spotify-player" -device_type = "speaker" -volume = 80 -bitrate = 320 -audio_cache = false - -# test diff --git a/users/gandalf/modules/spotify-player/default.nix b/users/gandalf/modules/spotify-player/default.nix deleted file mode 100644 index a2a30d1..0000000 --- a/users/gandalf/modules/spotify-player/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./spotify-player.nix - ]; -} diff --git a/users/gandalf/modules/spotify-player/spotify-player.nix b/users/gandalf/modules/spotify-player/spotify-player.nix deleted file mode 100644 index 40a9a84..0000000 --- a/users/gandalf/modules/spotify-player/spotify-player.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkgs, ... }: { - - home.packages = with pkgs; [ - spotify-player - ]; - - xdg.configFile."spotify-player/app.toml".source = ./app.toml; - -} diff --git a/users/gandalf/modules/sway.nix b/users/gandalf/modules/sway.nix index 55b0b54..0d3bd34 100644 --- a/users/gandalf/modules/sway.nix +++ b/users/gandalf/modules/sway.nix @@ -1,14 +1,20 @@ { config, pkgs, lib, ... }: let + cfg = config.wayland.windowManager.sway.config; common = import ./common.nix; + wallpaper = pkgs.fetchurl { url = "https://live.staticflickr.com/65535/52797919139_2444712a38_o_d.png"; sha256 = "1a9148d8911fa25afa82d3b843ee620173955a7ca705d525f3e9d00e00696308"; meta.licenses = lib.licenses.cc0; }; + + # flameshot = pkgs.libsForQt5.callPackage ./flameshot/build.nix { }; + in { + home.packages = with pkgs; [ brightnessctl # control screen brightness pavucontrol # control audio @@ -16,13 +22,17 @@ in networkmanagerapplet # control network dracula-theme # gtk theme gnome3.adwaita-icon-theme # default gnome cursors - # wdisplays # graphical output manager - # wev # wayland event monitor wl-clipboard # cli tool to manage wayland clipboard - # wl-mirror # emulation for “mirror display” mode - # wlr-randr # output management that actually works + sway-contrib.grimshot + wdisplays + wlr-randr ]; + programs.swaylock = { + enable = true; + package = pkgs.swaylock-effects; + }; + wayland.windowManager.sway = { enable = true; wrapperFeatures = { @@ -44,6 +54,7 @@ in export SDL_VIDEODRIVER=wayland # QT (needs qt5.qtwayland in systemPackages): export QT_QPA_PLATFORM=wayland-egl + # export QT_QPA_PLATFORM=wayland export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 # Fix for some Java AWT applications (e.g. Android Studio), # use this if they aren't displayed properly: @@ -81,7 +92,10 @@ in down = "j"; up = "k"; right = "l"; + keybindings = { + "${cfg.modifier}+Ctrl+Shift+l" = "exec ${pkgs.swaylock-effects}/bin/swaylock --screenshots --clock --indicator --indicator-radius 100 --indicator-thickness 7 --effect-blur 7x5 --effect-vignette 0.5:0.5 --ring-color ffffff --key-hl-color ${common.colorschemes.default._activeDark} --line-color 00000000 --inside-color 00000088 --inside-ver-color ${common.colorschemes.default._activeDark} --separator-color 00000000 --text-color ${common.colorschemes.default._activeDark} --fade-in 0.1"; + # Basics "${cfg.modifier}+Return" = "exec ${cfg.terminal}"; "${cfg.modifier}+q" = "kill"; @@ -175,6 +189,9 @@ in "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; "XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + # Screenshot + "Print" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy area"; + # Programs "${cfg.modifier}+Shift+v" = "exec ${pkgs.pavucontrol}/bin/pavucontrol"; "${cfg.modifier}+Shift+b" = "exec ${pkgs.blueman}/bin/blueman-manager"; @@ -287,5 +304,6 @@ in # ^-- resize again, case moving to different output ''; }; + } diff --git a/users/gandalf/modules/vscode.nix b/users/gandalf/modules/vscode.nix index 65bd286..021e73c 100644 --- a/users/gandalf/modules/vscode.nix +++ b/users/gandalf/modules/vscode.nix @@ -59,6 +59,20 @@ in "**/__pycache__" = true; }; + "vim.normalModeKeyBindingsNonRecursive" = [ + { + "before" = [ "" ]; + "commands" = [ "workbench.action.quickOpen" ]; + } + { + "before" = [ "" ]; + "commands" = [ + "workbench.view.explorer" + "workbench.action.toggleSidebarVisibility" + ]; + } + ]; + "[html]" = { "editor.tabSize" = 2; "editor.insertSpaces" = true;