My NixOS configuration.
1{
2 config,
3 lib,
4 environment,
5 ...
6}: {
7 home.file = {
8 ".local/bin/sh_prompt" = {
9 text = ''
10 #!/usr/bin/env bash
11 # dependencies: gum
12 set -e
13
14
15 dec="$(printf "%d\n" "$(head -c 1 /dev/random | od -A n -t u1)")"
16 hex="$(printf "%x\n" "$dec")"
17
18 val="$(gum input --header="What is 0x$hex in decimal?")"
19 while [ "$val" -ne "$dec" ]
20 do
21 gum log -l "error" "Try again."
22 val="$(gum input --header="What is 0x$hex in decimal?")"
23 done
24 '';
25 executable = true;
26 };
27 };
28
29 programs = {
30 direnv = {
31 enable = true;
32 enableZshIntegration = true;
33 nix-direnv.enable = true;
34 };
35
36 starship = {
37 enable = true;
38 enableZshIntegration = true;
39 settings = {
40 add_newline = true;
41 format = lib.concatStrings [
42 "[ ╭── ](white)[$hostname](purple)$directory\n"
43 "[ ╰ ](white)$character"
44 ];
45 right_format = lib.concatStrings [
46 "[$all](gray)"
47 ];
48
49 # Get editor completions based on the config schema
50 "$schema" = "https://starship.rs/config-schema.json";
51
52 character = { # The name of the module we are configuring is 'character'
53 success_symbol = "[λ](green)";
54 error_symbol = "[λ](red)";
55 };
56
57 # Disable the package module, hiding it from the prompt completely
58 package.disabled = false;
59 };
60 };
61
62 tealdeer = {
63 enable = true;
64 settings.updates.auto_update = true;
65 };
66
67 atuin = {
68 enable = true;
69 enableZshIntegration = true;
70 settings = {
71 auto_sync = true;
72 sync_frequency = "5m";
73 sync_address = "https://api.atuin.sh";
74 search_mode = "prefix";
75 };
76 };
77
78 zsh = {
79 enable = true;
80 enableCompletion = true;
81 enableVteIntegration = true;
82 autocd = true;
83 autosuggestion.enable = true;
84 shellAliases = {
85 "compose" = "nvim \"$(mktemp --suffix .md)\"";
86 "config" = "nvim \"~/nixos/hm-modules/rices/\"";
87 "rebuild" = "doas nixos-rebuild -L --flake ~/nixos#fw13 --show-trace";
88 "ls" = "eza";
89 "rm" = "rm -i";
90 };
91 initExtra = ''~/.local/bin/sh_prompt'';
92 envExtra = ''
93# XDG directories
94export XDG_DATA_HOME="$HOME/.local/share"
95export XDG_CONFIG_HOME="$HOME/.config"
96export XDG_STATE_HOME="$HOME/.local/state"
97export XDG_CACHE_HOME="$HOME/.cache"
98
99# paths
100export PATH="$HOME/.local/bin:$XDG_DATA_HOME/cargo/bin:$HOME/.cabal/bin:/opt/texlive/2023/bin/x86_64-linux:$PATH"
101
102# global env vars
103export EDITOR="nvim"
104export READER="zathura"
105export VISUAL="nvim"
106export TERMINAL="st"
107export VIDEO="mpv"
108export OPENER="xdg-open"
109export WM="dwm"
110export LESSHISTFILE=-
111export MANGOHUD=1
112export TEXINPUTS=".:$HOME/casa/Documents/texpackages//::"
113export COLORTERM=truecolor
114export NIXPKGS_ALLOW_UNFREE=1
115
116export CARGO_HOME="$XDG_DATA_HOME"/cargo
117export GNUPGHOME="$XDG_DATA_HOME"/gnupg
118export TERMINFO="$XDG_DATA_HOME"/terminfo
119export TERMINFO_DIRS="$XDG_DATA_HOME"/terminfo:usr/share/terminfo
120export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java
121export PASSWORD_STORE_DIR="$XDG_DATA_HOME"/pass
122export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
123export SPICETIFY_CONFIG="$XDG_CONFIG_HOME/spicetify"
124export W3M_DIR="$XDG_DATA_HOME"/w3m
125export WINEPREFIX="$XDG_DATA_HOME"/wine
126export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority
127export XINITRC="$XDG_CONFIG_HOME"/X11/xinitrc
128. "$XDG_DATA_HOME/cargo/env"
129 '';
130 };
131 };
132}