summaryrefslogtreecommitdiff
path: root/nixos/configuration.nix
blob: ef7adc9020a975d4642b83bce69899409b062419 (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
{ config, pkgs, inputs, ... }:

{
  imports = [
    ./hardware-configuration.nix
    inputs.noctalia-greeter.nixosModules.default
  ];

  # Custom EDID firmware loading for monitor
  hardware.firmware = [
    (pkgs.runCommand "custom-edid" {} ''
      mkdir -p $out/lib/firmware/edid
      cp ${./mi_edid.bin} $out/lib/firmware/edid/mi_edid.bin
    '')
  ];

  fileSystems."/mnt/giga" = {
    device = "/dev/disk/by-uuid/bfed3a37-05e1-465b-a4b7-d74cd31bf937";
    fsType = "ext4";
    options = [ "defaults" "user" "rw" ];
  };

  # --- Mullvad VPN daemon ---
  services.mullvad-vpn = {
    enable = true;
    package = pkgs.mullvad-vpn;
  };

  services.resolved = {
    enable = true;
    dnssec = "true";
    dnsovertls = "true";
    domains = [ "~." ];
    settings = {
      Resolve = {
        DNS = "194.242.2.4#base.dns.mullvad.net 2a07:e340::4#base.dns.mullvad.net";
        FallbackDNS = "";
      };
    };
  };

  # Restrict systemd log size and retention
  services.journald.extraConfig = ''
    SystemMaxUse=50M
    MaxRetentionSec=1month
  '';

  # --- AUTOSTART USER SERVICES ---
  systemd.user.services.swingmusic = {
    description = "Swing Music Local Server";
    wantedBy = [ "graphical-session.target" ];
    after = [ "graphical-session.target" ];
    serviceConfig = {
      ExecStart = "/home/seraphim/.swingmusic/swingmusic";
      Restart = "on-failure";
      WorkingDirectory = "/home/seraphim";
      # --- Systemd Hardening Options ---
      NoNewPrivileges = true;
      PrivateTmp = true;
      ProtectSystem = "strict";
      ProtectHome = "false";    
      RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
    };
  };

  # --- MPD-MPRIS (Для работы Waybar) ---
  systemd.user.services.mpd-mpris = {
    description = "MPD MPRIS Service for Waybar";
    wantedBy = [ "default.target" ];
    after = [ "graphical-session.target" ];
    serviceConfig = {
      ExecStart = "${pkgs.mpd-mpris}/bin/mpd-mpris -network tcp -host 127.0.0.1 -port 6600";
      Restart = "on-failure";
    };
  };

  systemd.user.services.niri.enableDefaultPath = false;
  qt = {
    enable = true;
    platformTheme = "qt5ct";
    style = "breeze";
  };

  boot.kernelParams = [
    "drm.edid_firmware=DP-1:edid/mi_edid.bin"
    "video=DP-1:2560x1440@180"
  ];

  # Bootloader configuration (systemd-boot)
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  # --- NETWORK AND ENCRYPTED DNS ---
  networking.hostName = "opus";
  networking.networkmanager.enable = true;

  # --- TIMEZONE AND LOCALIZATION ---
  time.timeZone = "Etc/GMT-7";
  i18n.defaultLocale = "en_US.UTF-8";

  # Forcing all extra locales to English to clear the Perl warnings
  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_US.UTF-8";
    LC_IDENTIFICATION = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_NAME = "en_US.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };

  # Allow unfree packages (NVIDIA, Steam, etc.)
  nixpkgs.config.allowUnfree = true;

  # Experimental Nix features
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # Dynamic binary execution & FHS environment compatibility
  programs.nix-ld.enable = true;
  services.envfs.enable = true;

  # Shell and CLI enhancements
  programs.starship.enable = true;

  # Throne configuration
  programs.throne = {
    enable = true;
    tunMode.enable = true;
  };

  # Privilege elevation (doas)
  security.doas.enable = true;
  security.doas.extraRules = [
    {
      users = [ "seraphim" ];
      keepEnv = true;
      persist = true;
    }
  ];

  # --- GRAPHICS AND NVIDIA ---
  hardware.graphics.enable = true;
  hardware.graphics.enable32Bit = true;
  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement.enable = false;
    open = false;
    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.latest;
  };

  # --- NIRI WAYLAND COMPOSITOR ---
  programs.niri.enable = true;

  # --- NOCTALIA GREETER ---
  programs.noctalia-greeter = {
    enable = true;
    settings = {
      cursor = {
        theme = "Bibata-Modern-Ice";
        size = 24;
        path = "${pkgs.bibata-cursors}/share/icons";
       };
     };
   };

  # --- SYSTEM SERVICES FOR FILE MANAGEMENT ---
  services.gvfs.enable = true;
  services.tumbler.enable = true;
  services.gnome.gnome-keyring.enable = true;
  programs.dconf.enable = true;

  # --- XDG DESKTOP PORTALS (NIRI / WAYLAND) ---
  xdg.portal = {
    enable = true;
    extraPortals = [
      pkgs.xdg-desktop-portal-gnome
      pkgs.xdg-desktop-portal-gtk
    ];
  };

  # --- AUDIO (PIPEWIRE) ---
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };
  fonts.fontconfig.enable = true;

  environment.variables = {
    SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt";
    NIX_SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt";
  };

  # --- GAMING (STEAM) ---
  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true;
    dedicatedServer.openFirewall = true;
  };

  # --- ENVIRONMENT VARIABLES FOR WAYLAND + NVIDIA ---
  environment.sessionVariables = {
    LIBVA_DRIVER_NAME = "nvidia";
    XCURSOR_THEME = "Bibata-Modern-Ice";
    XCURSOR_SIZE = "20";
    # GBM_BACKEND = "nvidia-drm";
    __GLX_VENDOR_LIBRARY_NAME = "nvidia";
    NIXOS_OZONE_WL = "1";
    CC = "gcc";
    ELECTRON_OZONE_PLATFORM_HINT = "auto";
    GSK_RENDERER = "ngl";
    QT_QPA_PLATFORM = "wayland;xcb";
    QT_ENABLE_HIGHDPI_SCALING = "1";
    QT_AUTO_SCREEN_SCALE_FACTOR = "1";
    QT_SCREEN_SCALE_FACTORS = "1.5";
  };

  # --- FONTS ---
  fonts.packages = with pkgs;
  [
    font-awesome
    nerd-fonts.jetbrains-mono
    nerd-fonts.symbols-only
    jetbrains-mono
  ];

  # --- USER CONFIGURATION ---
  users.users."seraphim" = {
    isNormalUser = true;
    description = "seraphim";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [];
  };

  programs.fish = {
    enable = true;
    shellAliases = {
      ls = "eza -al --icons=auto";
      ll = "eza -al --icons=auto";
    };
  };

