summaryrefslogtreecommitdiff
path: root/profiles/desktop.nix
blob: f84b2defa456e0916fdcc5f77cbb3b8192ddc53d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Shared desktop base: the niri graphical session, login manager, dark theme,
# audio, graphics, a browser, common desktop tools, and a font base. Imported by
# every graphical machine; per-host extras live in machines/<host>/desktop.nix.
#
# Deliberately username-agnostic (enzo uses hwebs, kusanagi uses henz), so this
# file sets NO users.users.*: shared desktop tools go to environment.systemPackages
# and per-user groups live in the machine files.
{ pkgs, ... }:

let
  greeter = pkgs.writeShellScript "tuigreet-fortune" ''
    exec ${pkgs.tuigreet}/bin/tuigreet \
      --time --remember \
      --greeting "$(${pkgs.fortune}/bin/fortune)" \
      --cmd niri-session
  '';
in
{
  # --- Session / login ---
  programs.niri.enable = true;
  programs.dconf.enable = true;

  # Tell the desktop it's in dark mode. Apps read light/dark from
  # xdg-desktop-portal's Settings interface (org.freedesktop.appearance
  # color-scheme). This dconf default is the value the portal serves.
  programs.dconf.profiles.user.databases = [
    {
      settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
    }
  ];

  # Serve color-scheme from the *gtk* portal backend, not gnome. The niri module
  # routes Settings to xdg-desktop-portal-gnome (its default), but that backend
  # relies on gnome-settings-daemon — absent under bare niri — so it reports
  # "no preference" and web content (Firefox's prefers-color-scheme) stays light
  # even though GTK chrome follows the dark GTK theme. xdg-desktop-portal-gtk
  # reads the dconf color-scheme above directly, so pinning Settings to it makes
  # the portal actually report dark and content follows. This key merges into
  # the niri module's xdg.portal.config.niri.
  xdg.portal = {
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
    config.niri."org.freedesktop.impl.portal.Settings" = "gtk";
  };

  # login screen
  services.greetd = {
    enable = true;
    settings.default_session = {
      command = "${greeter}";
      user = "greeter";
    };
  };
  # Let tuigreet write its cache (for --remember).
  systemd.services.greetd.serviceConfig = {
    Type = "idle";
    StandardInput = "tty";
    StandardOutput = "tty";
    StandardError = "journal"; # Better for debugging
    TTYReset = true;
    TTYVHangup = true;
    TTYVTDisallocate = true;
  };

  # --- Audio (playback base; kusanagi adds rtkit/jack/32-bit for pro audio) ---
  services.pulseaudio.enable = false;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    pulse.enable = true;
  };

  # --- Graphics ---
  hardware.graphics.enable = true;

  # --- GPG agent (kusanagi adds enableSSHSupport) ---
  programs.gnupg.agent.enable = true;

  # --- Firefox: blank home/new-tab and no bookmarks toolbar, as an enterprise
  # policy (no profile to manage). Dark theme is not configured here — it comes
  # from the portal above, which Firefox honors for both chrome and web content.
  programs.firefox = {
    enable = true;
    # Let Firefox reach KeePassXC's browser-integration proxy. This installs the
    # native-messaging manifest system-wide; the matching toggle is enabled in
    # the app via the stowed keepassxc.ini (Settings → Browser Integration).
    nativeMessagingHosts.packages = [ pkgs.keepassxc ];
    preferencesStatus = "default";
    preferences = {
      "browser.startup.homepage" = "about:blank";
      "browser.startup.page" = 0; # 0 = blank on startup
      "browser.newtabpage.enabled" = false;
      "browser.toolbars.bookmarks.visibility" = "never";
      # Silently deny geolocation instead of prompting ("Website would like
      # your location"). 2 = block, 0 = ask (default), 1 = allow. Per-site
      # exceptions still override this (padlock icon → Location → Allow).
      "permissions.default.geo" = 2;
      # Likewise silently deny "Website would like to send notifications".
      "permissions.default.desktop-notification" = 2;
    };
    # Note: Firefox View ("View recent browsing across windows and devices")
    # can't be disabled via pref or policy on modern Firefox — the old
    # browser.tabs.firefox-view pref was removed in Firefox 123. Remove its
    # toolbar button manually (right-click the icon → Remove from Toolbar);
    # the choice persists in the profile.

    # Restrict the available search engines to exactly these five, in this
    # order, with DuckDuckGo as default. DuckDuckGo/Google/Wikipedia/eBay are
    # built-in; only Searx is added. Bing/Amazon/Perplexity (the other
    # built-ins) are removed. SearchEngines works on regular Firefox as of v139.
    policies.SearchEngines = {
      Default = "DuckDuckGo";
      Remove = [ "Bing" "Amazon.com" "Perplexity" ];
      Add = [
        {
          Name = "Searx";
          URLTemplate = "https://searx.be/search?q={searchTerms}";
          Method = "GET";
          IconURL = "https://searx.be/favicon.ico";
          Alias = "searx";
        }
      ];
      # Names must match the engines' internal names. Wikipedia's built-in
      # engine is named "Wikipedia (en)" in the en-US locale.
      Order = [ "DuckDuckGo" "Searx" "Wikipedia (en)" "eBay" "Google" ];
    };

    # KeePassXC-Browser: autofill + passkeys, talking to the local app over the
    # native-messaging host above. normal_installed = installed but the user can
    # still disable/remove it (force_installed would lock it in).
    policies.ExtensionSettings = {
      "keepassxc-browser@keepassxc.org" = {
        install_url = "https://addons.mozilla.org/firefox/downloads/latest/keepassxc-browser/latest.xpi";
        installation_mode = "normal_installed";
      };
    };
  };

  # --- Common desktop tools (system-wide to stay username-agnostic) ---
  environment.systemPackages = with pkgs; [
    ghostty # terminal — required to actually use the GUI
    fuzzel # launcher
    swaybg # wallpaper
    xwayland-satellite # run X11 apps under niri
    mako # notifications
    libnotify # notify-send
    gnupg # gpg
    pinentry-gnome3 # passphrase prompt for the gpg agent
    keepassxc # offline password manager + software passkeys
  ];

  # --- Fonts (base) ---
  # Common packages + fontconfig; each machine sets its own defaultFonts (the
  # monospace family differs) and any extra font packages.
  fonts = {
    enableDefaultPackages = true;
    fontconfig.enable = true;
    packages = with pkgs; [
      noto-fonts
      nerd-fonts.symbols-only
      adwaita-fonts
    ];
  };
}