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