# --- MPD SERVER ---
  services.mpd = {
    enable = true;
    user = "seraphim";
    musicDirectory = "/mnt/giga/music";
    network.listenAddress = "any";
    network.port = 6600;
    
    settings = {
      auto_update = "yes";
      
      audio_output = [
        {
          type = "pulse";              # Возвращаем pulse
          name = "PipeWire Output";
          mixer_type = "hardware";     # Моментальная регулировка потока!
        }
      ];
    };
  };

  # Разрешаем системному MPD видеть звук пользователя seraphim
  systemd.services.mpd.environment = {
      XDG_RUNTIME_DIR = "/run/user/1000"; # 1000 — это ID твоего пользователя
  };

 # --- SYSTEM PACKAGES ---
  environment.systemPackages = with pkgs;
  [
    inputs.noctalia.packages.${pkgs.stdenv.hostPlatform.system}.default
    (pkgs.btop.override { cudaSupport = true; })
    
    # Terminals & Shell Utilities
    fastfetch
    fzf
    ghostty
    kitty
    ghfetch
    cacert
    
    # Music
    pkgs.mpd
    pkgs.rmpc
    mpc
    playerctl
    pkgs.mpd-mpris # <-- ДОБАВЛЕНО СЮДА
    
    # Text Editors
    micro
    neovim
    (pkgs.emacs-pgtk.override {
      withNativeCompilation = true;
    })
    # File Managers & Archiving
    nautilus
    loupe
    sushi
    file-roller
    yazi
    kdePackages.ark
    kdePackages.qt6ct
    stow
    # Utils
    cryptsetup
    util-linux
    eza
    pkgs.yt-dlp
    pkgs.caligula
    
    # GStreamer codecs
    gst_all_1.gst-plugins-base
    gst_all_1.gst-plugins-good
    gst_all_1.gst-plugins-bad
    gst_all_1.gst-plugins-ugly

    # Wayland & Niri Desktop Tools
    cliphist
    bibata-cursors
    fuzzel
    grim
    hyprpolkitagent
    noctalia-shell
    slurp
    wl-clipboard
    wtype
    xwayland-satellite

    # Audio & Brightness Controls
    brightnessctl
    pamixer
    pavucontrol

    # Desktop Applications
    keepassxc
    telegram-desktop
    vesktop
    nvidia-vaapi-driver
    pkgs.opencode
    pkgs.claude-code
    
    # Software Development & Toolchains
    black
    cargo
    clang
    clippy
    git
    pyright
    python3
    rust-analyzer
    rustc
    gnumake
    tree-sitter
    nodejs
  ];

  system.stateVersion = "26.05";
}