]> gitweb.ps.run Git - flake_thinkpad/blob - home-ps.nix
update
[flake_thinkpad] / home-ps.nix
1 { config, pkgs, lib, wallpaper, ... }:
2
3 let
4   theme = pkgs.qogir-theme.override { tweaks = [ "square" ]; };
5   markdownStyleHeader = pkgs.writeText "style.html" ''
6     <style type="text/css">
7     html{
8       margin:40px auto;
9       max-width:650px;
10       line-height:1.6;
11       font-size:18px;
12       color:#444;
13       background-color:#EEE;
14       padding:0 10px
15     }
16     @media (prefers-color-scheme: dark) {
17     html{
18       color:#CCC;
19       background-color:#333;
20     }
21     }
22     h1,h2,h3{line-height:1.2}
23     </style>
24   '';
25   markdownCaddyfile = pkgs.writeText "Caddyfile" ''
26     :8123
27
28     encode zstd gzip
29     templates
30     file_server browse {
31             root "/"
32             hide ".*"
33     }
34
35     @md <<CEL
36       {file}.endsWith(".md")
37       || {file}.endsWith(".MD")
38       CEL
39
40     header @md Content-Type "text/html; charset=UTF-8"
41     respond @md <<HTML
42             <!DOCTYPE html>
43             <html>
44                     <head>
45                             <title>{{ "{file.base}" }}</title>
46                             <link rel="stylesheet" href="https://sindresorhus.com/github-markdown-css/github-markdown.css">
47                             <style>
48                             .markdown-body {
49                                         box-sizing: border-box;
50                                         min-width: 200px;
51                                         max-width: 980px;
52                                         margin: 0 auto;
53                                         padding: 45px;
54                                 }
55                             </style>
56                     </head>
57                     <body class="markdown-body">
58                     {{
59                     markdown (include "{path}")
60                     }}
61                     </body>
62             </html>
63             HTML 200
64   '';
65 in
66 {
67   # Home Manager needs a bit of information about you and the paths it should
68   # manage.
69   home.username = "ps";
70   home.homeDirectory = "/home/ps";
71
72   services.xcape = {
73     enable = true;
74     mapExpression = {
75       Caps_Lock = "Escape";
76     };
77   };
78
79   xfconf.settings = {
80     xfce4-desktop = {
81       "backdrop/screen0/monitor0/image-path" = "${wallpaper}";
82       "backdrop/screen0/monitor0/image-show" = true;
83       "backdrop/screen0/monitor0/image-style" = 5;
84     };
85   };
86
87   systemd.user.services.markdownCaddy = {
88     Unit = {
89       Description = "Run a web server serving Markdown files.";
90       Wants = [ "network-online.target" ];
91       After = [ "network-online.target" ];
92     };
93     Install = {
94       WantedBy = [ "default.target" ];
95     };
96     Service = {
97       WorkingDirectory = "/";
98       ExecStart = "${pkgs.writeShellScript "markdown-caddy" ''
99         ${pkgs.caddy}/bin/caddy run --config ${markdownCaddyfile} --adapter caddyfile
100       ''}";
101     };
102   };
103   
104   xsession.windowManager.i3 = {
105     enable = true;
106     config = {
107       bars = [];
108       modifier = "Mod4";
109       terminal = "${pkgs.kitty}/bin/kitty";
110       gaps = { inner = 0; outer = 0; };
111       keybindings =
112         let
113           mod = config.xsession.windowManager.i3.config.modifier;
114           i3-next = pkgs.writers.writePython3 "i3-next" {} ''
115             import json
116             from subprocess import check_output
117
118             workspaces = json.loads(check_output(
119               ["${pkgs.i3}/bin/i3-msg",
120                "-t", "get_workspaces"]))
121
122             outputs = {}
123             activeOutput = ""
124             activeWorkspace = -1
125
126             for w in workspaces:
127                 output = w["output"]
128                 workspace = int(w["num"])
129                 if output not in outputs:
130                     outputs[output] = set()
131                 outputs[output].add(workspace)
132                 if w["focused"]:
133                     activeOutput = output
134                     activeWorkspace = workspace
135
136             workspacesSorted = sorted(outputs[activeOutput])
137             activeWorkspaceIndex = workspacesSorted.index(activeWorkspace)
138
139             if activeWorkspaceIndex < len(workspacesSorted) - 1:
140                 print(workspacesSorted[activeWorkspaceIndex + 1])
141             else:
142                 allWorkspaces = set()
143                 for o in outputs.values():
144                     allWorkspaces = allWorkspaces.union(o)
145                 allWorkspacesSorted = sorted(allWorkspaces)
146                 print(allWorkspacesSorted[-1]+1)
147           '';
148   
149           i3-empty = pkgs.writers.writePython3 "i3-empty" {} ''
150             import json
151             from subprocess import check_output
152
153             workspaces = json.loads(check_output(
154               ["${pkgs.i3}/bin/i3-msg",
155                "-t", "get_workspaces"]))
156
157             nextWorkspace = 1
158       
159             for w in workspaces:
160                 wNum = int(w["num"])
161                 if wNum >= nextWorkspace:
162                     nextWorkspace = wNum + 1
163
164             print(nextWorkspace)
165           '';
166           
167           i3-max = pkgs.writers.writePython3 "i3-max" {} ''
168             import json
169             from subprocess import check_output
170
171             workspaces = json.loads(check_output(
172               ["${pkgs.i3}/bin/i3-msg",
173                "-t", "get_workspaces"]))
174
175             result = "MAX"
176       
177             for w in workspaces:
178                 wName = w["name"]
179                 wFocused = w["focused"]
180                 if wName == "MAX" and wFocused:
181                     result = "back_and_forth"
182                     break
183
184             print(f"move window to workspace {result}; workspace {result}")
185           '';
186           i3-move-max = pkgs.writers.writePython3 "i3-move-max" {} ''
187             import json
188             from subprocess import check_output
189
190             workspaces = json.loads(check_output(
191               ["${pkgs.i3}/bin/i3-msg",
192                "-t", "get_workspaces"]))
193
194             result = "MAX"
195       
196             for w in workspaces:
197                 wName = w["name"]
198                 wFocused = w["focused"]
199                 if wName == "MAX" and wFocused:
200                     result = "back_and_forth"
201                     break
202
203             print(f"workspace {result}")
204           '';
205         in lib.mkOptionDefault
206           {
207             # "${mod}+d" = "exec --no-startup-id krunner";
208             # "${mod}+Shift+p" = "exec --no-startup-id set-wallpaper";
209             "${mod}+Shift+Return" = "exec --no-startup-id ${pkgs.kitty}/bin/kitty -d $(${pkgs.xcwd}/bin/xcwd)";
210             "${mod}+BackSpace" = "kill";
211             "${mod}+Prior" = "workspace prev_on_output";
212             "${mod}+Next" = "exec --no-startup-id i3-msg workspace number $(${i3-next})";
213             "${mod}+End" = "exec --no-startup-id i3-msg workspace $(${i3-empty})";
214             "${mod}+Shift+Prior" = "move container to workspace prev_on_output";
215             "${mod}+Shift+Next" = "exec --no-startup-id i3-msg move container to workspace number $(${i3-next})";
216             "${mod}+Shift+End" = "exec --no-startup-id i3-msg move container to workspace $(${i3-empty})";
217             "${mod}+Ctrl+Left" = "move workspace to output left";
218             "${mod}+Ctrl+Right" = "move workspace to output right";
219             "${mod}+y" = "exec --no-startup-id mirror-phone";
220             "${mod}+n" = "exec ${pkgs.kitty}/bin/kitty -d ~/sync/txt nvim -c 'autocmd VimEnter * ++once Telescope find_files'";
221             "${mod}+m" = "exec --no-startup-id i3-msg $(${i3-max})";
222             "${mod}+b" = "split toggle; layout tabbed";
223             "${mod}+Shift+m" = "exec --no-startup-id i3-msg $(${i3-move-max})";
224             "${mod}+Shift+p" = "exec --no-startup-id ${pkgs.autorandr}/bin/autorandr --match-edid -c -f";
225           };
226     };
227     extraConfig = ''
228       for_window [window_role="pop-up"] floating enable
229       for_window [window_role="task_dialog"] floating enable
230       for_window [workspace="9"] floating enable
231
232       for_window [class="kitty-popup"] floating enable
233       for_window [class="Xfce4-appfinder"] floating enable
234       for_window [class="yakuake"] floating enable
235       for_window [class="systemsettings"] floating enable
236       for_window [title="win7"] floating enable; border none
237       for_window [title="Arbeitsfläche.*"] kill, floating enable, border none
238
239       # class                 border  backgr. text    indicator child_border
240       client.focused          #000000bf #000000bf #e6ebef #000000bf   #000000bf
241       client.focused_inactive #00000080 #00000080 #e6ebef #00000080   #00000080
242       client.unfocused        #00000040 #00000040 #e6ebef #00000040   #00000040
243       client.urgent           #2f343a #900000 #e6ebef #900000   #2f343a
244       client.placeholder      #000000 #0c0c0c #e6ebef #000000   #0c0c0c
245
246       focus_follows_mouse no
247       mouse_warping none
248       popup_during_fullscreen all
249     '';
250   };
251
252   services.picom = {
253     enable = true;
254     vSync = true;
255     opacityRules = [
256       "0:_NET_WM_STATE@[*]:a = '_NET_WM_STATE_HIDDEN'"
257     ];
258   };
259
260   programs.git = {
261     userName = "patrick-scho";
262     userEmail = "patrick.schoenberger@posteo.de";
263     includes = [{ contents = {
264         user = {
265           email = "patrick.schoenberger@posteo.de";
266           name = "psch";
267         };
268     };}];
269   };
270
271   programs.bash = {
272     enable = true;
273     historySize = -1;
274     historyFileSize = -1;
275     shellAliases = {  
276       snrs = "sudo nixos-rebuild switch --flake /etc/nixos#default";
277       snrt = "sudo nixos-rebuild test --flake /etc/nixos#default";
278       snrb = "sudo nixos-rebuild boot --flake /etc/nixos#default";
279       senc = "sudo $EDITOR /etc/nixos/configuration.nix";
280       senh = "sudo $EDITOR /etc/nixos/home-ps.nix";
281       senhc = "sudo $EDITOR /etc/nixos/home-common.nix";
282       senf = "sudo $EDITOR /etc/nixos/flake.nix";
283       flakerun = "nix run --override-input nixpkgs nixpkgs";
284       n = "nvim";
285     };
286   };
287
288   programs.fzf = {
289     enable = true;
290     enableBashIntegration = true;
291   };
292
293   programs.readline = {
294     enable = true;
295     bindings = {
296       "\\e[A" = "history-search-backward";
297       "\\e[B" = "history-search-forward";
298     };
299   };
300
301   programs.kitty = {
302     enable = true;
303     themeFile = "Adapta_Nokto_Maia";
304     settings = {
305       # hide_window_decorations = "yes";
306       background_opacity = "0.98";
307       background_blur = "1";
308       confirm_os_window_close = "0";
309       enable_audio_bell = "no";
310       scrollback_pager_history_size = "1024";
311     };
312   };
313
314   programs.helix = {
315     enable = true;
316     settings = {
317       theme = "base16_terminal";
318       editor.cursor-shape = {
319         insert = "bar";
320         normal = "block";
321         select = "underline";
322       };
323       editor.soft-wrap = {
324         enable = true;
325       };
326       editor.file-picker = {
327         hidden = false;
328       };
329       keys.normal."space" = {
330         "space" = "goto_word";
331       };
332     };
333     languages = {
334       language = [{
335         name = "c";
336         auto-format = true;
337         formatter = { command = "clang-format"; args = ["--style=microsoft"]; };
338       }];
339     };
340   };
341
342   home.file.".config/zls.json".text = ''
343     {
344       "enable_build_on_save": true,
345       "build_on_save_step": "check"
346     }
347   '';
348   
349   home.file.".config/vis/plugins/vis-lspc" = {
350     source = builtins.fetchGit {
351       url = "https://gitlab.com/muhq/vis-lspc.git";
352       rev = "e184eb6c971abfcd0dc7f836f402aae6c33a8d13";
353     };
354     recursive = true;
355   };
356   home.file.".config/vis/plugins/vis-commentary" = {
357     source = builtins.fetchGit {
358       url = "https://github.com/lutobler/vis-commentary.git";
359       rev = "0e06ed8212c12c6651cb078b822390094b396f08";
360     };
361     recursive = true;
362   };
363   home.file.".config/vis/visrc.lua".text = ''
364       require('vis')
365       require('plugins/vis-commentary')
366       lspc = require('plugins/vis-lspc')
367
368       lspc.menu_cmd = 'vis-menu'
369       lspc.fallback_dirname_as_root = true
370       lspc.ls_map.zig = {name='zls',cmd='zls',roots={'build.zig'}}
371     
372       vis.events.subscribe(vis.events.INIT, function()
373         -- Your global configuration options
374       end)
375
376       vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
377         -- Your per window configuration options e.g.
378         vis:command('set number on')
379         vis:command('set autoindent')
380         vis:command('set tabwidth 4')
381         vis:command('set expandtab on')
382       end)
383     '';
384
385   programs.emacs = {
386     enable = true;
387     extraConfig = ''
388       (menu-bar-mode 1)
389       (tool-bar-mode 0)
390       (scroll-bar-mode 0)
391       (global-display-line-numbers-mode)
392       (setq-default
393         display-line-numbers-type 'relative
394         make-backup-files nil
395         inhibit-startup-screen t)
396       (load-theme 'tango-dark t)
397     '';
398     extraPackages = epkgs: [
399       epkgs.zig-mode
400       epkgs.lsp-mode
401     ];
402   };
403
404   programs.tmux = {
405     enable = true;
406     escapeTime = 0;
407     extraConfig = ''
408       set-option -g default-terminal screen-256color
409       set -g history-limit 10000
410       set -g base-index 1
411       set-option -g renumber-windows on
412       bind-key -n M-n new-window -c "#{pane_current_path}"
413       bind-key -n M-1 select-window -t :1
414       bind-key -n M-2 select-window -t :2
415       bind-key -n M-3 select-window -t :3
416       bind-key -n M-4 select-window -t :4
417       bind-key -n M-5 select-window -t :5
418       bind-key -n M-6 select-window -t :6
419       bind-key -n M-7 select-window -t :7
420       bind-key -n M-8 select-window -t :8
421       bind-key -n M-9 select-window -t :9
422       bind-key -n M-0 select-window -t :0
423       bind-key -n M-. select-window -n
424       bind-key -n M-, select-window -p
425       bind-key -n M-S-. swap-window -t +1
426       bind-key -n M-S-, swap-window -t -1
427       bind-key -n M-X confirm-before "kill-window"
428       bind-key -n M-v split-window -h -c "#{pane_current_path}"
429       bind-key -n M-b split-window -v -c "#{pane_current_path}"
430       bind-key -n M-R command-prompt -I "" "rename-window '%%'"
431       bind-key -n M-f resize-pane -Z
432       bind-key -n M-h select-pane -L
433       bind-key -n M-l select-pane -R
434       bind-key -n M-k select-pane -U
435       bind-key -n M-j select-pane -D
436       bind-key -n M-Left select-pane -L
437       bind-key -n M-Right select-pane -R
438       bind-key -n M-Up select-pane -U
439       bind-key -n M-Down select-pane -D
440       bind-key -n "M-H" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -L; tmux swap-pane -t $old'
441       bind-key -n "M-J" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -D; tmux swap-pane -t $old'
442       bind-key -n "M-K" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -U; tmux swap-pane -t $old'
443       bind-key -n "M-L" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -R; tmux swap-pane -t $old'
444       bind-key -n "M-S-Left" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -L; tmux swap-pane -t $old'
445       bind-key -n "M-S-Down" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -D; tmux swap-pane -t $old'
446       bind-key -n "M-S-Up" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -U; tmux swap-pane -t $old'
447       bind-key -n "M-S-Right" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -R; tmux swap-pane -t $old'
448       bind-key -n M-x confirm-before "kill-pane"
449       bind-key -n M-/ copy-mode
450
451       # Linux system clipboard
452       bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
453       bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xclip -in -selection clipboard"
454
455       set -g mouse on
456       # set-option -g status-keys vi
457       # set-option -g set-titles on
458       # set-option -g set-titles-string 'tmux - #W'
459       # set -g bell-action any
460       # set-option -g visual-bell off
461       # set-option -g set-clipboard off
462       # setw -g mode-keys vi
463       # setw -g monitor-activity on
464       # set -g visual-activity on
465       # set -g status-style fg=colour15
466       # set -g status-justify centre
467       # set -g status-left ""
468       # set -g status-right ""
469       # set -g status-interval 1
470       # set -g message-style fg=colour0,bg=colour3
471       # setw -g window-status-bell-style fg=colour1
472       # setw -g window-status-current-style fg=yellow,bold
473       # setw -g window-status-style fg=colour250
474       # setw -g window-status-current-format ' #{?#{==:#W,#{b:SHELL}},#{b:pane_current_path},#W} '
475       # setw -g window-status-format ' #{?#{==:#W,#{b:SHELL}},#{b:pane_current_path},#W} '
476       # # For older tmux:
477       # #setw -g window-status-format ' #W '
478       # #setw -g window-status-current-format ' #W '
479     '';
480   };
481
482   programs.nushell = {
483     enable = true;
484     # for editing directly to config.nu 
485     extraConfig = ''
486       $env.config = {
487         show_banner: false,
488         completions: {
489           case_sensitive: false # case-sensitive completions
490           quick: true           # set to false to prevent auto-selecting completions
491           partial: true         # set to false to prevent partial filling of the prompt
492           algorithm: "fuzzy"    # prefix or fuzzy
493         }
494         hooks: {
495           command_not_found: { |cmd| (command-not-found $cmd | str trim)  }
496         }
497       } 
498     '';
499     #  shellAliases = {
500     #  vi = "hx";
501     #  vim = "hx";
502     #  nano = "hx";
503     # };
504   };  
505   # programs.carapace = {
506   #   enable = true;
507   #   enableNushellIntegration = true;
508   # };
509
510   # programs.starship = {
511   #   enable = true;
512   #   settings = {
513   #     add_newline = false;
514   #     character = { 
515   #       success_symbol = "[➜](bold green)";
516   #       error_symbol = "[➜](bold red)";
517   #     };
518   #   };
519   # };
520
521   programs.firefox = {
522     enable = true;
523     profiles = {
524       default = {
525         settings = {
526           "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
527           "browser.fullscreen.autohide" = false;
528           "browser.toolbars.bookmarks.visibility" = "never";
529           "browser.tabs.inTitlebar" = 0;
530           "browser.compactmode.show" = true;
531           "browser.uidensity" = 1;
532         };
533         userChrome = ''
534         #TabsToolbar {
535           visibility: collapse !important;
536         }
537         '';
538       };
539       appmode = {
540         id = 1;
541         settings = {
542           "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
543           "browser.fullscreen.autohide" = false;
544           "browser.toolbars.bookmarks.visibility" = "never";
545           "browser.tabs.inTitlebar" = 0;
546           "browser.compactmode.show" = true;
547           "browser.uidensity" = 1;
548         };
549         userChrome = ''
550         #TabsToolbar {
551           visibility: collapse !important;
552         }
553         #nav-bar {
554           visibility: collapse !important;
555         }
556         #navigator-toolbox {
557           border-bottom: none !important;
558         }
559         '';        
560       };
561     };
562   };
563
564   xdg.desktopEntries = {
565     whatsapp = {
566       name = "WhatsApp";
567       genericName = "Messenger";
568       exec = "app web.whatsapp.com";
569       terminal = false;
570       categories = [ "Application" ];
571       icon = pkgs.fetchurl {
572         url = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/2062095_application_chat_communication_logo_whatsapp_icon.svg/1024px-2062095_application_chat_communication_logo_whatsapp_icon.svg.png";
573         sha256 = "sha256-0eE3EEGnWFlpObfraTXMIqJz0Uya/h0hDsUA528qKCY=";
574       };
575     };
576     md = {
577       name = "Markdown";
578       genericName = "Documents";
579       exec = "md-app";
580       terminal = false;
581       categories = [ "Application" ];
582       icon = pkgs.fetchurl {
583         url = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Markdown-mark.svg/1024px-Markdown-mark.svg.png";
584         sha256 = "0v161jvmcfxp9lwd86y789430w1vpvxnnm5n2hzgr1kfh03psvb2";
585       };
586     };
587   };
588
589   gtk.enable = true;
590   gtk.theme = {
591     package = theme;
592     name = "Qogir-Dark";
593   };
594   # programs.gnome-shell.theme = {
595   #   package = theme;
596   #   name = "Qogir-Dark";
597   # };
598   # gtk.iconTheme = {
599   #   package = pkgs.vimix-icon-theme;
600   #   name = "vimix-doder-dark";
601   # };
602   home.pointerCursor = {
603     gtk.enable = true;
604     x11.enable = true;
605
606     name = "volantes_light_cursors";
607     size = 24;
608     package = pkgs.volantes-cursors;
609   };
610
611   # This value determines the Home Manager release that your configuration is
612   # compatible with. This helps avoid breakage when a new Home Manager release
613   # introduces backwards incompatible changes.
614   #
615   # You should not change this value, even if you update Home Manager. If you do
616   # want to update the value, then make sure to first check the Home Manager
617   # release notes.
618   home.stateVersion = "24.05"; # Please read the comment before changing.
619
620   # The home.packages option allows you to install Nix packages into your
621   # environment.
622   home.packages = with pkgs; [
623     nixos-icons
624     spotify-player
625     prismlauncher
626     pandoc
627     ghidra
628     gnome-firmware
629     fzf bat delta silver-searcher ripgrep perl universal-ctags
630     rofi
631     # bintools
632     htop
633     unzip
634     rr wrk
635     clang-tools bear
636     linuxPackages_latest.perf
637     texliveFull
638     asciidoctor-with-extensions
639     emscripten
640     caddy
641     python3
642     qogir-icon-theme
643     volantes-cursors
644     xorg.xkill
645     lf nnn yazi
646     feh
647     xarchiver
648     tig lazygit gitui
649     thunderbird
650     aerc
651     libreoffice
652     gimp
653     guvcview
654     arandr
655     vial
656     ncdu
657     gnumake gcc
658     linux-wifi-hotspot
659     esptool picocom
660     wireshark
661     nil
662     bc
663     ffmpeg-full
664     sc-im visidata
665     localsend
666     vis
667     wineWowPackages.unstableFull winetricks
668     signal-desktop
669
670     # # It is sometimes useful to fine-tune packages, for example, by applying
671     # # overrides. You can do that directly here, just don't forget the
672     # # parentheses. Maybe you want to install Nerd Fonts with a limited number of
673     # # fonts?
674     # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
675
676     # # You can also create simple shell scripts directly inside your
677     # # configuration. For example, this adds a command 'my-hello' to your
678     # # environment:
679     # (pkgs.writeShellScriptBin "my-hello" ''
680     #   echo "Hello, ${config.home.username}!"
681     # '')
682     # $@ - Liste aller Parameter
683     # $* - String aller Parameter
684     # $# - Anzahl aller Parameter
685     # &> - stdout und stderr pipen
686     # '' - Literal
687     # "" - Expanded
688     # 
689     (pkgs.writeShellScriptBin "app" ''
690       ${pkgs.firefox}/bin/firefox -p appmode --new-window "$@"
691     '')
692     (pkgs.writeShellScriptBin "md" ''
693       file=$(mktemp --suffix=.html) && \
694       echo $file && \
695       ${pkgs.pandoc}/bin/pandoc -o $file $1 -s -H ${markdownStyleHeader} && \
696       app $file && \
697       rm $file
698     '')
699     (pkgs.writeShellScriptBin "run" ''
700       (nohup "$@" &>/dev/null &); sleep 0
701     '')
702     (pkgs.writeShellScriptBin "popup" ''
703       ${pkgs.kitty}/bin/kitty -o hide_window_decorations=yes -o background_opacity=0.5 \
704         --class kitty-popup -o remember_window_size=no \
705         -o initial_window_width=120c -o initial_window_height=40c \
706         "$@"
707     '')
708     (pkgs.writeShellScriptBin "fzfdir" ''
709       find "$1" -name "$2" | ${pkgs.fzf}/bin/fzf --layout=reverse
710     '')
711     (pkgs.writeShellScriptBin "file-app" ''
712       app localhost:8123
713     '')
714     (pkgs.writeShellScriptBin "run-popup" ''
715       popup bash -c 'file=$(compgen -c | grep -v fzf | sort -u | fzf --layout=reverse --print-query | tail -n 1) && run $file'
716     '')
717     (pkgs.writeShellScriptBin "set-wallpaper" ''
718       ${pkgs.feh}/bin/feh --bg-fill --no-fehbg ${wallpaper}
719     '')
720     (pkgs.writeShellScriptBin "mirror-phone" "IP=$(select-ip) && sudo scrcpy --tcpip=$IP --no-audio -K --kill-adb-on-close")
721     (pkgs.writeShellScriptBin "select-ip" ''
722       FILE=$HOME/.cache/select-ip.txt
723       IP=$( ${pkgs.rofi}/bin/rofi -dmenu -input $FILE -p IP ) || exit 1
724       echo $IP >> $FILE
725       gawk -i inplace 'FNR==1{delete a} !a[$0]++' $FILE
726       echo $IP
727     '')
728     (pkgs.writeShellScriptBin "create-repo" ''
729       ssh psch.dev sudo -u git git init --bare /srv/git/$1
730     '')
731   ];
732
733   # Home Manager is pretty good at managing dotfiles. The primary way to manage
734   # plain files is through 'home.file'.
735   home.file = {
736     # # Building this configuration will create a copy of 'dotfiles/screenrc' in
737     # # the Nix store. Activating the configuration will then make '~/.screenrc' a
738     # # symlink to the Nix store copy.
739     # ".screenrc".source = dotfiles/screenrc;
740
741     # # You can also set the file content immediately.
742     # ".gradle/gradle.properties".text = ''
743     #   org.gradle.console=verbose
744     #   org.gradle.daemon.idletimeout=3600000
745     # '';
746   };
747
748   # Home Manager can also manage your environment variables through
749   # 'home.sessionVariables'. These will be explicitly sourced when using a
750   # shell provided by Home Manager. If you don't want to manage your shell
751   # through Home Manager then you have to manually source 'hm-session-vars.sh'
752   # located at either
753   #
754   #  ~/.nix-profile/etc/profile.d/hm-session-vars.sh
755   #
756   # or
757   #
758   #  ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
759   #
760   # or
761   #
762   #  /etc/profiles/per-user/ps/etc/profile.d/hm-session-vars.sh
763   #
764   home.sessionVariables = {
765     # EDITOR = "emacs";
766   };
767
768   # Let Home Manager install and manage itself.
769   programs.home-manager.enable = true;
770 }