greenhouse

kore

my public infrastructure monorepo

git clone [email protected]:kore.git

kore / nixos / roles / desktop.nix116 lines · 2912B · raw

1{ outputs, config, pkgs, lib, ... }:
2
3let
4  roleName = "desktop";
5  roleEnabled = lib.elem roleName config.kore.currentHost.roles;
6in {
7  config = lib.mkMerge [{} (lib.mkIf roleEnabled {
8    xdg.portal = {
9      enable = true;
10      extraPortals = [ pkgs.xdg-desktop-portal-wlr ];
11      configPackages = [ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr ];
12
13      wlr.enable = true;
14
15      config.common = {
16        default = [ "wlr" ];
17      };
18    };
19
20    system.activationScripts.persistent-dirs.text =
21      let
22        mkHomePersist = user: lib.optionalString user.createHome ''
23          mkdir -p /persist/${user.home}
24          chown ${user.name}:${user.group} /persist/${user.home}
25          chmod ${user.homeMode} /persist/${user.home}
26        '';
27        users = lib.attrValues config.users.users;
28      in
29        lib.concatLines (map mkHomePersist users);
30
31    fonts = {
32      enableDefaultPackages = false;
33
34      packages = with pkgs; [
35        noto-fonts
36        noto-fonts-cjk-sans
37        noto-fonts-cjk-serif
38        noto-fonts-color-emoji
39
40        #(nerdfonts.override { fonts = [ "ComicShannsMono" ]; })
41        nerd-fonts.comic-shanns-mono
42      ];
43
44      fontconfig = {
45        hinting.autohint = true;
46
47        defaultFonts = {
48          serif = [ "Noto Serif" "Noto Color Emoji" ];
49          sansSerif = [ "Noto Sans" "Noto Color Emoji" ];
50          monospace = [ "ComicShannsMono Nerd Font" "Noto Color Emoji" ];
51          emoji = [ "Noto Color Emoji" ];
52        };
53      };
54    };
55
56    services = {
57      udisks2.enable = true;
58
59      pipewire = {
60        enable = true;
61
62        alsa.enable = true;
63        alsa.support32Bit = true;
64
65        pulse.enable = true;
66        jack.enable = true;
67
68        wireplumber = {
69          enable = true;
70
71          # https://github.com/NixOS/nixpkgs/pull/292115
72          extraConfig."alsa-lowlatency" = {
73            "monitor.alsa.rules" = [{
74              matches = [{ "node.name" = "~alsa_output.*"; }];
75
76              actions.update-props = {
77                "audio.format" = "S32LE";
78                "audio.rate" = "96000";
79                "api.alsa.period-size" = 2;
80              };
81            }];
82          };
83        };
84
85        extraConfig.pipewire."92-low-latency" = {
86          context = {
87            properties.default.clock = {
88              rate = 48000;
89              quantum = 64;
90            };
91
92            modules = [{
93              name = "libpipewire-module-protocol-pulse";
94
95              args.pulse = {
96                min = {
97                  req = "64/48000";
98                  quantum = "64/48000";
99                  frag = "64/48000";
100                };
101
102                default.req = "64/48000";
103              };
104            }];
105          };
106          
107          stream.properties = {
108            node.latency = "64/48000";
109            resample.quality = 1;
110          };
111        };
112      };
113    };
114  })];
115}
116