]> gitweb.ps.run Git - flake_thinkpad/blob - home.nix
14dd4c3375d20c089928d70e6f7c7d87cf7de6b7
[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       blink-cmp
358       telescope-nvim
359       trouble-nvim
360     ];
361     extraConfig = ''
362       set number
363       set relativenumber
364       set tabstop=4
365       set shiftwidth=4
366       set foldmethod=marker
367       colorscheme habamax
368
369       nnoremap <Down> gj
370       nnoremap <Up> gk
371       vnoremap <Down> gj
372       vnoremap <Up> gk
373       inoremap <Down> <C-o>gj
374       inoremap <Up> <C-o>gk
375       tnoremap <Esc> <C-\><C-n>
376     '';
377     extraLuaConfig = ''
378       require('lspconfig').zls.setup{}
379       require('formatter').setup {
380         
381       }
382     '';
383   };
384
385
386   home.file.".config/vis/plugins/vis-lspc" = {
387     source = builtins.fetchGit {
388       url = "https://gitlab.com/muhq/vis-lspc.git";
389       rev = "e184eb6c971abfcd0dc7f836f402aae6c33a8d13";
390     };
391     recursive = true;
392   };
393   home.file.".config/vis/plugins/vis-commentary" = {
394     source = builtins.fetchGit {
395       url = "https://github.com/lutobler/vis-commentary.git";
396       rev = "0e06ed8212c12c6651cb078b822390094b396f08";
397     };
398     recursive = true;
399   };
400   home.file.".config/vis/visrc.lua".text = ''
401       require('vis')
402       require('plugins/vis-commentary')
403       lspc = require('plugins/vis-lspc')
404
405       lspc.menu_cmd = 'vis-menu'
406       lspc.fallback_dirname_as_root = true
407       lspc.ls_map.zig = {name='zls',cmd='zls',roots={'build.zig'}}
408     
409       vis.events.subscribe(vis.events.INIT, function()
410         -- Your global configuration options
411       end)
412
413       vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
414         -- Your per window configuration options e.g.
415         vis:command('set number on')
416         vis:command('set autoindent')
417         vis:command('set tabwidth 4')
418         vis:command('set expandtab on')
419       end)
420     '';
421
422   programs.emacs = {
423     enable = true;
424     extraConfig = ''
425       (menu-bar-mode 1)
426       (tool-bar-mode 0)
427       (scroll-bar-mode 0)
428       (global-display-line-numbers-mode)
429       (setq-default
430         display-line-numbers-type 'relative
431         make-backup-files nil
432         inhibit-startup-screen t)
433       (load-theme 'tango-dark t)
434     '';
435     extraPackages = epkgs: [
436       epkgs.zig-mode
437       epkgs.lsp-mode
438     ];
439   };
440
441   programs.tmux = {
442     enable = true;
443     escapeTime = 0;
444     extraConfig = ''
445       set-option -g default-terminal screen-256color
446       set -g history-limit 10000
447       set -g base-index 1
448       set-option -g renumber-windows on
449       bind-key -n M-n new-window -c "#{pane_current_path}"
450       bind-key -n M-1 select-window -t :1
451       bind-key -n M-2 select-window -t :2
452       bind-key -n M-3 select-window -t :3
453       bind-key -n M-4 select-window -t :4
454       bind-key -n M-5 select-window -t :5
455       bind-key -n M-6 select-window -t :6
456       bind-key -n M-7 select-window -t :7
457       bind-key -n M-8 select-window -t :8
458       bind-key -n M-9 select-window -t :9
459       bind-key -n M-0 select-window -t :0
460       bind-key -n M-. select-window -n
461       bind-key -n M-, select-window -p
462       bind-key -n M-S-. swap-window -t +1
463       bind-key -n M-S-, swap-window -t -1
464       bind-key -n M-X confirm-before "kill-window"
465       bind-key -n M-v split-window -h -c "#{pane_current_path}"
466       bind-key -n M-b split-window -v -c "#{pane_current_path}"
467       bind-key -n M-R command-prompt -I "" "rename-window '%%'"
468       bind-key -n M-f resize-pane -Z
469       bind-key -n M-h select-pane -L
470       bind-key -n M-l select-pane -R
471       bind-key -n M-k select-pane -U
472       bind-key -n M-j select-pane -D
473       bind-key -n M-Left select-pane -L
474       bind-key -n M-Right select-pane -R
475       bind-key -n M-Up select-pane -U
476       bind-key -n M-Down select-pane -D
477       bind-key -n "M-H" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -L; tmux swap-pane -t $old'
478       bind-key -n "M-J" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -D; tmux swap-pane -t $old'
479       bind-key -n "M-K" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -U; tmux swap-pane -t $old'
480       bind-key -n "M-L" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -R; tmux swap-pane -t $old'
481       bind-key -n "M-S-Left" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -L; tmux swap-pane -t $old'
482       bind-key -n "M-S-Down" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -D; tmux swap-pane -t $old'
483       bind-key -n "M-S-Up" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -U; tmux swap-pane -t $old'
484       bind-key -n "M-S-Right" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -R; tmux swap-pane -t $old'
485       bind-key -n M-x confirm-before "kill-pane"
486       bind-key -n M-/ copy-mode
487
488       # Linux system clipboard
489       bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
490       bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xclip -in -selection clipboard"
491
492       set -g mouse on
493       # set-option -g status-keys vi
494       # set-option -g set-titles on
495       # set-option -g set-titles-string 'tmux - #W'
496       # set -g bell-action any
497       # set-option -g visual-bell off
498       # set-option -g set-clipboard off
499       # setw -g mode-keys vi
500       # setw -g monitor-activity on
501       # set -g visual-activity on
502       # set -g status-style fg=colour15
503       # set -g status-justify centre
504       # set -g status-left ""
505       # set -g status-right ""
506       # set -g status-interval 1
507       # set -g message-style fg=colour0,bg=colour3
508       # setw -g window-status-bell-style fg=colour1
509       # setw -g window-status-current-style fg=yellow,bold
510       # setw -g window-status-style fg=colour250
511       # setw -g window-status-current-format ' #{?#{==:#W,#{b:SHELL}},#{b:pane_current_path},#W} '
512       # setw -g window-status-format ' #{?#{==:#W,#{b:SHELL}},#{b:pane_current_path},#W} '
513       # # For older tmux:
514       # #setw -g window-status-format ' #W '
515       # #setw -g window-status-current-format ' #W '
516     '';
517   };
518
519   programs.nushell = {
520     enable = true;
521     # for editing directly to config.nu 
522     extraConfig = ''
523       $env.config = {
524         show_banner: false,
525         completions: {
526           case_sensitive: false # case-sensitive completions
527           quick: true           # set to false to prevent auto-selecting completions
528           partial: true         # set to false to prevent partial filling of the prompt
529           algorithm: "fuzzy"    # prefix or fuzzy
530         }
531         hooks: {
532           command_not_found: { |cmd| (command-not-found $cmd | str trim)  }
533         }
534       } 
535     '';
536     #  shellAliases = {
537     #  vi = "hx";
538     #  vim = "hx";
539     #  nano = "hx";
540     # };
541   };  
542   # programs.carapace = {
543   #   enable = true;
544   #   enableNushellIntegration = true;
545   # };
546
547   # programs.starship = {
548   #   enable = true;
549   #   settings = {
550   #     add_newline = false;
551   #     character = { 
552   #       success_symbol = "[➜](bold green)";
553   #       error_symbol = "[➜](bold red)";
554   #     };
555   #   };
556   # };
557
558   programs.firefox = {
559     enable = true;
560     profiles = {
561       default = {
562         settings = {
563           "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
564           "browser.fullscreen.autohide" = false;
565           "browser.toolbars.bookmarks.visibility" = "never";
566           "browser.tabs.inTitlebar" = 0;
567           "browser.compactmode.show" = true;
568           "browser.uidensity" = 1;
569         };
570         userChrome = ''
571         #TabsToolbar {
572           visibility: collapse !important;
573         }
574         '';
575       };
576       appmode = {
577         id = 1;
578         settings = {
579           "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
580           "browser.fullscreen.autohide" = false;
581           "browser.toolbars.bookmarks.visibility" = "never";
582           "browser.tabs.inTitlebar" = 0;
583           "browser.compactmode.show" = true;
584           "browser.uidensity" = 1;
585         };
586         userChrome = ''
587         #TabsToolbar {
588           visibility: collapse !important;
589         }
590         #nav-bar {
591           visibility: collapse !important;
592         }
593         #navigator-toolbox {
594           border-bottom: none !important;
595         }
596         '';        
597       };
598     };
599   };
600
601   xdg.desktopEntries = {
602     whatsapp = {
603       name = "WhatsApp";
604       genericName = "Messenger";
605       exec = "app web.whatsapp.com";
606       terminal = false;
607       categories = [ "Application" ];
608       icon = pkgs.fetchurl {
609         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";
610         sha256 = "sha256-0eE3EEGnWFlpObfraTXMIqJz0Uya/h0hDsUA528qKCY=";
611       };
612     };
613     md = {
614       name = "Markdown";
615       genericName = "Documents";
616       exec = "md-app";
617       terminal = false;
618       categories = [ "Application" ];
619       icon = pkgs.fetchurl {
620         url = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Markdown-mark.svg/1024px-Markdown-mark.svg.png";
621         sha256 = "0v161jvmcfxp9lwd86y789430w1vpvxnnm5n2hzgr1kfh03psvb2";
622       };
623     };
624   };
625
626   gtk.enable = true;
627   gtk.theme = {
628     package = theme;
629     name = "Qogir-Dark";
630   };
631   # programs.gnome-shell.theme = {
632   #   package = theme;
633   #   name = "Qogir-Dark";
634   # };
635   # gtk.iconTheme = {
636   #   package = pkgs.vimix-icon-theme;
637   #   name = "vimix-doder-dark";
638   # };
639   home.pointerCursor = {
640     gtk.enable = true;
641     x11.enable = true;
642
643     name = "volantes_light_cursors";
644     size = 24;
645     package = pkgs.volantes-cursors;
646   };
647
648   # This value determines the Home Manager release that your configuration is
649   # compatible with. This helps avoid breakage when a new Home Manager release
650   # introduces backwards incompatible changes.
651   #
652   # You should not change this value, even if you update Home Manager. If you do
653   # want to update the value, then make sure to first check the Home Manager
654   # release notes.
655   home.stateVersion = "24.05"; # Please read the comment before changing.
656
657   # The home.packages option allows you to install Nix packages into your
658   # environment.
659   home.packages = with pkgs; [
660     nixos-icons
661     spotify-player
662     prismlauncher
663     pandoc
664     ghidra
665     gnome-firmware
666     fzf bat delta silver-searcher ripgrep perl universal-ctags
667     rofi
668     # bintools
669     htop
670     unzip
671     rr wrk
672     clang-tools bear
673     linuxPackages_latest.perf
674     texliveFull
675     emscripten
676     caddy
677     python3
678     qogir-icon-theme
679     volantes-cursors
680     xorg.xkill
681     lf nnn yazi
682     feh
683     xarchiver
684     tig lazygit gitui
685     thunderbird
686     libreoffice
687     gimp
688     guvcview
689     arandr
690     vial
691     ncdu
692     gnumake gcc
693     linux-wifi-hotspot
694     esptool picocom
695     wireshark
696     nil
697     bc
698     ffmpeg
699     sc-im visidata
700     localsend
701     vis
702     wineWowPackages.unstableFull winetricks
703     signal-desktop
704
705     # # It is sometimes useful to fine-tune packages, for example, by applying
706     # # overrides. You can do that directly here, just don't forget the
707     # # parentheses. Maybe you want to install Nerd Fonts with a limited number of
708     # # fonts?
709     # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
710
711     # # You can also create simple shell scripts directly inside your
712     # # configuration. For example, this adds a command 'my-hello' to your
713     # # environment:
714     # (pkgs.writeShellScriptBin "my-hello" ''
715     #   echo "Hello, ${config.home.username}!"
716     # '')
717     # $@ - Liste aller Parameter
718     # $* - String aller Parameter
719     # $# - Anzahl aller Parameter
720     # &> - stdout und stderr pipen
721     # '' - Literal
722     # "" - Expanded
723     # 
724     (pkgs.writeShellScriptBin "app" ''
725       ${pkgs.firefox}/bin/firefox -p appmode --new-window "$@"
726     '')
727     (pkgs.writeShellScriptBin "md" ''
728       file=$(mktemp --suffix=.html) && \
729       echo $file && \
730       ${pkgs.pandoc}/bin/pandoc -o $file $1 -s -H ${markdownStyleHeader} && \
731       app $file && \
732       rm $file
733     '')
734     (pkgs.writeShellScriptBin "run" ''
735       (nohup "$@" &>/dev/null &); sleep 0
736     '')
737     (pkgs.writeShellScriptBin "popup" ''
738       ${pkgs.kitty}/bin/kitty -o hide_window_decorations=yes -o background_opacity=0.5 \
739         --class kitty-popup -o remember_window_size=no \
740         -o initial_window_width=120c -o initial_window_height=40c \
741         "$@"
742     '')
743     (pkgs.writeShellScriptBin "fzfdir" ''
744       find "$1" -name "$2" | ${pkgs.fzf}/bin/fzf --layout=reverse
745     '')
746     (pkgs.writeShellScriptBin "md-app" ''
747       #popup bash -c 'file=$(fzfdir "md" "*.md") && run md $file'
748       firefox -p appmode --new-window localhost:8123/home/ps/sync/txt/hsrm
749     '')
750     (pkgs.writeShellScriptBin "run-popup" ''
751       popup bash -c 'file=$(compgen -c | grep -v fzf | sort -u | fzf --layout=reverse --print-query | tail -n 1) && run $file'
752     '')
753     (pkgs.writeShellScriptBin "set-wallpaper" ''
754       ${pkgs.feh}/bin/feh --bg-fill --no-fehbg ${wallpaper}
755     '')
756     (pkgs.writeShellScriptBin "mirror-phone" "IP=$(select-ip) && sudo scrcpy --tcpip=$IP --no-audio -K --kill-adb-on-close")
757     (pkgs.writeShellScriptBin "select-ip" ''
758       FILE=$HOME/.cache/select-ip.txt
759       IP=$( ${pkgs.rofi}/bin/rofi -dmenu -input $FILE -p IP ) || exit 1
760       echo $IP >> $FILE
761       gawk -i inplace 'FNR==1{delete a} !a[$0]++' $FILE
762       echo $IP
763     '')
764     (pkgs.writeShellScriptBin "create-repo" ''
765       ssh psch.dev sudo -u git git init --bare /srv/git/$1
766     '')
767   ];
768
769   # Home Manager is pretty good at managing dotfiles. The primary way to manage
770   # plain files is through 'home.file'.
771   home.file = {
772     # # Building this configuration will create a copy of 'dotfiles/screenrc' in
773     # # the Nix store. Activating the configuration will then make '~/.screenrc' a
774     # # symlink to the Nix store copy.
775     # ".screenrc".source = dotfiles/screenrc;
776
777     # # You can also set the file content immediately.
778     # ".gradle/gradle.properties".text = ''
779     #   org.gradle.console=verbose
780     #   org.gradle.daemon.idletimeout=3600000
781     # '';
782   };
783
784   # Home Manager can also manage your environment variables through
785   # 'home.sessionVariables'. These will be explicitly sourced when using a
786   # shell provided by Home Manager. If you don't want to manage your shell
787   # through Home Manager then you have to manually source 'hm-session-vars.sh'
788   # located at either
789   #
790   #  ~/.nix-profile/etc/profile.d/hm-session-vars.sh
791   #
792   # or
793   #
794   #  ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
795   #
796   # or
797   #
798   #  /etc/profiles/per-user/ps/etc/profile.d/hm-session-vars.sh
799   #
800   home.sessionVariables = {
801     # EDITOR = "emacs";
802   };
803
804   # Let Home Manager install and manage itself.
805   programs.home-manager.enable = true;
806 }