[nixos-configs-tcu] Add platform compatibility guards to cross-platform roles #25

Open
johno wants to merge 1 commits from bead/nixos-configs-tcu into main
5 changed files with 127 additions and 106 deletions
Showing only changes of commit b9f56ff57d - Show all commits

View File

@@ -4,6 +4,7 @@ with lib;
let let
cfg = config.home.roles.communication; cfg = config.home.roles.communication;
isLinux = pkgs.stdenv.isLinux;
in in
{ {
options.home.roles.communication = { options.home.roles.communication = {
@@ -12,14 +13,14 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ home.packages = [
# Communication apps # For logging back into google chat (cross-platform)
globalInputs.google-cookie-retrieval.packages.${system}.default
] ++ optionals isLinux [
# Linux-only communication apps (Electron apps don't build on Darwin)
pkgs.element-desktop pkgs.element-desktop
# Re-enabled in 25.11 after security issues were resolved # Re-enabled in 25.11 after security issues were resolved
pkgs.fluffychat pkgs.fluffychat
pkgs.nextcloud-talk-desktop pkgs.nextcloud-talk-desktop
# For logging back into google chat
globalInputs.google-cookie-retrieval.packages.${system}.default
]; ];
}; };
} }

View File

@@ -4,6 +4,7 @@ with lib;
let let
cfg = config.home.roles.desktop; cfg = config.home.roles.desktop;
isLinux = pkgs.stdenv.isLinux;
in in
{ {
options.home.roles.desktop = { options.home.roles.desktop = {
@@ -12,61 +13,63 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
# Desktop applications # Cross-platform desktop applications
bitwarden-desktop bitwarden-desktop
dunst
keepassxc keepassxc
xdg-utils # XDG utilities for opening files/URLs with default applications
] ++ optionals isLinux [
# Linux-only desktop applications
dunst
unstable.ghostty unstable.ghostty
# Desktop utilities # Linux-only desktop utilities
feh # Image viewer and wallpaper setter for X11 feh # Image viewer and wallpaper setter for X11
rofi # Application launcher for X11 rofi # Application launcher for X11
solaar # Logitech management software solaar # Logitech management software
waybar waybar
wofi # Application launcher for Wayland wofi # Application launcher for Wayland
xdg-utils # XDG utilities for opening files/URLs with default applications
# Linux-only system utilities with GUI components
# System utilities with GUI components
(snapcast.override { pulseaudioSupport = true; }) (snapcast.override { pulseaudioSupport = true; })
# KDE tiling window management # KDE tiling window management (Linux-only)
kdePackages.krohnkite # Dynamic tiling extension for KWin 6 kdePackages.krohnkite # Dynamic tiling extension for KWin 6
# KDE PIM applications for email, calendar, and contacts # KDE PIM applications for email, calendar, and contacts (Linux-only)
kdePackages.kmail kdePackages.kmail
kdePackages.kmail-account-wizard kdePackages.kmail-account-wizard
kdePackages.kmailtransport kdePackages.kmailtransport
kdePackages.korganizer kdePackages.korganizer
kdePackages.kaddressbook kdePackages.kaddressbook
kdePackages.kontact kdePackages.kontact
# KDE System components needed for proper integration # KDE System components needed for proper integration (Linux-only)
kdePackages.kded kdePackages.kded
kdePackages.systemsettings kdePackages.systemsettings
kdePackages.kmenuedit kdePackages.kmenuedit
# Desktop menu support # Desktop menu support (Linux-only)
kdePackages.plasma-desktop # Contains applications.menu kdePackages.plasma-desktop # Contains applications.menu
# KDE Online Accounts support # KDE Online Accounts support (Linux-only)
kdePackages.kaccounts-integration kdePackages.kaccounts-integration
kdePackages.kaccounts-providers kdePackages.kaccounts-providers
kdePackages.signond kdePackages.signond
# KDE Mapping # KDE Mapping (Linux-only)
kdePackages.marble # Virtual globe and world atlas kdePackages.marble # Virtual globe and world atlas
# KDE Productivity # KDE Productivity (Linux-only)
kdePackages.kate # Advanced text editor with syntax highlighting kdePackages.kate # Advanced text editor with syntax highlighting
kdePackages.okular # Universal document viewer (PDF, ePub, etc.) kdePackages.okular # Universal document viewer (PDF, ePub, etc.)
kdePackages.spectacle # Screenshot capture utility kdePackages.spectacle # Screenshot capture utility
kdePackages.filelight # Visual disk usage analyzer kdePackages.filelight # Visual disk usage analyzer
# KDE Multimedia # KDE Multimedia (Linux-only)
kdePackages.gwenview # Image viewer and basic editor kdePackages.gwenview # Image viewer and basic editor
kdePackages.elisa # Music player kdePackages.elisa # Music player
# KDE System Utilities # KDE System Utilities (Linux-only)
kdePackages.ark # Archive manager (zip, tar, 7z, etc.) kdePackages.ark # Archive manager (zip, tar, 7z, etc.)
kdePackages.yakuake # Drop-down terminal emulator kdePackages.yakuake # Drop-down terminal emulator
]; ];
@@ -77,61 +80,66 @@ in
programs.spotify-player.enable = true; programs.spotify-player.enable = true;
services.gnome-keyring = { # Linux-only: GNOME keyring service
services.gnome-keyring = mkIf isLinux {
enable = true; enable = true;
}; };
# rbw vault unlock on login and resume from suspend # Linux-only: systemd user services for rbw vault unlock
systemd.user.services.rbw-unlock-on-login = { systemd.user.services = mkIf isLinux {
Unit = { # rbw vault unlock on login
Description = "Unlock rbw vault at login"; rbw-unlock-on-login = {
After = [ "graphical-session.target" ]; Unit = {
Description = "Unlock rbw vault at login";
After = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.rbw}/bin/rbw unlock";
Environment = "RBW_AGENT=${pkgs.rbw}/bin/rbw-agent";
# KillMode = "process" prevents systemd from killing the rbw-agent daemon
# when this oneshot service completes. The agent is spawned by rbw unlock
# and needs to persist after the service exits.
KillMode = "process";
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
}; };
Service = {
Type = "oneshot"; # rbw vault unlock on resume from suspend
ExecStart = "${pkgs.rbw}/bin/rbw unlock"; rbw-unlock-on-resume = {
Environment = "RBW_AGENT=${pkgs.rbw}/bin/rbw-agent"; Unit = {
# KillMode = "process" prevents systemd from killing the rbw-agent daemon Description = "Unlock rbw vault after resume from suspend";
# when this oneshot service completes. The agent is spawned by rbw unlock After = [ "suspend.target" ];
# and needs to persist after the service exits. };
KillMode = "process"; Service = {
}; Type = "oneshot";
Install = { ExecStart = "${pkgs.rbw}/bin/rbw unlock";
WantedBy = [ "graphical-session.target" ]; Environment = "RBW_AGENT=${pkgs.rbw}/bin/rbw-agent";
# KillMode = "process" prevents systemd from killing the rbw-agent daemon
# when this oneshot service completes. The agent is spawned by rbw unlock
# and needs to persist after the service exits.
KillMode = "process";
};
Install = {
WantedBy = [ "suspend.target" ];
};
}; };
}; };
systemd.user.services.rbw-unlock-on-resume = { # Linux-only: KDE environment variables for proper integration
Unit = { home.sessionVariables = mkIf isLinux {
Description = "Unlock rbw vault after resume from suspend";
After = [ "suspend.target" ];
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.rbw}/bin/rbw unlock";
Environment = "RBW_AGENT=${pkgs.rbw}/bin/rbw-agent";
# KillMode = "process" prevents systemd from killing the rbw-agent daemon
# when this oneshot service completes. The agent is spawned by rbw unlock
# and needs to persist after the service exits.
KillMode = "process";
};
Install = {
WantedBy = [ "suspend.target" ];
};
};
# KDE environment variables for proper integration
home.sessionVariables = {
QT_QPA_PLATFORMTHEME = "kde"; QT_QPA_PLATFORMTHEME = "kde";
KDE_SESSION_VERSION = "6"; KDE_SESSION_VERSION = "6";
}; };
xdg = { xdg = {
enable = true; enable = true;
# Ensure desktop files are made available for discovery # Ensure desktop files are made available for discovery
desktopEntries = {}; # This creates the desktop files directory structure desktopEntries = {}; # This creates the desktop files directory structure
mimeApps = { mimeApps = {
enable = true; enable = true;
associations.added = { associations.added = {
@@ -141,13 +149,14 @@ in
"x-scheme-handler/https" = "firefox.desktop"; "x-scheme-handler/https" = "firefox.desktop";
}; };
defaultApplications = { defaultApplications = {
# Web browsers # Web browsers (cross-platform)
"text/html" = "firefox.desktop"; "text/html" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop"; "x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop"; "x-scheme-handler/https" = "firefox.desktop";
"x-scheme-handler/about" = "firefox.desktop"; "x-scheme-handler/about" = "firefox.desktop";
"x-scheme-handler/unknown" = "firefox.desktop"; "x-scheme-handler/unknown" = "firefox.desktop";
} // optionalAttrs isLinux {
# Linux-only: KDE application associations
# Documents # Documents
"application/pdf" = "okular.desktop"; "application/pdf" = "okular.desktop";
"text/plain" = "kate.desktop"; "text/plain" = "kate.desktop";
@@ -155,7 +164,7 @@ in
"text/x-c" = "kate.desktop"; "text/x-c" = "kate.desktop";
"text/x-python" = "kate.desktop"; "text/x-python" = "kate.desktop";
"application/x-shellscript" = "kate.desktop"; "application/x-shellscript" = "kate.desktop";
# Images # Images
"image/png" = "gwenview.desktop"; "image/png" = "gwenview.desktop";
"image/jpeg" = "gwenview.desktop"; "image/jpeg" = "gwenview.desktop";
@@ -164,25 +173,25 @@ in
"image/bmp" = "gwenview.desktop"; "image/bmp" = "gwenview.desktop";
"image/tiff" = "gwenview.desktop"; "image/tiff" = "gwenview.desktop";
"image/webp" = "gwenview.desktop"; "image/webp" = "gwenview.desktop";
# Archives # Archives
"application/zip" = "ark.desktop"; "application/zip" = "ark.desktop";
"application/x-tar" = "ark.desktop"; "application/x-tar" = "ark.desktop";
"application/x-compressed-tar" = "ark.desktop"; "application/x-compressed-tar" = "ark.desktop";
"application/x-7z-compressed" = "ark.desktop"; "application/x-7z-compressed" = "ark.desktop";
"application/x-rar" = "ark.desktop"; "application/x-rar" = "ark.desktop";
# Audio # Audio
"audio/mpeg" = "elisa.desktop"; "audio/mpeg" = "elisa.desktop";
"audio/mp4" = "elisa.desktop"; "audio/mp4" = "elisa.desktop";
"audio/flac" = "elisa.desktop"; "audio/flac" = "elisa.desktop";
"audio/ogg" = "elisa.desktop"; "audio/ogg" = "elisa.desktop";
"audio/wav" = "elisa.desktop"; "audio/wav" = "elisa.desktop";
# Email # Email
"message/rfc822" = "kmail.desktop"; "message/rfc822" = "kmail.desktop";
"x-scheme-handler/mailto" = "kmail.desktop"; "x-scheme-handler/mailto" = "kmail.desktop";
# Calendar # Calendar
"text/calendar" = "korganizer.desktop"; "text/calendar" = "korganizer.desktop";
"application/x-vnd.akonadi.calendar.event" = "korganizer.desktop"; "application/x-vnd.akonadi.calendar.event" = "korganizer.desktop";
@@ -190,9 +199,11 @@ in
}; };
}; };
# Fix for KDE applications.menu file issue on Plasma 6 # Linux-only: Fix for KDE applications.menu file issue on Plasma 6
# KDE still looks for applications.menu but Plasma 6 renamed it to plasma-applications.menu # KDE still looks for applications.menu but Plasma 6 renamed it to plasma-applications.menu
xdg.configFile."menus/applications.menu".source = "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu"; xdg.configFile."menus/applications.menu" = mkIf isLinux {
source = "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";
};
# Note: modules must be imported at top-level home config # Note: modules must be imported at top-level home config
}; };

View File

@@ -4,6 +4,7 @@ with lib;
let let
cfg = config.home.roles.email; cfg = config.home.roles.email;
isLinux = pkgs.stdenv.isLinux;
in in
{ {
options.home.roles.email = { options.home.roles.email = {
@@ -89,34 +90,38 @@ in
account default : proton account default : proton
''; '';
# Systemd service for mail sync # Linux-only: Systemd service for mail sync (Darwin uses launchd instead)
systemd.user.services.mbsync = { systemd.user.services = mkIf isLinux {
Unit = { mbsync = {
Description = "Mailbox synchronization service"; Unit = {
After = [ "network-online.target" ]; Description = "Mailbox synchronization service";
Wants = [ "network-online.target" ]; After = [ "network-online.target" ];
}; Wants = [ "network-online.target" ];
Service = { };
Type = "oneshot"; Service = {
ExecStart = "${pkgs.bash}/bin/bash -c 'mkdir -p ~/Mail && ${pkgs.isync}/bin/mbsync -a && (${pkgs.mu}/bin/mu info >/dev/null 2>&1 || ${pkgs.mu}/bin/mu init --maildir ~/Mail --personal-address=john@ogle.fyi) && ${pkgs.mu}/bin/mu index'"; Type = "oneshot";
Environment = "PATH=${pkgs.rbw}/bin:${pkgs.coreutils}/bin"; ExecStart = "${pkgs.bash}/bin/bash -c 'mkdir -p ~/Mail && ${pkgs.isync}/bin/mbsync -a && (${pkgs.mu}/bin/mu info >/dev/null 2>&1 || ${pkgs.mu}/bin/mu init --maildir ~/Mail --personal-address=john@ogle.fyi) && ${pkgs.mu}/bin/mu index'";
StandardOutput = "journal"; Environment = "PATH=${pkgs.rbw}/bin:${pkgs.coreutils}/bin";
StandardError = "journal"; StandardOutput = "journal";
StandardError = "journal";
};
}; };
}; };
# Systemd timer for automatic sync # Linux-only: Systemd timer for automatic sync
systemd.user.timers.mbsync = { systemd.user.timers = mkIf isLinux {
Unit = { mbsync = {
Description = "Mailbox synchronization timer"; Unit = {
}; Description = "Mailbox synchronization timer";
Timer = { };
OnBootSec = "2min"; Timer = {
OnUnitActiveSec = "5min"; OnBootSec = "2min";
Unit = "mbsync.service"; OnUnitActiveSec = "5min";
}; Unit = "mbsync.service";
Install = { };
WantedBy = [ "timers.target" ]; Install = {
WantedBy = [ "timers.target" ];
};
}; };
}; };
}; };

View File

@@ -4,13 +4,15 @@ with lib;
let let
cfg = config.home.roles.kdeconnect; cfg = config.home.roles.kdeconnect;
isLinux = pkgs.stdenv.isLinux;
in in
{ {
options.home.roles.kdeconnect = { options.home.roles.kdeconnect = {
enable = mkEnableOption "Enable KDE Connect for device integration"; enable = mkEnableOption "Enable KDE Connect for device integration";
}; };
config = mkIf cfg.enable { # KDE Connect services are Linux-only (requires D-Bus and systemd)
config = mkIf (cfg.enable && isLinux) {
services.kdeconnect = { services.kdeconnect = {
enable = true; enable = true;
indicator = true; indicator = true;

View File

@@ -4,6 +4,7 @@ with lib;
let let
cfg = config.home.roles.sync; cfg = config.home.roles.sync;
isLinux = pkgs.stdenv.isLinux;
in in
{ {
options.home.roles.sync = { options.home.roles.sync = {
@@ -11,9 +12,10 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ # Linux-only: syncthingtray requires system tray support
home.packages = optionals isLinux (with pkgs; [
syncthingtray syncthingtray
]; ]);
services.syncthing = { services.syncthing = {
enable = true; enable = true;