1
0

files.nix 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. { pkgs, lib, ... }:
  2. {
  3. home = {
  4. file = {
  5. bashrc = {
  6. target = ".bashrc";
  7. text = ''
  8. current_git_branch() {
  9. git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
  10. }
  11. shlvl_prompt() {
  12. (( SHLVL > 1 )) && printf '(%d)' "$SHLVL"
  13. }
  14. PS1='$(shlvl_prompt)(\[\033[01;94m\]\u\[\033[00;00m\]@\[\033[01;94m\]\h\[\033[00;00m\]:\[\033[01;34m\]\w\[\033[00m\])\[\033[01;32m\]$(current_git_branch)\[\033[00m\]$ '
  15. alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
  16. home() {
  17. cd "$HOME/home-manager"
  18. "$EDITOR" "$HOME/home-manager/home.nix"
  19. }
  20. flake() {
  21. cd "$HOME/home-manager"
  22. "$EDITOR" "$HOME/home-manager/flake.nix"
  23. }
  24. config() {
  25. "sudo" "$EDITOR" "/etc/nixos/configuration.nix"
  26. }
  27. nix-update() {
  28. set -e
  29. ORIG_CWD="$(pwd)"
  30. sudo nix-channel --update
  31. cd "$HOME/home-manager"
  32. make
  33. sudo nixos-rebuild switch
  34. flatpak update -y
  35. sudo flatpak update -y
  36. cd "$ORIG_CWD"
  37. }
  38. jclone() {
  39. git clone https://github.com/johron/$1
  40. }
  41. '';
  42. };
  43. flameshot = {
  44. target = ".config/flameshot/flameshot.ini";
  45. text = ''
  46. [General]
  47. contrastOpacity=188
  48. showAbortNotification=false
  49. showDesktopNotification=false
  50. showStartupLaunchMessage=false
  51. savePath=/home/johron/Pictures/Screenshots
  52. savePathFixed=true
  53. '';
  54. };
  55. mako = {
  56. target = ".config/mako/config";
  57. text = ''
  58. default-timeout=5000
  59. '';
  60. };
  61. clock = {
  62. target = ".config/waybar/clock.sh";
  63. text = ''
  64. # Generate the formatted date string
  65. formatted_date=$(LC_TIME=nb_NO.UTF-8 date +"%H:%M %A, %b %d" | tr '[:upper:]' '[:lower:]' | sed 's/\.//g')
  66. # Output as JSON for Waybar
  67. printf '{"text": "%s"}\n' "$formatted_date"
  68. '';
  69. executable = true;
  70. };
  71. memory = {
  72. target = ".config/waybar/memory.sh";
  73. text = ''
  74. free -m | awk '
  75. /^Mem:/ {
  76. current_gb = $3 / 1024;
  77. total_gb = $2 / 1024;
  78. printf "{\"text\": \"%.1fG/%.1fG\"}\n", current_gb, total_gb
  79. }'
  80. '';
  81. executable = true;
  82. };
  83. volume = {
  84. target = ".config/waybar/volume.sh";
  85. text = ''
  86. VOLUME_INFO=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
  87. VOL_NUM=$(echo "$VOLUME_INFO" | awk '{print $2}')
  88. VOL_PERC=$(awk -v n="$VOL_NUM" 'BEGIN {print int(n * 100)}')
  89. if [[ "$VOLUME_INFO" == *"[MUTED]"* ]]; then
  90. RESULT="Muted ($VOL_PERC%)"
  91. else
  92. RESULT="$VOL_PERC%"
  93. fi
  94. echo "{\"text\": \"$RESULT\"}"
  95. '';
  96. executable = true;
  97. };
  98. };
  99. };
  100. }