diff --git a/flake.nix b/flake.nix index 251eabc..21b1c7b 100644 --- a/flake.nix +++ b/flake.nix @@ -51,11 +51,12 @@ overlays = [ nixgl.overlay ]; }; extraSpecialArgs = { - inherit stateVersion inputs; + inherit stateVersion inputs nixgl; hostname = hostname; username = username; }; modules = [ + { nixpkgs.overlays = [ nixgl.overlay ];} ./home-manager/default.nix ]; }; diff --git a/home-manager/default.nix b/home-manager/default.nix index befa969..f70cd47 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,4 +1,4 @@ -{ inputs, lib, stateVersion, username, hostname, ... }: +{ inputs, lib, stateVersion, username, hostname, nixgl, ... }: { imports = [ inputs.sops-nix.homeManagerModules.sops @@ -12,7 +12,9 @@ nixpkgs.config.allowUnfree = true; programs.home-manager.enable = true; fonts.fontconfig.enable = true; - + nixGL.packages = nixgl.packages; + nixGL.defaultWrapper = "mesa"; + nixGL.installScripts = ["mesa"]; home = { inherit stateVersion username; homeDirectory = "/home/${username}"; diff --git a/hosts/rick/home-config.nix b/hosts/rick/home-config.nix index 5a6295c..a72cdf0 100644 --- a/hosts/rick/home-config.nix +++ b/hosts/rick/home-config.nix @@ -24,14 +24,8 @@ kdenlive.enable = false; mpv.enable = false; }; - web.firefox = { - enable = true; - enableNixGL = true; - }; - web.qutebrowser = { - enable = true; - enableNixGL = true; - }; + web.firefox.enable = true; + web.qutebrowser.enable = true; web.webcord.enable = false; gaming.lutris.enable = false; desktop.sway = { diff --git a/hosts/work/home-config.nix b/hosts/work/home-config.nix index 0712e15..0155435 100644 --- a/hosts/work/home-config.nix +++ b/hosts/work/home-config.nix @@ -2,10 +2,7 @@ config.modules = { application = { zathura.enable = true; - foot = { - enable = true; - font-size = "10.5"; - }; + foot.enable = true; }; audio.cmus.enable = true; cli = { @@ -33,9 +30,22 @@ zellij.enable = true; zsh.enable = true; }; + desktop.sway = { + enable = true; + kanshi = true; + swaylock.useNullPackage = true; + waybar = { + laptop = true; + gpuThermal.enable = false; + cpuThermal = { + hwmonPathAbs = "/sys/devices/platform/coretemp.0/hwmon/"; + inputFilename = "temp1_input"; + }; + }; + xdg.useDistributionPortals = true; + }; web.firefox = { enable = true; - enableNixGL = true; optionalExtensions = with pkgs.nur.repos.rycee.firefox-addons; [ okta-browser-plugin ]; diff --git a/hosts/work/includes/home-manager.nix b/hosts/work/includes/home-manager.nix index 1d1c542..92fc843 100644 --- a/hosts/work/includes/home-manager.nix +++ b/hosts/work/includes/home-manager.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: { home.packages = with pkgs; [ dejavu_fonts @@ -13,7 +13,23 @@ noto-fonts-cjk-sans slurp wl-clipboard + (config.lib.nixGL.wrap ungoogled-chromium) + (config.lib.nixGL.wrap slack) ]; targets.genericLinux.enable = true; xdg.mime.enable = true; + wayland.windowManager.sway.config.input = { + "1:1:AT_Translated_Set_2_keyboard" = { + xkb_layout = "us"; + xkb_variant = "altgr-intl"; + }; + "65261:8800:KBDFans_DZ60" = { + xkb_layout = "us"; + xkb_variant = "altgr-intl"; + }; + }; + + home.sessionVariables = { + SSH_AUTH_SOCK = ''$XDG_RUNTIME_DIR/gnupg/S.gpg-agent.ssh''; + }; } diff --git a/modules/home-manager/desktop/sway/default.nix b/modules/home-manager/desktop/sway/default.nix index 57a6c16..643e192 100644 --- a/modules/home-manager/desktop/sway/default.nix +++ b/modules/home-manager/desktop/sway/default.nix @@ -13,6 +13,26 @@ in description = "configure laptop mode"; }; + swaylock.useNullPackage = mkOption { + type = types.bool; + default = false; + description = '' + Use null package to not install swaylock with Nix + Useful when using Home-Manager on third-party distribution to avoid + problem with PAM + ''; + }; + + xdg.useDistributionPortals = mkOption { + type = types.bool; + default = false; + description = '' + This prevent installing xdg-desktop-portal from nixpkgs. These + Useful when using Home-Manager on third-party distribution with old + version of portals (coucou Ubuntu LTS) + ''; + }; + wallpapers = { lockscreen = mkOption { type = types.str; @@ -114,7 +134,7 @@ in }; iconTheme = { name = "Papirus Dark"; - package = pkgs.papirus-icon-theme; + package = pkgs.papirus-icon-theme; }; font = { name = "Deja Vu Sans"; @@ -133,8 +153,10 @@ in }; }; - # Avoid pixelated effect for QT application with fractionnal scaling home.sessionVariables = { + # Use wayland for chrom{e|ium} based crap + NIXOS_OZONE_WL = "1"; + # Avoid pixelated effect for QT application with fractionnal scaling QT_SCALE_FACTOR_ROUNDING_POLICY = "RoundPreferFloor"; }; @@ -158,6 +180,32 @@ in desktop = "${config.home.homeDirectory}/documents"; publicShare = "${config.home.homeDirectory}/tmp/public"; }; + portal = mkIf (cfg.xdg.useDistributionPortals == false) { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + xdg-desktop-portal-gtk + ]; + xdgOpenUsePortal = true; + config = { + sway = { + default = [ + "wlr" + "gtk" + ]; + }; + }; + }; }; + + # When using `useDistributionPackage`, create wlr configuration to let user + # choose the right screen. This is a workarount to not have to configure + # it manually. + home.file."${config.xdg.configHome}/xdg-desktop-portal-wlr/config".text = mkIf cfg.xdg.useDistributionPortals '' + [screencast] + max_fps=30 + chooser_type=simple + chooser_cmd=${pkgs.slurp}/bin/slurp -f %o -or + ''; }; } diff --git a/modules/home-manager/desktop/sway/includes/kanshi.nix b/modules/home-manager/desktop/sway/includes/kanshi.nix index a0453e3..8376511 100644 --- a/modules/home-manager/desktop/sway/includes/kanshi.nix +++ b/modules/home-manager/desktop/sway/includes/kanshi.nix @@ -10,7 +10,7 @@ with lib; profile.name = "standalone"; profile.outputs = [ { - criteria = "eDP-1"; + criteria = "eDP-1"; scale = 1.33; status = "enable"; } @@ -20,13 +20,13 @@ with lib; profile.name = "home"; profile.outputs = [ { - criteria = "Iiyama North America PL2792UH 1166310803122"; + criteria = "Iiyama North America PL2792UH 1166310803122"; mode = "3840x2160"; position = "1235,0"; scale = 1.75; } - { - criteria = "Iiyama North America PL2792UH 1176923201598"; + { + criteria = "Iiyama North America PL2792UH 1176923201598"; mode = "3840x2160"; position = "0,0"; transform = "90"; @@ -42,18 +42,16 @@ with lib; profile.name = "work"; profile.outputs = [ { - criteria = "Iiyama North America PL2480H 11183M2807013"; - mode = "1920x1080"; - position = "0,0"; - } - { - criteria = "Iiyama North America PL2480H 11183M2807016"; - mode = "1920x1080"; - position = "1920,0"; + criteria = "Iiyama North America PL2792QN 1179214201663"; + mode = "2560x1440"; + position = "1450,0"; + scale = 1.15; } { - criteria = "eDP-1"; - status = "disable"; + criteria = "BOE 0x0A95 Unknown"; + mode = "1920x1080"; + position = "0,0"; + scale = 1.325; } ]; } diff --git a/modules/home-manager/desktop/sway/includes/sway.nix b/modules/home-manager/desktop/sway/includes/sway.nix index 004322b..f93d2c6 100644 --- a/modules/home-manager/desktop/sway/includes/sway.nix +++ b/modules/home-manager/desktop/sway/includes/sway.nix @@ -6,6 +6,7 @@ in { config = mkIf config.modules.desktop.sway.enable { wayland.windowManager.sway = { + package = config.lib.nixGL.wrap pkgs.sway; enable = true; wrapperFeatures.gtk = true; systemd.enable = true; @@ -75,7 +76,7 @@ in "${mod}+Alt+k" = "kill"; "${mod}+Alt+c" = "reload"; "${mod}+Alt+Backspace" = "exec swaynag -t warning -m 'Exit sway?' -B 'Yes' 'swaymsg exit'"; - "${mod}+Alt+l" = "exec ${pkgs.swaylock}/bin/swaylock"; + "${mod}+Alt+l" = if cfg.swaylock.useNullPackage then "exec swaylock" else "exec ${pkgs.swaylock}/bin/swaylock"; # Manage windows placement "${mod}+b" = "splith"; "${mod}+v" = "splitv"; diff --git a/modules/home-manager/desktop/sway/includes/swayidle.nix b/modules/home-manager/desktop/sway/includes/swayidle.nix index 1b22575..577621c 100644 --- a/modules/home-manager/desktop/sway/includes/swayidle.nix +++ b/modules/home-manager/desktop/sway/includes/swayidle.nix @@ -10,7 +10,7 @@ in timeouts = [ { timeout = 300; - command = "${pkgs.swaylock}/bin/swaylock -f"; + command = if cfg.swaylock.useNullPackage then ''/usr/bin/swaylock -f'' else ''${pkgs.swaylock}/bin/swaylock -f''; } { timeout = 600; @@ -21,11 +21,11 @@ in events = [ { event = "before-sleep"; - command = "${pkgs.swaylock}/bin/swaylock -f"; + command = if cfg.swaylock.useNullPackage then ''/usr/bin/swaylock -f'' else ''${pkgs.swaylock}/bin/swaylock -f''; } { event = "lock"; - command = "${pkgs.swaylock}/bin/swaylock -f"; + command = if cfg.swaylock.useNullPackage then ''usr/bin/swaylock -f'' else ''${pkgs.swaylock}/bin/swaylock -f''; } ]; }; diff --git a/modules/home-manager/desktop/sway/includes/swaylock.nix b/modules/home-manager/desktop/sway/includes/swaylock.nix index 0bacc89..b0340ef 100644 --- a/modules/home-manager/desktop/sway/includes/swaylock.nix +++ b/modules/home-manager/desktop/sway/includes/swaylock.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, ... }: with lib; let cfg = config.modules.desktop.sway; @@ -6,9 +6,10 @@ in { config = mkIf config.modules.desktop.sway.enable { programs.swaylock = { + package = if cfg.swaylock.useNullPackage then null else pkgs.swaylock; enable = true; settings = { - image = "${cfg.wallpapers.lockscreen}"; + image = if cfg.wallpapers.lockscreen != "" then "${cfg.wallpapers.lockscreen}" else false; scaling = "center"; color = "000000"; indicator-radius = 70; @@ -22,7 +23,7 @@ in ring-wrong-color = "f268b3"; inside-wrong-color = "f268b3cc"; key-hl-color = "1cd180"; - caps-lock-key-hl-color = "1cd180"; + caps-lock-key-hl-color = "1cd180"; caps-lock-bs-hl-color = "f268b3"; bs-hl-color = "f268b3ff"; separator-color = "00000000"; diff --git a/modules/home-manager/desktop/sway/includes/waybar.nix b/modules/home-manager/desktop/sway/includes/waybar.nix index df1a1f1..d46baf1 100644 --- a/modules/home-manager/desktop/sway/includes/waybar.nix +++ b/modules/home-manager/desktop/sway/includes/waybar.nix @@ -1,4 +1,4 @@ -{lib, config, ...}: +{lib, config, ...}: with lib; let cfg = config.modules.desktop.sway; @@ -22,7 +22,7 @@ in "sway/mode" ]; modules-right = [ - "network" + "network" "custom/sep" ] ++ ( if cfg.waybar.laptop then [ @@ -38,15 +38,15 @@ in "memory" "cpu" "temperature" - "custom/sep" + "custom/sep" ] ++ ( if cfg.waybar.gpuThermal.enable then [ "temperature#gpu" "custom/sep" - ] + ] else [ ] - ) ++ + ) ++ [ "pulseaudio" "custom/sep" @@ -101,8 +101,8 @@ in "format-icons" = { "car" = ""; "default" = ""; - "handsfree" = "󰋎"; - "headphones" = "󰋋"; + "hands-free" = "󰋎"; + "headphone" = "󰋋"; "headset" = "󰋎"; "phone" = ""; "portable" = ""; diff --git a/modules/home-manager/web/firefox/default.nix b/modules/home-manager/web/firefox/default.nix index 191bdae..d52f8a9 100644 --- a/modules/home-manager/web/firefox/default.nix +++ b/modules/home-manager/web/firefox/default.nix @@ -29,11 +29,6 @@ in description = "Optional Firefox Plugins to install"; }; - enableNixGL = mkOption { - type = types.bool; - default = false; - description = "Use NixGL to start Firefox"; - }; }; config = mkIf cfg.enable { programs.browserpass = { @@ -47,24 +42,6 @@ in "x-scheme-handler/about" = "firefox.desktop"; "x-scheme-handler/unknown" = "firefox.desktop"; }; - xdg.desktopEntries."firefox" = mkIf cfg.enableNixGL { - name = "Firefox NixGL Powered"; - exec = "${pkgs.nixgl.nixGLMesa}/bin/nixGLMesa firefox %U"; - icon = "firefox"; - terminal = false; - type = "Application"; - startupNotify = true; - actions = { - "new-private-window" = { - exec = "${pkgs.nixgl.nixGLMesa}/bin/nixGLMesa firefox --private-window %U"; - name = "New Private Window"; - }; - "new-window" = { - exec = "${pkgs.nixgl.nixGLMesa}/bin/nixGLMesa firefox --new-window %U"; - name = "New Window"; - }; - }; - }; xdg.configFile."tridactyl/tridactylrc".text = '' sanitize tridactyllocal tridactylsync @@ -93,13 +70,13 @@ in allExtensions = cfg.baseExtensions ++ cfg.optionalExtensions; in { enable = true; - package = pkgs.wrapFirefox pkgs.firefox-unwrapped { + package = config.lib.nixGL.wrap ( pkgs.wrapFirefox pkgs.firefox-unwrapped { nativeMessagingHosts = [ # Tridactyl native connector pkgs.tridactyl-native pkgs.browserpass ]; - }; + }); profiles.ephase = { id = 0; name = "ephase"; diff --git a/modules/home-manager/web/qutebrowser/default.nix b/modules/home-manager/web/qutebrowser/default.nix index 81549e1..b626027 100644 --- a/modules/home-manager/web/qutebrowser/default.nix +++ b/modules/home-manager/web/qutebrowser/default.nix @@ -6,35 +6,13 @@ in { options.modules.web.qutebrowser = { enable = mkEnableOption "enable Qutebrowser web browser"; - - enableNixGL = mkOption { - type = types.bool; - default = false; - description = "Use NixGL to start Qutebrowser"; - }; - }; config = mkIf cfg.enable { - xdg.desktopEntries."org.qutebrowser.qutebrowser" = mkIf cfg.enableNixGL { - name = "QuteBrowser NixGL Powered"; - - exec = "${pkgs.nixgl.nixGLMesa}/bin/nixGLMesa qutebrowser %u"; - icon = "qutebrowser"; - terminal = false; - type = "Application"; - startupNotify = true; - actions = { - "preference" = { - exec = "${pkgs.nixgl.nixGLMesa}/bin/nixGLMesa qutebrowser \"qute://settings\""; - name = "Preferences"; - }; - }; - }; programs.qutebrowser = { enable = true; + package = config.lib.nixGL.wrap pkgs.qutebrowser; loadAutoconfig = true; settings = { - qt.args = [ "autoplay-policy=user-gesture-required" "ignore-gpu-blocklist" diff --git a/modules/nixos/desktop/sway/default.nix b/modules/nixos/desktop/sway/default.nix index 5d65618..c7427a8 100644 --- a/modules/nixos/desktop/sway/default.nix +++ b/modules/nixos/desktop/sway/default.nix @@ -16,20 +16,5 @@ in alsa.support32Bit = true; pulse.enable = true; }; - xdg.portal = { - enable = true; - wlr.enable = true; - # gtk portal needed to make gtk apps happy - extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; - config = { - common = { - default = [ - "gtk" - ]; - "org.freedesktop.impl.portal.ScreenCast" = "wlr"; - "org.freedesktop.impl.portal.Screenshot" = "wlr"; - }; - }; - }; }; }