summaryrefslogtreecommitdiff
path: root/mun.nix
blob: 6fe695eb6ac3a582f86c312aa76c43b24ecbfd19 (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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
{ config, lib, pkgs, ... }:

let
  get_spotify_status = pkgs.writeShellScript "get_spotify_status.sh" ''
    #!/bin/bash
    PARENT_BAR="example"
    PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
    PLAYER="playerctld"
    FORMAT="{{ title }} - {{ artist }}"

    update_hooks() {
      while IFS= read -r id; do
        polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1
      done < <(echo "$1")
    }

    PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
    EXIT_CODE=$?

    if [ $EXIT_CODE -eq 0 ]; then
      STATUS=$PLAYERCTL_STATUS
    else
      STATUS="No player is running"
    fi

    if [ "$1" == "--status" ]; then
      echo "$STATUS"
    else
      if [ "$STATUS" = "Stopped" ]; then
        echo "Music Stopped"
      elif [ "$STATUS" = "Paused" ]; then
        update_hooks "$PARENT_BAR_PID" 2
        playerctl --player=$PLAYER metadata --format "$FORMAT"
      elif [ "$STATUS" = "No player is running" ]; then
        echo "Music Off"
      else
        update_hooks "$PARENT_BAR_PID" 1
        playerctl --player=$PLAYER metadata --format "$FORMAT"
      fi
    fi
  '';

  hidePolybarInFullscreen = pkgs.writeShellScript "hidePolybarInFullscreen.sh" ''
    #!/usr/bin/env bash
    sleep 1
    i3-msg -t subscribe -m '[ "window" ]' | while read -r event; do
      if echo "$event" | grep -q '"fullscreen_mode":[[:space:]]*1'; then
        polybar-msg cmd hide
      elif echo "$event" | grep -q '"fullscreen_mode":[[:space:]]*0'; then
        polybar-msg cmd show
      fi
    done
  '';
in
{
  home = {
    username = "mun";
    homeDirectory = "/home/mun";
    stateVersion = "25.11";

    packages = with pkgs; [
      pay-respects
      zathura
      ripgrep
      fd
      git
      lazygit
      tree-sitter
      #gcr
    ];

    sessionVariables = {
      EDITOR = "nvim";
      VISUAL = "nvim";
    };
  };

  gtk.cursorTheme = {
    package = pkgs.rose-pine-cursor;
    name = "RosePine";
  };

  xdg = {
    enable = true;

    mimeApps = {
      enable = true;
      defaultApplications = {
        "text/plain" = [ "nvim.desktop" ];
        "text/markdown" = [ "nvim.desktop" ];
        "text/x-markdown" = [ "nvim.desktop" ];
      };
    };
  };

  programs = {
    ssh = {
      enable = true;
      forwardAgent = true;
      addKeysToAgent = "yes";
    };

    zsh = {
      enable = true;
      syntaxHighlighting.enable = true;

      shellAliases = {
        ll = "ls -l";
        rebuild = "sudo nixos-rebuild switch";
        edit = "sudo vi /etc/nixos/configuration.nix";
      };

      history.size = 10000;

      oh-my-zsh = {
        enable = true;
        plugins = [ "git" ];
        theme = "simple";
      };

      initContent = ''
        export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/ssh-agent.socket
        fastfetch
      '';
    };

    rofi = {
      enable = true;
      location = "center";
      cycle = true;
      theme = "purple";
      terminal = "${pkgs.kitty}/bin/kitty";
      modes = [ "drun" "ssh" "emoji" "calc" ];
      plugins = with pkgs; [ rofi-emoji rofi-calc ];
    };

    nnn = {
      enable = true;
      package = pkgs.nnn.override { withNerdIcons = true; };
    };

    neovim = {
      enable = true;
      defaultEditor = true;
      viAlias = true;
      vimAlias = true;
      withNodeJs = true;

      # +ANT FIX 
      plugins = []; # disable HM plugin processing

      extraLuaConfig = ''
        -- LazyVim bootstrap
        local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
        if not vim.loop.fs_stat(lazypath) then
          vim.fn.system({
            "git", "clone", "--filter=blob:none",
            "https://github.com/folke/lazy.nvim.git",
            "--branch=stable", lazypath,
          })
        end
        vim.opt.rtp:prepend(lazypath)

        require("lazy").setup({
          spec = {
            { "LazyVim/LazyVim", import = "lazyvim.plugins" },
            { import = "lazyvim.plugins.extras.lang.tex" },
            { import = "lazyvim.plugins.extras.lang.markdown" },
            { import = "lazyvim.plugins.extras.ui.mini-animate" },
            { import = "lazyvim.plugins.extras.lang.typescript" },
            { import = "lazyvim.plugins.extras.lang.python" },
            { import = "lazyvim.plugins.extras.lang.rust" },
            { import = "lazyvim.plugins.extras.lang.nix" },

            {
              "lervag/vimtex",
              lazy = false,
              init = function()
                vim.g.vimtex_view_method = "zathura"
              end
            },

            {
              "MeanderingProgrammer/render-markdown.nvim",
              opts = {
                enabled = true,
                file_types = { "markdown", "rmd" },
                colorscheme = "default",
              },
              dependencies = {
                "nvim-treesitter/nvim-treesitter",
                "nvim-tree/nvim-web-devicons",
              },
            },

            { "mracos/mermaid.vim", ft = { "mermaid" } },
          },

          defaults = { lazy = false, version = false },
          checker = { enabled = true },

          performance = {
            rtp = {
              disabled_plugins = {
                "gzip", "tarPlugin", "tohtml",
                "tutor", "zipPlugin",
              },
            },
          },
        })

        -- LaTeX wrapping
        vim.api.nvim_create_autocmd("FileType", {
          pattern = "tex",
          callback = function()
            vim.opt_local.wrap = true
            vim.opt_local.linebreak = true
            vim.opt_local.breakindent = true
            vim.opt_local.breakindentopt = "shift:2"
            vim.opt_local.textwidth = 0
          end,
        })

        -- Disable diagnostics in markdown
        vim.api.nvim_create_autocmd("FileType", {
          pattern = "markdown",
          callback = function()
            vim.diagnostic.disable(0)
          end,
        })

        -- Nix LSP
        local lspconfig = require("lspconfig")
        lspconfig.nil_ls.setup({ cmd = { "nil" } })

        vim.opt.clipboard = "unnamedplus"
      '';
    };

    kitty = {
      enable = true;
      extraConfig = ''
        confirm_os_window_close 0
        font_family Fira Code
        bold_font Fira Code Bold
        italic_font Fira Code Light
        shell_integration no-cursor
        cursor_shape beam
        window_padding_width 7
        window_padding_height 10
        scrollback_lines 3000
        font_size 11
        map ctrl+shift+plus change_font_size all +1.0
        map ctrl+shift+minus change_font_size all -1.0
        background_opacity 0.7

        cursor               #AC82E9
        selection_background #d8cab8
        selection_foreground #141216
        background           #141216
        foreground           #d8cab8

        color0  #2b2135
        color8  #92fcfa
        color1  #fc4649
        color9  #fc4649
        color2  #c4e881
        color10 #c4e881
        color3  #AC82E9
        color11 #AC82E9
        color4  #7b91fc
        color12 #7b91fc
        color5  #f3fc7b
        color13 #f3fc7b
        color6  #8F56E1
        color14 #8F56E1
        color7  #fc92fc
        color15 #d8cab8
      '';
    };
  };

  xsession.windowManager.i3 = {
    enable = true;
    config.bars = [];

    extraConfig = ''
      # i3 config
      set $mod Mod4
      font pango:Fira Code 10

      exec --no-startup-id dex-autostart --autostart --environment i3
      exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock-fancy-rapid 5 3 --nofork
      exec --no-startup-id nm-applet
      exec --no-startup-id blueman-applet
      exec_always --no-startup-id sh -c "sleep 1 && picom --config ~/.config/picom/picom.conf"
      exec --no-startup-id -merge ~/.Xresources
      exec_always --no-startup-id feh --bg-scale ~/Pictures/wallpapers/vox.jpg
      exec_always --no-startup-id sh -c "killall -q polybar; sleep 1; polybar example --config=~/.config/polybar/config.ini &"
      exec_always --no-startup-id ${hidePolybarInFullscreen}
      exec --no-startup-id flameshot

      gaps top 60

      bindsym XF86MonBrightnessDown exec brightnessctl set 10%-
      bindsym XF86MonBrightnessUp exec brightnessctl set +10%
      bindsym XF86AudioMute exec amixer set Master toggle
      bindsym XF86AudioLowerVolume exec amixer set Master 5%-
      bindsym XF86AudioRaiseVolume exec amixer set Master 5%+
      bindsym XF86AudioMicMute exec amixer set Capture toggle

      floating_modifier $mod

      bindsym $mod+Shift+s exec flameshot gui
      bindsym $mod+Return exec kitty
      bindsym $mod+Control+l exec --no-startup-id i3lock-fancy-rapid 5 3
      bindsym $mod+m exec rofi -show drun
      bindsym $mod+Shift+m exec kitty nnn
      bindsym $mod+n exec firefox
      bindsym $mod+Shift+q kill

      bindsym $mod+j focus left
      bindsym $mod+k focus down
      bindsym $mod+l focus up
      bindsym $mod+uring focus right

      bindsym $mod+Shift+j move left
      bindsym $mod+Shift+k move down
      bindsym $mod+Shift+l move up
      bindsym $mod+Shift+uring move right

      bindsym $mod+h split h
      bindsym $mod+v split v
      bindsym $mod+f fullscreen toggle
      bindsym $mod+s layout stacking
      bindsym $mod+w layout tabbed
      bindsym $mod+e layout toggle split
      bindsym $mod+Shift+space floating toggle
      bindsym $mod+space focus mode_toggle
      bindsym $mod+a focus parent

      set $ws1 "1"
      set $ws2 "2"
      set $ws3 "3"
      set $ws4 "4"
      set $ws5 "5"
      set $ws6 "6"
      set $ws7 "7"
      set $ws8 "8"
      set $ws9 "9"
      set $ws10 "10"

      bindsym $mod+plus workspace number $ws1
      bindsym $mod+ecaron workspace number $ws2
      bindsym $mod+scaron workspace number $ws3
      bindsym $mod+ccaron workspace number $ws4
      bindsym $mod+rcaron workspace number $ws5
      bindsym $mod+zcaron workspace number $ws6
      bindsym $mod+yacute workspace number $ws7
      bindsym $mod+aacute workspace number $ws8
      bindsym $mod+iacute workspace number $ws9
      bindsym $mod+eacute workspace number $ws10

      bindsym $mod+Shift+plus move container to workspace number $ws1
      bindsym $mod+Shift+ecaron move container to workspace number $ws2
      bindsym $mod+Shift+scaron move container to workspace number $ws3
      bindsym $mod+Shift+ccaron move container to workspace number $ws4
      bindsym $mod+Shift+rcaron move container to workspace number $ws5
      bindsym $mod+Shift+zcaron move container to workspace number $ws6
      bindsym $mod+Shift+yacute move container to workspace number $ws7
      bindsym $mod+Shift+aacute move container to workspace number $ws8
      bindsym $mod+Shift+iacute move container to workspace number $ws9
      bindsym $mod+Shift+eacute move container to workspace number $ws10

      bindsym $mod+Shift+c reload
      bindsym $mod+Shift+r restart
      bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

      mode "resize" {
        bindsym j resize shrink width 5 px or 5 ppt
        bindsym k resize grow height 5 px or 5 ppt
        bindsym l resize shrink height 5 px or 5 ppt
        bindsym uring resize grow width 5 px or 5 ppt

        bindsym Left resize shrink width 5 px or 5 ppt
        bindsym Down resize grow height 5 px or 5 ppt
        bindsym Up resize shrink height 5 px or 5 ppt
        bindsym Right resize grow width 5 px or 5 ppt

        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
      }

      bindsym $mod+r mode "resize"

      client.focused          #FFFFFF #FFFFFF #FFFFFF #FFFFFF   #b12cbf
      client.focused_inactive #8C8C8C #4C4C4C #FFFFFF #4C4C4C   #FFFFFF
      client.unfocused        #4C4C4C #222222 #888888 #292D2E   #500096
      client.urgent           #EC69A0 #DB3279 #FFFFFF #DB3279   #DB3279
      client.placeholder      #000000 #0C0C0C #FFFFFF #000000   #FFFFFF
      client.background       #FFFFFF

      default_border pixel 3
      default_floating_border pixel 3
      hide_edge_borders smart
    '';
  };

  services = {
    #gnome-keyring.enable = true;

    dunst = {
      enable = true;

      settings = let
        colors = {
          foreground = "#d0b6fd";
          background = "#1c182d";
          alert = "#7b91fc";
        };
      in {
        global = {
          width = "(200,300)";
          height = "(0,150)";
          offset = "(30,50)";
          origin = "bottom-right";
          transparency = 10;
          frame_width = 0;
          font = "Fira Code 10";
        };

        urgency_low = {
          background = colors.background;
          foreground = colors.foreground;
          timeout = 8;
        };

        urgency_normal = {
          background = colors.background;
          foreground = colors.foreground;
          frame-size = "0";
          timeout = 10;
        };

        urgency_critical = {
          background = colors.background;
          foreground = colors.foreground;
          frame-size = "5";
          frame-color = colors.alert;
        };
      };
    };

    polybar = {
      enable = true;

      extraConfig = let
        colors = {
          background = "#1c182d";
          background-alt = "#2b1b3d";
          foreground = "#d0b6fd";
          primary = "#cfb5fd";
          secondary = "#8a78b0";
          alert = "#7b91fc";
          disabled = "#707880";
        };
      in ''
        [bar/example]
        width = 98%
        height = 30pt
        radius = 15
        offset-x = 1%
        offset-y = 1%
        override-redirect = true
        fixed-center = true
        enable-ipc = true

        background = ${colors.background}
        foreground = ${colors.foreground}

        line-size = 4pt
        border-size = Opt
        border-color = #00000000

        padding-left = 1
        padding-right = 1
        module-margin = 1

        separator = |
        separator-foreground = ${colors.disabled}

        font-0 = fira code;2

        modules-left = xworkspaces spotify spotify-prev spotify-play-pause spotify-next
        modules-center = date
        modules-right = filesystem memory cpu pulseaudio-devices wlan xkeyboard battery

        [module/systray]
        type = internal/tray
        format-margin = 8pt
        tray-spacing = 16pt

        [module/xworkspaces]
        type = internal/xworkspaces
        label-active = %name%
        label-active-background = ${colors.background-alt}
        label-active-underline = ${colors.primary}
        label-active-padding = 1
        label-occupied = %name%
        label-occupied-padding = 1
        label-urgent = %name%
        label-urgent-background = ${colors.alert}
        label-urgent-padding = 1
        label-empty = %name%
        label-empty-foreground = ${colors.disabled}
        label-empty-padding = 1

        [module/xwindow]
        type = internal/xwindow
        label = %title:0:60:...%

        [module/filesystem]
        type = internal/fs
        interval = 25
        mount-0 = /
        label-mounted = %{F#F0C674}%mountpoint%%{F-} %percentage_used%%
        label-unmounted = %mountpoint% not mounted
        label-unmounted-foreground = ${colors.disabled}

        [module/pulseaudio]
        type = internal/pulseaudio
        format-volume-prefix = "VOL "
        format-volume-prefix-foreground = ${colors.primary}
        format-volume = <label-volume>
        label-volume = %percentage%%
        label-muted = muted
        label-muted-foreground = ${colors.disabled}

        [module/xkeyboard]
        type = internal/xkeyboard
        blacklist-0 = num lock
        label-layout = %layout%
        label-layout-foreground = ${colors.primary}
        label-indicator-padding = 2
        label-indicator-margin = 1
        label-indicator-foreground = ${colors.background}
        label-indicator-background = ${colors.secondary}

        [module/memory]
        type = internal/memory
        interval = 2
        format-prefix = "RAM "
        format-prefix-foreground = ${colors.primary}
        label = %percentage_used:2%%

        [module/cpu]
        type = internal/cpu
        interval = 2
        format-prefix = "CPU "
        format-prefix-foreground = ${colors.primary}
        label = %percentage:2%%

        [network-base]
        type = internal/network
        interval = 5
        format-connected = <label-connected>
        format-disconnected = <label-disconnected>
        label-disconnected = %{F#F0C674}%ifname%%{F#707880} disconnected

        [module/wlan]
        inherit = network-base
        interface-type = wireless
        label-connected = %{F#F0C674}%ifname%%{F-} %essid%

        [module/eth]
        inherit = network-base
        interface-type = wired
        label-connected = %{F#F0C674}%ifname%%{F-}

        [module/date]
        type = internal/date
        interval = 1
        date = %H:%M
        date-alt = %Y-%m-%d %H:%M:%S
        label = %date%
        label-foreground = ${colors.primary}

        [settings]
        screenchange-reload = true
        pseudo-transparency = true

        [module/battery]
        type = internal/battery
        full-at = 100
        low-at = 15
        battery = BAT0
        adapter = ADP1
        poll-interval = 5

        [module/spotify]
        type = custom/script
        tail = true
        interval = 1
        format-prefix = "♫"
        format = <label>
        exec = ${get_spotify_status}

        [module/spotify-prev]
        type = custom/script
        exec = echo "◀◀"
        format = <label>
        click-left = playerctl previous -p spotify

        [module/spotify-play-pause]
        type = custom/ipc
        hook-0 = echo "▶"
        hook-1 = echo "▶"
        initial = 1
        click-left = playerctl play-pause -p spotify

        [module/spotify-next]
        type = custom/script
        exec = echo "▶▶"
        format = <label>
        click-left = playerctl next -p spotify
      '';

      script = "polybar example --config=~/.config/polybar/config.ini &";
    };

    picom = {
      enable = true;
      backend = "glx";
      vSync = true;
      inactiveOpacity = 0.9;
      activeOpacity = 1.0;
      fade = true;
      fadeSteps = [ 0.09 0.09 ];
      fadeDelta = 5;
      shadow = true;
      shadowOffsets = [ 12 12 ];
      shadowOpacity = 0.5;
      shadowExclude = [
        "class_g = 'Polybar'"
        "name = 'Polybar'"
      ];
      settings = {
        corner-radius = 15;
      };
    };
  };
}