calcite: switch to greetd and gtklock

This commit is contained in:
xinyangli 2024-11-13 21:24:26 +08:00
parent f87136fc94
commit d4aaa6c4a3
Signed by: xin
SSH key fingerprint: SHA256:UU5pRTl7NiLFJbWJZa+snLylZSXIz5rgHmwjzv8v4oE
9 changed files with 261 additions and 48 deletions

View file

@ -36,6 +36,8 @@ in
home.packages = with pkgs; [
thunderbird
remmina
qq
wechat-uos
];
# Theme
@ -84,6 +86,7 @@ in
zellij = {
enable = true;
};
gui = {
niri.enable = true;
waybar.enable = true;

View file

@ -4,7 +4,9 @@
lib,
...
}:
let
inherit (lib) mkForce getExe;
in
{
imports = [
# Include the results of the hardware scan.
@ -14,7 +16,6 @@
];
commonSettings = {
auth.enable = true;
nix = {
enableMirrors = true;
signing.enable = true;
@ -43,7 +44,7 @@
# TPM2TOOLS_TCTI and TPM2_PKCS11_TCTI env variables
tctiEnvironment.enable = true;
};
services.gnome.gnome-keyring.enable = lib.mkForce false;
# services.gnome.gnome-keyring.enable = lib.mkForce false;
security.pam.services.login.enableGnomeKeyring = lib.mkForce false;
services.ssh-tpm-agent.enable = true;
@ -98,14 +99,43 @@
LC_TIME = "en_US.utf8";
};
services.displayManager = {
enable = true;
defaultSession = "niri";
};
# ====== GUI ======
programs.niri.enable = true;
environment.sessionVariables.NIXOS_OZONE_WL = "1";
security.pam.services.gtklock = { }; # Required by gtklock
services.xserver.displayManager.gdm.enable = true;
xdg.portal = {
enable = true;
extraPortals = [
pkgs.xdg-desktop-portal-gtk
pkgs.xdg-desktop-portal-gnome
];
configPackages = [ pkgs.niri ];
};
systemd.user.services.xdg-desktop-portal-gtk.after = [ "graphical-session.target" ];
services.greetd =
let
niri-login-config = pkgs.writeText "niri-login-config.kdl" ''
animations {
off
}
hotkey-overlay {
skip-at-startup
}
'';
in
{
enable = true;
vt = 1;
settings = {
default_session = {
command = "${pkgs.dbus}/bin/dbus-run-session -- ${getExe pkgs.niri} -c ${niri-login-config} -- ${getExe pkgs.greetd.gtkgreet} -l -c niri-session -s ${pkgs.magnetic-catppuccin-gtk}/share/themes/Catppuccin-GTK-Dark/gtk-3.0/gtk.css";
};
};
};
# Keyboard mapping on internal keyboard
services.keyd = {
@ -229,7 +259,6 @@
# IM
element-desktop
tdesktop
qq
# Password manager
bitwarden
@ -311,7 +340,6 @@
services.gvfs.enable = true;
services.flatpak.enable = true;
xdg.portal.enable = true;
# Fonts
fonts = {

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ config, pkgs, lib, ... }:
{
imports = [ ];
@ -10,7 +10,6 @@
dns = "systemd-resolved";
};
};
systemd.services.NetworkManager-wait-online.enable = false;
services.resolved = {
enable = true;
@ -25,6 +24,7 @@
services.dae.enable = true;
services.dae.configFile = "/var/lib/dae/config.dae";
systemd.services.dae.after = lib.mkIf (config.networking.networkmanager.enable) [ "NetworkManager-wait-online.service" ];
custom.sing-box = {
enable = false;
@ -46,12 +46,6 @@
# Use nftables to manager firewall
networking.nftables.enable = true;
# Add gsconnect, open firewall
programs.kdeconnect = {
enable = true;
package = pkgs.gnomeExtensions.gsconnect;
};
programs.wireshark = {
enable = true;
package = pkgs.wireshark-qt;

View file

@ -2,6 +2,7 @@
imports = [
./niri.nix
./fuzzel.nix
./gtklock.nix
./waybar.nix
];
}

View file

@ -1,4 +1,9 @@
{ config, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.custom-hm.gui.fuzzel;
@ -9,6 +14,27 @@ in
};
config = mkIf cfg.enable {
programs.fuzzel.enable = true;
programs.fuzzel = {
enable = true;
settings = {
main = {
fields = "filename,name,exec,generic";
y-margin = 30;
width = 40;
use-bold = true;
line-height = 30;
};
};
};
home.packages = with pkgs; [
networkmanager_dmenu
networkmanagerapplet
];
xdg.configFile."networkmanager-dmenu/config.ini".text = ''
[dmenu]
dmenu_command = fuzzel --dmenu
wifi_chars =
wifi_icons = 󰤯󰤟󰤢󰤥󰤨
'';
};
}

View file

@ -0,0 +1,119 @@
# modified from https://github.com/isabelroses/dotfiles/blob/2fd4d2d0cb8254cad5ce4b089d81114e1b88ad02/modules/extra/home-manager/gtklock.nix
{
lib,
pkgs,
config,
...
}:
let
cfg = config.custom-hm.gui.gtklock;
inherit (lib.modules) mkIf;
inherit (lib.options)
mkOption
mkEnableOption
mkPackageOption
literalExpression
;
inherit (lib.strings) optionalString concatStringsSep;
inherit (lib.lists) optionals;
inherit (lib.types)
oneOf
str
path
listOf
either
package
nullOr
attrs
;
inherit (lib.generators) toINI;
# the main config includes two very niche options: style (which takes a path) and modules, which takes a list of module paths
# concatted by ";"
# for type checking purposes, I prefer templating the main section of the config and let the user safely choose options
# extraConfig takes an attrset, and converts it to the correct INI format - it's mostly just strings and integers, so that's fine
baseConfig = ''
[main]
${optionalString (cfg.config.gtk-theme != "") "gtk-theme=${cfg.config.gtk-theme}"}
${optionalString (cfg.config.style != "") "style=${cfg.config.style}"}
${optionalString (cfg.config.modules != [ ]) "modules=${concatStringsSep ";" cfg.config.modules}"}
'';
finalConfig = baseConfig + optionals (cfg.extraConfig != null) (toINI { } cfg.extraConfig);
in
{
options.custom-hm.gui.gtklock = {
enable = mkEnableOption "GTK-based lockscreen for Wayland";
package = mkPackageOption pkgs "gtklock" { };
config = {
gtk-theme = mkOption {
type = str;
default = "";
description = ''
GTK theme to use for gtklock.
'';
example = "Adwaita-dark";
};
style = mkOption {
type = oneOf [
str
path
];
default = "";
description = ''
The css file to be used for gtklock.
'';
example = literalExpression ''
pkgs.writeText "gtklock-style.css" '''
window {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
'''
'';
};
modules = mkOption {
type = listOf (either package str);
default = [ ];
description = ''
A list of gtklock modulesto use. Can either be packages, absolute paths, or strings.
'';
example = literalExpression ''
[
"${pkgs.gtklock-powerbar-module.outPath}/lib/gtklock/powerbar-module.so"
"${pkgs.gtklock-playerctl-module.outPath}/lib/gtklock/playerctl-module.so"
];
'';
};
};
extraConfig = mkOption {
type = nullOr attrs;
default =
{
};
description = ''
Extra configuration to append to gtklock configuration file.
Mostly used for appending module configurations.
'';
example = literalExpression ''
countdown = {
countdown-position = "top-right";
justify = "right";
countdown = 20;
}
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."gtklock/config.ini".source = pkgs.writeText "gtklock-config.ini" finalConfig;
};
}

View file

@ -5,38 +5,55 @@
...
}:
let
inherit (lib) mkIf mkEnableOption;
inherit (lib) mkIf mkEnableOption getExe;
cfg = config.custom-hm.gui.niri;
wallpaper = pkgs.fetchurl {
url = "https://github.com/NixOS/nixos-artwork/blob/master/wallpapers/nixos-wallpaper-catppuccin-mocha.png?raw=true";
hash = "sha256-fmKFYw2gYAYFjOv4lr8IkXPtZfE1+88yKQ4vjEcax1s=";
};
xwayland-satellite = pkgs.xwayland-satellite.overrideAttrs (drv: rec {
src = pkgs.fetchFromGitHub {
owner = "Supreeeme";
repo = "xwayland-satellite";
rev = "3e6f892d20d918479e67d1e6c90c4be824a9d4ab";
hash = "sha256-W1UUok7DPi4IXCYtc273FbVH1ifuCIcl+oO6CDqt8Dk=";
};
cargoDeps = drv.cargoDeps.overrideAttrs (
lib.const {
name = "xwayland-satellite-vendor.tar.gz";
inherit src;
outputHash = "sha256-/nK4cVgelaMtpym18RYNafPUFnMOG4uHRpVO8bOS3ow=";
}
);
});
in
{
imports = [
./themes.nix
];
options.custom-hm.gui.niri = {
enable = mkEnableOption "niri";
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
xwayland-satellite
cosmic-files
];
home.pointerCursor = {
name = "Bibata-Modern-Ice";
size = 24;
package = pkgs.bibata-cursors;
gtk.enable = true;
};
gtk = {
enable = true;
theme = {
name = "Catppuccin-GTK-Dark";
package = pkgs.magnetic-catppuccin-gtk;
systemd.user.services.xwayland-satellite = {
Install = {
WantedBy = [ "graphical-session.target" ];
};
Unit = {
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${xwayland-satellite}/bin/xwayland-satellite";
Restart = "on-failure";
};
gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
};
services.network-manager-applet.enable = true;
systemd.user.services.swaybg = {
Install = {
@ -52,12 +69,21 @@ in
};
};
programs.swaylock = {
custom-hm.gui.gtklock = {
enable = true;
settings = {
show-failed-attempts = true;
daemonize = true;
scaling = "fill";
config = {
gtk-theme = "Catppuccin-GTK-Dark";
# style = pkgs.writeText "gtklock-style.css" ''
# window {
# background-size: cover;
# background-repeat: no-repeat;
# background-position: center;
# }
# '';
# modules = [
# "${pkgs.gtklock-playerctl-module}/lib/gtklock/playerctl-module.so"
# "${pkgs.gtklock-userinfo-module}/lib/gtklock/userinfo-module.so"
# ];
};
};
@ -67,6 +93,10 @@ in
swayidle = {
enable = true;
timeouts = [
# {
# timeout = 300;
# command = "/run/
# }
{
timeout = 900;
command = "/run/current-system/systemd/bin/systemctl suspend";
@ -75,7 +105,7 @@ in
events = [
{
event = "lock";
command = "${pkgs.swaylock}/bin/swaylock";
command = "${getExe pkgs.gtklock}";
}
{
event = "before-sleep";

View file

@ -0,0 +1,19 @@
{ config, pkgs, ... }:
{
config = {
home.pointerCursor = {
name = "Bibata-Modern-Ice";
size = 24;
package = pkgs.bibata-cursors;
gtk.enable = true;
};
gtk = {
enable = true;
theme = {
name = "Catppuccin-GTK-Dark";
package = pkgs.magnetic-catppuccin-gtk;
};
gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
};
};
}

View file

@ -162,12 +162,5 @@ in
};
systemd.enable = true;
};
systemd.user.targets.tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = [ "graphical-session-pre.target" ];
};
};
};
}