commit 231b9303ad299d9fe0c23e167438a9867fdeb626 Author: jolheiser Date: Wed Jun 28 15:48:01 2023 -0500 feat: nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..84f7d4c --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +dotfiles manages with NixOS and home-manager + +`just` diff --git a/apps/bat.nix b/apps/bat.nix new file mode 100644 index 0000000..4ad3045 --- /dev/null +++ b/apps/bat.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: { + programs.bat = { + enable = true; + config = { theme = "ctp-mocha"; }; + themes = { + ctp-mocha = builtins.readFile (pkgs.fetchFromGitHub { + owner = "catppuccin"; + repo = "bat"; + rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1"; + sha256 = "1g2r6j33f4zys853i1c5gnwcdbwb6xv5w6pazfdslxf69904lrg9"; + } + "/Catppuccin-mocha.tmTheme"); + }; + }; +} diff --git a/apps/bottom.nix b/apps/bottom.nix new file mode 100644 index 0000000..44843ed --- /dev/null +++ b/apps/bottom.nix @@ -0,0 +1,32 @@ +{ + programs.bottom = { + enable = true; + settings = { + colors = { + table_header_color = "#f5e0dc"; + all_cpu_color = "#f5e0dc"; + avg_cpu_color = "#eba0ac"; + cpu_core_colors = + [ "#f38ba8" "#fab387" "#f9e2af" "#a6e3a1" "#74c7ec" "#cba6f7" ]; + ram_color = "#a6e3a1"; + swap_color = "#fab387"; + rx_color = "#a6e3a1"; + tx_color = "#f38ba8"; + widget_title_color = "#f2cdcd"; + border_color = "#585b70"; + highlighted_border_color = "#f5c2e7"; + text_color = "#cdd6f4"; + graph_color = "#a6adc8"; + cursor_color = "#f5c2e7"; + selected_text_color = "#11111b"; + selected_bg_color = "#cba6f7"; + high_battery_color = "#a6e3a1"; + medium_battery_color = "#f9e2af"; + low_battery_color = "#f38ba8"; + gpu_core_colors = + [ "#74c7ec" "#cba6f7" "#f38ba8" "#fab387" "#f9e2af" "#a6e3a1" ]; + arc_color = "#89dceb"; + }; + }; + }; +} diff --git a/apps/default.nix b/apps/default.nix new file mode 100644 index 0000000..d957bcb --- /dev/null +++ b/apps/default.nix @@ -0,0 +1,51 @@ +{ pkgs, ... }: { + imports = [ + ./bat.nix + ./bottom.nix + ./firefox.nix + ./fzf.nix + ./gpg.nix + ./git.nix + ./go.nix + ./helix.nix + ./jq.nix + ./nushell.nix + ./oh-my-posh.nix + ./ssh.nix + ./wezterm.nix + ./zoxide.nix + ]; + home = { + packages = with pkgs; [ + + # Tools + age + bitwarden-cli + delve + duf + du-dust + fd + just + ripgrep + + # LSPs + gopls + lua-language-server + marksman + nil + nodePackages.yaml-language-server + + # Formatters + black + gofumpt + nodePackages.lua-fmt + nixfmt + + # IDEs + jetbrains.goland + ]; + stateVersion = "22.11"; + }; + + programs = { home-manager.enable = true; }; +} diff --git a/apps/firefox.nix b/apps/firefox.nix new file mode 100644 index 0000000..09c7b2f --- /dev/null +++ b/apps/firefox.nix @@ -0,0 +1,47 @@ +{ pkgs, ... }: { + programs.firefox = { + enable = true; + profiles.default = { + search.default = "DuckDuckGo"; + search.force = true; + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + bitwarden + refined-github + ublock-origin + ]; + settings = { + "app.update.auto" = false; + "browser.formfill.enable" = false; + "browser.tabs.firefox-view" = false; + "browser.aboutConfig.showWarning" = false; + "browser.bookmarks.addedImportButton" = false; + "extensions.pocket.enabled" = false; + "browser.newtabpage.activity-stream.feeds.section.topstories" = false; + "browser.newtabpage.activity-stream.showSponsoredTopSites" = false; + "browser.newtabpage.pinned" = builtins.toJSON [ + { url = "https://mynixos.com/"; } + { url = "https://github.com/"; } + { url = "https://git.jojodev.com/"; } + ]; + }; + bookmarks = [{ + name = "Gitea"; + toolbar = true; + bookmarks = [ + { + name = "gitea"; + tags = [ "gitea" ]; + keyword = "gitea"; + url = "https://github.com/go-gitea/gitea"; + } + { + name = "jojodev"; + tags = [ "gitea" ]; + keyword = "jojodev"; + url = "https://git.jojodev.com"; + } + ]; + }]; + }; + }; +} diff --git a/apps/fzf.nix b/apps/fzf.nix new file mode 100644 index 0000000..34cfef0 --- /dev/null +++ b/apps/fzf.nix @@ -0,0 +1,10 @@ +{ + programs.fzf = { + enable = true; + defaultOptions = [ + "--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8" + "--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc" + "--color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8" + ]; + }; +} diff --git a/apps/git.nix b/apps/git.nix new file mode 100644 index 0000000..2279bbc --- /dev/null +++ b/apps/git.nix @@ -0,0 +1,40 @@ +let key = "0xB853ADA5DA7BBF7A"; +in { + programs.git = { + enable = true; + userName = "jolheiser"; + userEmail = "john.olheiser@gmail.com"; + signing = { + signByDefault = true; + key = key; + }; + aliases = { + wt = "worktree"; + ci = "commit -s -S -m"; + br = "branch"; + aa = "add ."; + adog = "log --all --decorate --oneline --graph"; + poh = "push origin HEAD"; + cb = "checkout -b"; + fu = "fetch upstream"; + fo = "fetch origin"; + }; + lfs.enable = true; + ignores = [ ".idea/" ]; + extraConfig = { + init.defaultBranch = "main"; + merge.conflictstyle = "diff3"; + diff.colorMoved = "default"; + }; + delta = { + enable = true; + options = { + features = "ctp-mocha"; + navigate = true; + light = false; + line-numbers = true; + side-by-side = true; + }; + }; + }; +} diff --git a/apps/go.nix b/apps/go.nix new file mode 100644 index 0000000..0f089ec --- /dev/null +++ b/apps/go.nix @@ -0,0 +1 @@ +{ programs.go.enable = true; } diff --git a/apps/gpg.nix b/apps/gpg.nix new file mode 100644 index 0000000..1b1ad50 --- /dev/null +++ b/apps/gpg.nix @@ -0,0 +1,26 @@ +{ pkgs, ... }: +let key = "0xB853ADA5DA7BBF7A"; +in { + home.packages = with pkgs; [ pinentry ]; + programs.gpg = { + enable = true; + settings = { + default-key = key; + trusted-key = key; + no-comments = true; + no-greeting = true; + no-emit-version = true; + keyid-format = "0xlong"; + list-options = "show-uid-validity"; + verify-options = "show-uid-validity"; + with-fingerprint = true; + with-key-origin = true; + }; + }; + services.gpg-agent = { + enable = true; + enableExtraSocket = true; + enableSshSupport = true; + pinentryFlavor = "gnome3"; + }; +} diff --git a/apps/helix.nix b/apps/helix.nix new file mode 100644 index 0000000..9052328 --- /dev/null +++ b/apps/helix.nix @@ -0,0 +1,207 @@ +{ + programs.helix = { + enable = true; + defaultEditor = true; + settings = { + theme = "catppuccin_mocha_transparent"; + editor = { + line-number = "relative"; + mouse = false; + bufferline = "always"; + color-modes = true; + cursor-shape = { + insert = "bar"; + normal = "block"; + select = "underline"; + }; + file-picker = { hidden = false; }; + indent-guides = { + render = true; + skip-levels = 1; + }; + soft-wrap = { enable = true; }; + statusline = { + right = [ + "version-control" + "diagnostics" + "selections" + "position" + "file-encoding" + ]; + }; + lsp = { display-messages = true; }; + }; + keys = { + normal = { + space = { + q = ":quit"; + Q = ":quit!"; + w = ":write"; + W = ":write!"; + }; + C-c = ":config-open"; + C-r = ":config-reload"; + "C-/" = "toggle_comments"; + S-right = "goto_next_buffer"; + S-left = "goto_previous_buffer"; + C-b = ":buffer-close"; + C-s = [ "select_all" "select_regex" ]; + + C-j = "shrink_selection"; + C-k = "expand_selection"; + C-l = "select_next_sibling"; + C-a = "select_all"; + C-u = [ "half_page_up" "align_view_center" ]; + C-d = [ "half_page_down" "align_view_center" ]; + + "{" = [ "goto_prev_paragraph" "collapse_selection" ]; + "}" = [ "goto_next_paragraph" "collapse_selection" ]; + "0" = "goto_line_start"; + "$" = "goto_line_end"; + "^" = "goto_first_nonwhitespace"; + G = "goto_file_end"; + "%" = "match_brackets"; + V = [ "select_mode" "extend_to_line_bounds" ]; + C = [ "collapse_selection" "extend_to_line_end" "change_selection" ]; + D = [ "extend_to_line_end" "delete_selection" ]; + S = "surround_add"; + + d = { + d = [ "extend_to_line_bounds" "delete_selection" ]; + t = [ "extend_till_char" ]; + s = [ "surround_delete" ]; + i = [ "select_textobject_inner" ]; + a = [ "select_textobject_around" ]; + }; + + x = "delete_selection"; + p = "paste_clipboard_after"; + P = "paste_clipboard_before"; + y = [ + "yank_main_selection_to_clipboard" + "normal_mode" + "flip_selections" + "collapse_selection" + ]; + Y = [ + "extend_to_line_bounds" + "yank_main_selection_to_clipboard" + "goto_line_start" + "collapse_selection" + ]; + + w = [ "move_next_word_start" "move_char_right" "collapse_selection" ]; + e = [ "move_next_word_end" "collapse_selection" ]; + b = [ "move_prev_word_start" "collapse_selection" ]; + + i = [ "insert_mode" "collapse_selection" ]; + a = [ "append_mode" "collapse_selection" ]; + + esc = [ "collapse_selection" "keep_primary_selection" ]; + + }; + insert = { esc = [ "collapse_selection" "normal_mode" ]; }; + select = { + space = { + j = { + e = ":pipe jq"; + c = ":pipe jq -c"; + }; + }; + "{" = [ "extend_to_line_bounds" "goto_prev_paragraph" ]; + "}" = [ "extend_to_line_bounds" "goto_next_paragraph" ]; + "0" = "goto_line_start"; + "$" = "goto_line_end"; + "^" = "goto_first_nonwhitespace"; + G = "goto_file_end"; + D = [ "extend_to_line_bounds" "delete_selection" "normal_mode" ]; + C = [ "goto_line_start" "extend_to_line_bounds" "change_selection" ]; + "%" = "match_brackets"; + S = "surround_add"; + + i = "select_textobject_inner"; + a = "select_textobject_around"; + + tab = [ "insert_mode" "collapse_selection" ]; + C-a = [ "append_mode" "collapse_selection" ]; + + k = [ "extend_line_up" "extend_to_line_bounds" ]; + j = [ "extend_line_down" "extend_to_line_bounds" ]; + + d = [ "yank_main_selection_to_clipboard" "delete_selection" ]; + x = [ "yank_main_selection_to_clipboard" "delete_selection" ]; + y = [ + "yank_main_selection_to_clipboard" + "normal_mode" + "flip_selections" + "collapse_selection" + ]; + Y = [ + "extend_to_line_bounds" + "yank_main_selection_to_clipboard" + "goto_line_start" + "collapse_selection" + "normal_mode" + ]; + p = "replace_selections_with_clipboard"; + P = "paste_clipboard_before"; + + esc = [ "collapse_selection" "keep_primary_selection" "normal_mode" ]; + }; + }; + }; + languages = { + language = [ + { + name = "jsonnet"; + auto-format = true; + formatter = { + command = "jsonnetfmt"; + args = [ "-" ]; + }; + } + { + name = "go"; + formatter = { + command = "gofumpt"; + args = [ ]; + }; + } + { + name = "python"; + auto-format = true; + formatter = { + command = "black"; + args = [ "--quiet" "-" ]; + }; + } + { + name = "nix"; + auto-format = true; + formatter = { + command = "nixfmt"; + args = [ ]; + }; + } + ]; + }; + themes = { + catppuccin_frappe_transparent = { + inherits = "catppuccin_frappe"; + "ui.background" = { }; + }; + catppuccin_latte_transparent = { + inherits = "catppuccin_latte"; + "ui.background" = { }; + }; + catppuccin_macchiato_transparent = { + inherits = "catppuccin_macchiato"; + "ui.background" = { }; + }; + catppuccin_mocha_transparent = { + inherits = "catppuccin_mocha"; + "ui.background" = { }; + }; + }; + }; +} diff --git a/apps/jq.nix b/apps/jq.nix new file mode 100644 index 0000000..3c01c41 --- /dev/null +++ b/apps/jq.nix @@ -0,0 +1 @@ +{ programs.jq.enable = true; } diff --git a/apps/nushell.nix b/apps/nushell.nix new file mode 100644 index 0000000..5aee629 --- /dev/null +++ b/apps/nushell.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: { + programs.nushell = { + enable = true; + configFile.source = ./nushell/config.nu; + envFile.source = ./nushell/env.nu; + shellAliases = { + cat = "bat"; + find = "fd"; + df = "duf"; + du = "dust -b -d 1"; + ll = "ls -al"; + }; + extraConfig = '' + use ${pkgs.nu_scripts}/share/nu_scripts/custom-completions/bitwarden-cli/bitwarden-cli-completions.nu * + use ${pkgs.nu_scripts}/share/nu_scripts/custom-completions/btm/btm-completions.nu * + use ${pkgs.nu_scripts}/share/nu_scripts/custom-completions/git/git-completions.nu * + use ${pkgs.nu_scripts}/share/nu_scripts/custom-completions/glow/glow-completions.nu * + use ${pkgs.nu_scripts}/share/nu_scripts/custom-completions/just/just.nu * + use ${pkgs.nu_scripts}/share/nu_scripts/custom-completions/nix/nix-completions.nu * + ''; + }; + xdg.configFile = { + "nushell/jolheiser.nu".source = ./nushell/jolheiser.nu; + "nushell/zoxide.nu".source = ./nushell/zoxide.nu; + "nushell/ohmyposh.nu".source = ./nushell/ohmyposh.nu; + }; +} diff --git a/apps/nushell/config.nu b/apps/nushell/config.nu new file mode 100644 index 0000000..f4cf541 --- /dev/null +++ b/apps/nushell/config.nu @@ -0,0 +1,650 @@ +# Nushell Config File + +module completions { + # Custom completions for external commands (those outside of Nushell) + # Each completions has two parts: the form of the external command, including its flags and parameters + # and a helper command that knows how to complete values for those flags and parameters + # + # This is a simplified version of completions for git branches and git remotes + def "nu-complete git branches" [] { + ^git branch | lines | each { |line| $line | str replace '[\*\+] ' '' | str trim } + } + + def "nu-complete git remotes" [] { + ^git remote | lines | each { |line| $line | str trim } + } + + # Download objects and refs from another repository + export extern "git fetch" [ + repository?: string@"nu-complete git remotes" # name of the repository to fetch + branch?: string@"nu-complete git branches" # name of the branch to fetch + --all # Fetch all remotes + --append(-a) # Append ref names and object names to .git/FETCH_HEAD + --atomic # Use an atomic transaction to update local refs. + --depth: int # Limit fetching to n commits from the tip + --deepen: int # Limit fetching to n commits from the current shallow boundary + --shallow-since: string # Deepen or shorten the history by date + --shallow-exclude: string # Deepen or shorten the history by branch/tag + --unshallow # Fetch all available history + --update-shallow # Update .git/shallow to accept new refs + --negotiation-tip: string # Specify which commit/glob to report while fetching + --negotiate-only # Do not fetch, only print common ancestors + --dry-run # Show what would be done + --write-fetch-head # Write fetched refs in FETCH_HEAD (default) + --no-write-fetch-head # Do not write FETCH_HEAD + --force(-f) # Always update the local branch + --keep(-k) # Keep downloaded pack + --multiple # Allow several arguments to be specified + --auto-maintenance # Run 'git maintenance run --auto' at the end (default) + --no-auto-maintenance # Don't run 'git maintenance' at the end + --auto-gc # Run 'git maintenance run --auto' at the end (default) + --no-auto-gc # Don't run 'git maintenance' at the end + --write-commit-graph # Write a commit-graph after fetching + --no-write-commit-graph # Don't write a commit-graph after fetching + --prefetch # Place all refs into the refs/prefetch/ namespace + --prune(-p) # Remove obsolete remote-tracking references + --prune-tags(-P) # Remove any local tags that do not exist on the remote + --no-tags(-n) # Disable automatic tag following + --refmap: string # Use this refspec to map the refs to remote-tracking branches + --tags(-t) # Fetch all tags + --recurse-submodules: string # Fetch new commits of populated submodules (yes/on-demand/no) + --jobs(-j): int # Number of parallel children + --no-recurse-submodules # Disable recursive fetching of submodules + --set-upstream # Add upstream (tracking) reference + --submodule-prefix: string # Prepend to paths printed in informative messages + --upload-pack: string # Non-default path for remote command + --quiet(-q) # Silence internally used git commands + --verbose(-v) # Be verbose + --progress # Report progress on stderr + --server-option(-o): string # Pass options for the server to handle + --show-forced-updates # Check if a branch is force-updated + --no-show-forced-updates # Don't check if a branch is force-updated + -4 # Use IPv4 addresses, ignore IPv6 addresses + -6 # Use IPv6 addresses, ignore IPv4 addresses + --help # Display the help message for this command + ] + + # Check out git branches and files + export extern "git checkout" [ + ...targets: string@"nu-complete git branches" # name of the branch or files to checkout + --conflict: string # conflict style (merge or diff3) + --detach(-d) # detach HEAD at named commit + --force(-f) # force checkout (throw away local modifications) + --guess # second guess 'git checkout ' (default) + --ignore-other-worktrees # do not check if another worktree is holding the given ref + --ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only + --merge(-m) # perform a 3-way merge with the new branch + --orphan: string # new unparented branch + --ours(-2) # checkout our version for unmerged files + --overlay # use overlay mode (default) + --overwrite-ignore # update ignored files (default) + --patch(-p) # select hunks interactively + --pathspec-from-file: string # read pathspec from file + --progress # force progress reporting + --quiet(-q) # suppress progress reporting + --recurse-submodules: string # control recursive updating of submodules + --theirs(-3) # checkout their version for unmerged files + --track(-t) # set upstream info for new branch + -b: string # create and checkout a new branch + -B: string # create/reset and checkout a branch + -l # create reflog for new branch + --help # Display the help message for this command + ] + + # Push changes + export extern "git push" [ + remote?: string@"nu-complete git remotes", # the name of the remote + ...refs: string@"nu-complete git branches" # the branch / refspec + --all # push all refs + --atomic # request atomic transaction on remote side + --delete(-d) # delete refs + --dry-run(-n) # dry run + --exec: string # receive pack program + --follow-tags # push missing but relevant tags + --force(-f) # force updates + --ipv4(-4) # use IPv4 addresses only + --ipv6(-6) # use IPv6 addresses only + --mirror # mirror all refs + --no-verify # bypass pre-push hook + --porcelain # machine-readable output + --progress # force progress reporting + --prune # prune locally removed refs + --push-option(-o): string # option to transmit + --quiet(-q) # be more quiet + --receive-pack: string # receive pack program + --recurse-submodules: string # control recursive pushing of submodules + --repo: string # repository + --set-upstream(-u) # set upstream for git pull/status + --signed: string # GPG sign the push + --tags # push tags (can't be used with --all or --mirror) + --thin # use thin pack + --verbose(-v) # be more verbose + --help # Display the help message for this command + ] +} + +# Get just the extern definitions without the custom completion commands +use completions * + +# For more information on themes, see +# https://www.nushell.sh/book/coloring_and_theming.html +let dark_theme = { + # color for nushell primitives + separator: white + leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off + header: green_bold + empty: blue + # Closures can be used to choose colors for specific values. + # The value (in this case, a bool) is piped into the closure. + bool: { if $in { 'light_cyan' } else { 'light_gray' } } + int: white + filesize: {|e| + if $e == 0b { + 'white' + } else if $e < 1mb { + 'cyan' + } else { 'blue' } + } + duration: white + date: { (date now) - $in | + if $in < 1hr { + '#e61919' + } else if $in < 6hr { + '#e68019' + } else if $in < 1day { + '#e5e619' + } else if $in < 3day { + '#80e619' + } else if $in < 1wk { + '#19e619' + } else if $in < 6wk { + '#19e5e6' + } else if $in < 52wk { + '#197fe6' + } else { 'light_gray' } + } + range: white + float: white + string: white + nothing: white + binary: white + cellpath: white + row_index: green_bold + record: white + list: white + block: white + hints: dark_gray + + shape_and: purple_bold + shape_binary: purple_bold + shape_block: blue_bold + shape_bool: light_cyan + shape_custom: green + shape_datetime: cyan_bold + shape_directory: cyan + shape_external: cyan + shape_externalarg: green_bold + shape_filepath: cyan + shape_flag: blue_bold + shape_float: purple_bold + # shapes are used to change the cli syntax highlighting + shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b} + shape_globpattern: cyan_bold + shape_int: purple_bold + shape_internalcall: cyan_bold + shape_list: cyan_bold + shape_literal: blue + shape_matching_brackets: { attr: u } + shape_nothing: light_cyan + shape_operator: yellow + shape_or: purple_bold + shape_pipe: purple_bold + shape_range: yellow_bold + shape_record: cyan_bold + shape_redirection: purple_bold + shape_signature: green_bold + shape_string: green + shape_string_interpolation: cyan_bold + shape_table: blue_bold + shape_variable: purple +} + +let light_theme = { + # color for nushell primitives + separator: dark_gray + leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off + header: green_bold + empty: blue + # Closures can be used to choose colors for specific values. + # The value (in this case, a bool) is piped into the closure. + bool: { if $in { 'dark_cyan' } else { 'dark_gray' } } + int: dark_gray + filesize: {|e| + if $e == 0b { + 'dark_gray' + } else if $e < 1mb { + 'cyan_bold' + } else { 'blue_bold' } + } + duration: dark_gray + date: { (date now) - $in | + if $in < 1hr { + 'red3b' + } else if $in < 6hr { + 'orange3' + } else if $in < 1day { + 'yellow3b' + } else if $in < 3day { + 'chartreuse2b' + } else if $in < 1wk { + 'green3b' + } else if $in < 6wk { + 'darkturquoise' + } else if $in < 52wk { + 'deepskyblue3b' + } else { 'dark_gray' } + } + range: dark_gray + float: dark_gray + string: dark_gray + nothing: dark_gray + binary: dark_gray + cellpath: dark_gray + row_index: green_bold + record: white + list: white + block: white + hints: dark_gray + + shape_and: purple_bold + shape_binary: purple_bold + shape_block: blue_bold + shape_bool: light_cyan + shape_custom: green + shape_datetime: cyan_bold + shape_directory: cyan + shape_external: cyan + shape_externalarg: green_bold + shape_filepath: cyan + shape_flag: blue_bold + shape_float: purple_bold + # shapes are used to change the cli syntax highlighting + shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b} + shape_globpattern: cyan_bold + shape_int: purple_bold + shape_internalcall: cyan_bold + shape_list: cyan_bold + shape_literal: blue + shape_matching_brackets: { attr: u } + shape_nothing: light_cyan + shape_operator: yellow + shape_or: purple_bold + shape_pipe: purple_bold + shape_range: yellow_bold + shape_record: cyan_bold + shape_redirection: purple_bold + shape_signature: green_bold + shape_string: green + shape_string_interpolation: cyan_bold + shape_table: blue_bold + shape_variable: purple +} + +# External completer example +# let carapace_completer = {|spans| +# carapace $spans.0 nushell $spans | from json +# } + + +# The default config record. This is where much of your global configuration is setup. +let-env config = { + ls: { + use_ls_colors: true # use the LS_COLORS environment variable to colorize output + clickable_links: true # enable or disable clickable links. Your terminal has to support links. + } + rm: { + always_trash: false # always act as if -t was given. Can be overridden with -p + } + cd: { + abbreviations: false # allows `cd s/o/f` to expand to `cd some/other/folder` + } + table: { + mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other + index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + trim: { + methodology: wrapping # wrapping or truncating + wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology + truncating_suffix: "..." # A suffix used by the 'truncating' methodology + } + } + + explore: { + help_banner: false + exit_esc: true + + command_bar_text: '#C4C9C6' + # command_bar: {fg: '#C4C9C6' bg: '#223311' } + + status_bar_background: {fg: '#1D1F21' bg: '#C4C9C6' } + # status_bar_text: {fg: '#C4C9C6' bg: '#223311' } + + highlight: {bg: 'yellow' fg: 'black' } + + status: { + # warn: {bg: 'yellow', fg: 'blue'} + # error: {bg: 'yellow', fg: 'blue'} + # info: {bg: 'yellow', fg: 'blue'} + } + + try: { + # border_color: 'red' + # highlighted_color: 'blue' + + # reactive: false + } + + table: { + split_line: '#404040' + + cursor: true + + line_index: true + line_shift: true + line_head_top: true + line_head_bottom: true + + show_head: true + show_index: true + + # selected_cell: {fg: 'white', bg: '#777777'} + # selected_row: {fg: 'yellow', bg: '#C1C2A3'} + # selected_column: blue + + # padding_column_right: 2 + # padding_column_left: 2 + + # padding_index_left: 2 + # padding_index_right: 1 + } + + config: { + cursor_color: {bg: 'yellow' fg: 'black' } + + # border_color: white + # list_color: green + } + } + + history: { + max_size: 10000 # Session has to be reloaded for this to take effect + sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file + file_format: "plaintext" # "sqlite" or "plaintext" + } + completions: { + case_sensitive: false # set to true to enable case-sensitive completions + quick: true # set this to false to prevent auto-selecting completions when only one remains + partial: true # set this to false to prevent partial filling of the prompt + algorithm: "prefix" # prefix or fuzzy + external: { + enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up my be very slow + max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options + completer: null # check 'carapace_completer' above as an example + } + } + filesize: { + metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto + } + color_config: $dark_theme # if you want a light theme, replace `$dark_theme` to `$light_theme` + use_grid_icons: true + footer_mode: "25" # always, never, number_of_rows, auto + float_precision: 2 + # buffer_editor: "emacs" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + use_ansi_coloring: true + edit_mode: emacs # emacs, vi + shell_integration: true # enables terminal markers and a workaround to arrow keys stop working issue + show_banner: false # true or false to enable or disable the banner + render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. + + hooks: { + pre_prompt: [{ + null # replace with source code to run before the prompt is shown + }] + pre_execution: [{ + null # replace with source code to run before the repl input is run + }] + env_change: { + PWD: [{|before, after| + null # replace with source code to run if the PWD environment is different since the last repl input + }] + } + display_output: { + if (term size).columns >= 100 { table -e } else { table } + } + } + menus: [ + # Configuration for default nushell menus + # Note the lack of source parameter + { + name: completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: columnar + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: history_menu + only_buffer_difference: true + marker: "? " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: help_menu + only_buffer_difference: true + marker: "? " + type: { + layout: description + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + # Example of extra menus created using a nushell source + # Use the source field to create a list of records that populates + # the menu + { + name: commands_menu + only_buffer_difference: false + marker: "# " + type: { + layout: columnar + columns: 4 + col_width: 20 + col_padding: 2 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + source: { |buffer, position| + $nu.scope.commands + | where name =~ $buffer + | each { |it| {value: $it.name description: $it.usage} } + } + } + { + name: vars_menu + only_buffer_difference: true + marker: "# " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + source: { |buffer, position| + $nu.scope.vars + | where name =~ $buffer + | sort-by name + | each { |it| {value: $it.name description: $it.type} } + } + } + { + name: commands_with_description + only_buffer_difference: true + marker: "# " + type: { + layout: description + columns: 4 + col_width: 20 + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + source: { |buffer, position| + $nu.scope.commands + | where name =~ $buffer + | each { |it| {value: $it.name description: $it.usage} } + } + } + ] + keybindings: [ + { + name: completion_menu + modifier: none + keycode: tab + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: completion_menu } + { send: menunext } + ] + } + } + { + name: completion_previous + modifier: shift + keycode: backtab + mode: [emacs, vi_normal, vi_insert] # Note: You can add the same keybinding to all modes by using a list + event: { send: menuprevious } + } + { + name: history_menu + modifier: control + keycode: char_r + mode: emacs + event: { send: menu name: history_menu } + } + { + name: next_page + modifier: control + keycode: char_x + mode: emacs + event: { send: menupagenext } + } + { + name: undo_or_previous_page + modifier: control + keycode: char_z + mode: emacs + event: { + until: [ + { send: menupageprevious } + { edit: undo } + ] + } + } + { + name: yank + modifier: control + keycode: char_y + mode: emacs + event: { + until: [ + {edit: pastecutbufferafter} + ] + } + } + { + name: unix-line-discard + modifier: control + keycode: char_u + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {edit: cutfromlinestart} + ] + } + } + { + name: kill-line + modifier: control + keycode: char_k + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {edit: cuttolineend} + ] + } + } + # Keybindings used to trigger the user defined menus + { + name: commands_menu + modifier: control + keycode: char_t + mode: [emacs, vi_normal, vi_insert] + event: { send: menu name: commands_menu } + } + { + name: vars_menu + modifier: alt + keycode: char_o + mode: [emacs, vi_normal, vi_insert] + event: { send: menu name: vars_menu } + } + { + name: commands_with_description + modifier: control + keycode: char_s + mode: [emacs, vi_normal, vi_insert] + event: { send: menu name: commands_with_description } + } + ] +} + + +source ~/.config/nushell/jolheiser.nu + diff --git a/apps/nushell/env.nu b/apps/nushell/env.nu new file mode 100644 index 0000000..3006c8d --- /dev/null +++ b/apps/nushell/env.nu @@ -0,0 +1,63 @@ +# Nushell Environment Config File + +def create_left_prompt [] { + let path_segment = if (is-admin) { + $"(ansi red_bold)($env.PWD)" + } else { + $"(ansi green_bold)($env.PWD)" + } + + $path_segment +} + +def create_right_prompt [] { + let time_segment = ([ + (date now | date format '%m/%d/%Y %r') + ] | str join) + + $time_segment +} + +# Use nushell functions to define your right and left prompt +let-env PROMPT_COMMAND = { create_left_prompt } +let-env PROMPT_COMMAND_RIGHT = { create_right_prompt } + +# The prompt indicators are environmental variables that represent +# the state of the prompt +let-env PROMPT_INDICATOR = { "〉" } +let-env PROMPT_INDICATOR_VI_INSERT = { ": " } +let-env PROMPT_INDICATOR_VI_NORMAL = { "〉" } +let-env PROMPT_MULTILINE_INDICATOR = { "::: " } + +# Specifies how environment variables are: +# - converted from a string to a value on Nushell startup (from_string) +# - converted from a value back to a string when running external commands (to_string) +# Note: The conversions happen *after* config.nu is loaded +let-env ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand -n } + to_string: { |v| $v | path expand -n | str join (char esep) } + } + "Path": { + from_string: { |s| $s | split row (char esep) | path expand -n } + to_string: { |v| $v | path expand -n | str join (char esep) } + } +} + +# Directories to search for scripts when calling source or use +# +# By default, /scripts is added +let-env NU_LIB_DIRS = [ + ($nu.config-path | path dirname | path join 'scripts') +] + +# Directories to search for plugin binaries when calling register +# +# By default, /plugins is added +let-env NU_PLUGIN_DIRS = [ + ($nu.config-path | path dirname | path join 'plugins') +] + +# To add entries to PATH (on Windows you might use Path), you can use the following pattern: +# let-env PATH = ($env.PATH | split row (char esep) | prepend '/some/path') + diff --git a/apps/nushell/jolheiser.nu b/apps/nushell/jolheiser.nu new file mode 100644 index 0000000..6811627 --- /dev/null +++ b/apps/nushell/jolheiser.nu @@ -0,0 +1,20 @@ +## Aliases ## +alias cat = bat +alias find = fd +alias df = duf +alias du = dust -b -d 1 +alias just = just --shell "nu" --shell-arg "-c" +alias ll = ls -al +def day [] { date now | date format "%a %b %d" } + +## Functions ## +def sshdev [port: int = 8080] { + $"Listening on localhost:($port)" + ^ssh -i ~/.ssh/dev -N -T -R $"1337:localhost:($port)" dev@jolheiser.com +} + +## Other ## +let-env config = ($env.config | upsert "shell_integration" ("WEZTERM_PANE" not-in $env and "SSH_CLIENT" not-in $env)) +source ~/.config/nushell/zoxide.nu +source ~/.config/nushell/ohmyposh.nu + diff --git a/apps/nushell/ohmyposh.nu b/apps/nushell/ohmyposh.nu new file mode 100644 index 0000000..39dfcb0 --- /dev/null +++ b/apps/nushell/ohmyposh.nu @@ -0,0 +1,25 @@ +export-env { + let-env POWERLINE_COMMAND = 'oh-my-posh' + let-env POSH_THEME = "~/.config/oh-my-posh/config.json" + let-env PROMPT_INDICATOR = "" + let-env POSH_PID = (random uuid) + # By default displays the right prompt on the first line + # making it annoying when you have a multiline prompt + # making the behavior different compared to other shells + let-env PROMPT_COMMAND_RIGHT = {''} + let-env NU_VERSION = (version | get version) + + # PROMPTS + let-env PROMPT_MULTILINE_INDICATOR = (^oh-my-posh print secondary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)") + + let-env PROMPT_COMMAND = { + # We have to do this because the initial value of `$env.CMD_DURATION_MS` is always `0823`, + # which is an official setting. + # See https://github.com/nushell/nushell/discussions/6402#discussioncomment-3466687. + let cmd_duration = if $env.CMD_DURATION_MS == "0823" { 0 } else { $env.CMD_DURATION_MS } + + let width = ((term size).columns | into string) + ^oh-my-posh print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)" $"--execution-time=($cmd_duration)" $"--error=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" + } +} + diff --git a/apps/nushell/zoxide.nu b/apps/nushell/zoxide.nu new file mode 100644 index 0000000..a0c4e1b --- /dev/null +++ b/apps/nushell/zoxide.nu @@ -0,0 +1,60 @@ +# Code generated by zoxide. DO NOT EDIT. + +# ============================================================================= +# +# Hook configuration for zoxide. +# + +# Initialize hook to add new entries to the database. +if (not ($env | default false __zoxide_hooked | get __zoxide_hooked)) { + let-env __zoxide_hooked = true + let-env config = ($env | default {} config).config + let-env config = ($env.config | default {} hooks) + let-env config = ($env.config | update hooks ($env.config.hooks | default {} env_change)) + let-env config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD)) + let-env config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_change.PWD | append {|_, dir| + zoxide add -- $dir + })) +} + +# ============================================================================= +# +# When using zoxide with --no-cmd, alias these internal functions as desired. +# + +# Jump to a directory using only keywords. +def-env __zoxide_z [...rest:string] { + let arg0 = ($rest | append '~').0 + let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) { + $arg0 + } else { + (zoxide query --exclude $env.PWD -- $rest | str trim -r -c "\n") + } + cd $path +} + +# Jump to a directory using interactive search. +def-env __zoxide_zi [...rest:string] { + cd $'(zoxide query --interactive -- $rest | str trim -r -c "\n")' +} + +# ============================================================================= +# +# Commands for zoxide. Disable these using --no-cmd. +# + +alias z = __zoxide_z +alias zi = __zoxide_zi + +# ============================================================================= +# +# Add this to your env file (find it by running `$nu.env-path` in Nushell): +# +# zoxide init nushell | save -f ~/.zoxide.nu +# +# Now, add this to the end of your config file (find it by running +# `$nu.config-path` in Nushell): +# +# source ~/.zoxide.nu +# +# Note: zoxide only supports Nushell v0.73.0 and above. diff --git a/apps/oh-my-posh.nix b/apps/oh-my-posh.nix new file mode 100644 index 0000000..156a4cc --- /dev/null +++ b/apps/oh-my-posh.nix @@ -0,0 +1,7 @@ +{ + programs.oh-my-posh = { + enable = true; + settings = builtins.fromJSON (builtins.unsafeDiscardStringContext + (builtins.readFile ./ohmyposh/config.json)); + }; +} diff --git a/apps/ohmyposh/config.json b/apps/ohmyposh/config.json new file mode 100644 index 0000000..865c815 --- /dev/null +++ b/apps/ohmyposh/config.json @@ -0,0 +1,106 @@ +{ + "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", + "blocks": [ + { + "alignment": "left", + "segments": [ + { + "background": "p:lavender", + "foreground": "p:black", + "leading_diamond": "\ue0b6", + "properties": { + "display_host": false + }, + "style": "diamond", + "template": " {{ if .SSHSession }}\udb80\udf18 {{ end }}{{ .UserName }}@{{ .HostName }} ", + "trailing_diamond": "\ue0b0", + "type": "session" + }, + { + "background": "p:orange", + "foreground": "p:black", + "powerline_symbol": "\ue0b0", + "properties": { + "home_icon": "~", + "style": "folder" + }, + "style": "powerline", + "template": " \ue613 {{ path .Path .Location }} ", + "type": "path" + }, + { + "background": "p:green", + "background_templates": [ + "{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}", + "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}", + "{{ if gt .Ahead 0 }}#49416D{{ end }}", + "{{ if gt .Behind 0 }}#7A306C{{ end }}" + ], + "foreground": "p:black", + "foreground_templates": [ + "{{ if or (.Working.Changed) (.Staging.Changed) }}p:black{{ end }}", + "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:white{{ end }}", + "{{ if gt .Ahead 0 }}p:white{{ end }}" + ], + "powerline_symbol": "\ue0b0", + "properties": { + "branch_max_length": 25, + "fetch_status": true, + "fetch_upstream_icon": true, + "github_icon": "\uf408", + "git_icon": "\ue702", + "upstream_icons": { + "gitea.com": "\udb83\udd9e", + "git.jojodev.com": "\udb83\udd9e", + "codeberg.org": "\ue2a6" + } + }, + "style": "powerline", + "template": " {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }} ", + "type": "git" + }, + { + "background": "p:yellow", + "foreground": "p:black", + "powerline_symbol": "\ue0b0", + "properties": { + "root_icon": "\uf0ad" + }, + "style": "powerline", + "template": " \uf0e7 ", + "type": "root" + }, + { + "background": "p:blue", + "background_templates": [ + "{{ if gt .Code 0 }}p:red{{ end }}" + ], + "foreground": "p:black", + "leading_diamond": "\ue0b0", + "properties": { + "always_enabled": true + }, + "style": "diamond", + "template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ", + "trailing_diamond": "\ue0b4", + "type": "exit" + } + ], + "type": "prompt" + } + ], + "console_title_template": "{{ .Shell }} in {{ .Folder }}", + "final_space": true, + "palette": { + "black": "#1E1E1E", + "blue": "#89B4FA", + "green": "#A6E3A1", + "orange": "#FAB387", + "red": "#F38BA8", + "white": "#CDD6F4", + "yellow": "#F9E2AF", + "lavender": "#B4BEFE" + }, + "version": 2 +} + diff --git a/apps/ssh.nix b/apps/ssh.nix new file mode 100644 index 0000000..d518b98 --- /dev/null +++ b/apps/ssh.nix @@ -0,0 +1,6 @@ +{ + programs.ssh = { + enable = true; + extraConfig = builtins.readFile ./ssh/config; + }; +} diff --git a/apps/ssh/config b/apps/ssh/config new file mode 100644 index 0000000..aa96b12 --- /dev/null +++ b/apps/ssh/config @@ -0,0 +1,9 @@ +Host jolheiser + HostName jolheiser.com + User jolheiser + IdentityFile ~/.ssh/jolheiser + +Host jojodev + HostName jojodev.com + User jolheiser + IdentityFile ~/.ssh/jojodev diff --git a/apps/wezterm.nix b/apps/wezterm.nix new file mode 100644 index 0000000..5c13db6 --- /dev/null +++ b/apps/wezterm.nix @@ -0,0 +1,4 @@ +{ + programs.wezterm.enable = true; + xdg.configFile."wezterm/wezterm.lua".source = ./wezterm/wezterm.lua; +} diff --git a/apps/wezterm/wezterm.lua b/apps/wezterm/wezterm.lua new file mode 100644 index 0000000..25e6431 --- /dev/null +++ b/apps/wezterm/wezterm.lua @@ -0,0 +1,86 @@ +local wezterm = require "wezterm" + +-- Choose theme based on system +function theme_for_appearance(appearance) + if appearance:find "Dark" then + return "Catppuccin Mocha" + else + return "Catppuccin Latte" + end +end + +-- Update right status with "mode" +wezterm.on('update-right-status', function(window, pane) + local name = window:active_key_table() + if name then + name = " " .. string.upper(string.sub(name, 1, 1)) .. " " + end + window:set_right_status(name or '') +end) + +-- Toggle opacity +local opacity = 0.8 +wezterm.on('toggle-opacity', function(window, pane) + if opacity == 0.8 then + opacity = 0.9 + elseif opacity == 0.9 then + opacity = 1.0 + else + opacity = 0.8 + end + window:set_config_overrides({ window_background_opacity = opacity }) +end) + +-- config +return { + default_prog = { "nu", "--config", "~/.config/nushell/config.nu", "--env-config", "~/.config/nushell/config.nu" }, + color_scheme = theme_for_appearance(wezterm.gui.get_appearance()), + window_close_confirmation = 'NeverPrompt', + window_background_opacity = opacity, + window_decorations = "RESIZE", + leader = { + key = "Space", + mods = "CTRL", + timeout_milliseconds = math.maxinteger, + }, + keys = { + { key = "p", mods = "LEADER", action = wezterm.action.ActivateKeyTable({ name = "pane_mode", one_shot = false }) }, + { key = "h", mods = "SHIFT|CTRL|ALT", action = wezterm.action.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, + { key = "v", mods = "SHIFT|CTRL|ALT", action = wezterm.action.SplitVertical({ domain = "CurrentPaneDomain" }) }, + { key = "c", mods = "SHIFT|CTRL|ALT", action = wezterm.action.CloseCurrentPane({ confirm = false }) }, + { key = "s", mods = "SHIFT|CTRL|ALT", action = wezterm.action.PaneSelect({ alphabet = "1234567890", mode = "SwapWithActive" }) }, + + { key = "o", mods = "SHIFT|CTRL|ALT", action = wezterm.action.EmitEvent("toggle-opacity") }, + + { key = "1", mods = "LEADER", action = wezterm.action.ActivateTab(0) }, + { key = "2", mods = "LEADER", action = wezterm.action.ActivateTab(1) }, + { key = "3", mods = "LEADER", action = wezterm.action.ActivateTab(2) }, + { key = "4", mods = "LEADER", action = wezterm.action.ActivateTab(3) }, + { key = "5", mods = "LEADER", action = wezterm.action.ActivateTab(4) }, + { key = "6", mods = "LEADER", action = wezterm.action.ActivateTab(5) }, + { key = "7", mods = "LEADER", action = wezterm.action.ActivateTab(6) }, + { key = "8", mods = "LEADER", action = wezterm.action.ActivateTab(7) }, + { key = "9", mods = "LEADER", action = wezterm.action.ActivateTab(8) }, + { key = "0", mods = "LEADER", action = wezterm.action.ActivateTab(-1) }, + }, + key_tables = { + pane_mode = { + { key = "h", action = wezterm.action.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, + { key = "v", action = wezterm.action.SplitVertical({ domain = "CurrentPaneDomain" }) }, + { key = "c", action = wezterm.action.CloseCurrentPane({ confirm = false }) }, + { key = "s", action = wezterm.action.PaneSelect({ alphabet = "1234567890", mode = "SwapWithActive" }) }, + { key = "LeftArrow", action = wezterm.action.ActivatePaneDirection("Left") }, + { key = "UpArrow", action = wezterm.action.ActivatePaneDirection("Up") }, + { key = "RightArrow", action = wezterm.action.ActivatePaneDirection("Right") }, + { key = "DownArrow", action = wezterm.action.ActivatePaneDirection("Down") }, + { key = "Delete", action = wezterm.action.CloseCurrentPane({ confirm = false }) }, + { key = "LeftArrow", mods = "SHIFT", action = wezterm.action.AdjustPaneSize({ "Left", 1 }) }, + { key = "RightArrow", mods = "SHIFT", action = wezterm.action.AdjustPaneSize({ "Right", 1 }) }, + { key = "UpArrow", mods = "SHIFT", action = wezterm.action.AdjustPaneSize({ "Up", 1 }) }, + { key = "DownArrow", mods = "SHIFT", action = wezterm.action.AdjustPaneSize({ "Down", 1 }) }, + { key = "Escape", action = "PopKeyTable" }, + }, + }, +} + + diff --git a/apps/zoxide.nix b/apps/zoxide.nix new file mode 100644 index 0000000..d548416 --- /dev/null +++ b/apps/zoxide.nix @@ -0,0 +1 @@ +{ programs.zoxide.enable = true; } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d7f6729 --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1687969886, + "narHash": "sha256-tC2qFLmuM0PFaw0tMHVcFmzsG/351q09qa1EpuL2n1U=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "a7002d6bfca54742d5fc9b485a1879953b4585b9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687977148, + "narHash": "sha256-gUcXiU2GgjYIc65GOIemdBJZ+lkQxuyIh7OkR9j0gCo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "60a783e00517fce85c42c8c53fe0ed05ded5b2a4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nur": { + "locked": { + "lastModified": 1688125565, + "narHash": "sha256-QRk4rycseCsCLKpC5KImw+3ypG6wRRBuytU1jLAKvT8=", + "owner": "nix-community", + "repo": "nur", + "rev": "57b0c0f3b43b869d3fe5356062e29fd061013ea7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nur", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nur": "nur" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9f4a60f --- /dev/null +++ b/flake.nix @@ -0,0 +1,61 @@ +{ + description = "jolheiser's nixos config"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + nur.url = "github:nix-community/nur"; + }; + + nixConfig = { warn-dirty = false; }; + + outputs = { self, nixpkgs, home-manager, ... }@inputs: + let + overlays = final: prev: { + nur = import inputs.nur { + nurpkgs = prev; + pkgs = prev; + }; + }; + commonConfig = { username }: + ({ config, pkgs, ... }: { + config = { + nixpkgs.overlays = [ overlays ]; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + sharedModules = [ + # inputs.jolheiser-nur.homeManagerModules.default + ]; + users.${username}.imports = [ ./apps ]; + extraSpecialArgs = { + flakePath = "/home/${username}/.config/nixpkgs"; + }; + }; + }; + }); + in { + nixosConfigurations = { + "chai" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + home-manager.nixosModules.home-manager + ./machines/common + ./machines/chai + (commonConfig { username = "jolheiser"; }) + ]; + }; + "matcha" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + home-manager.nixosModules.home-manager + ./machines/common + ./machines/matcha + (commonConfig { username = "jolheiser"; }) + ]; + }; + }; + }; +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..4641655 --- /dev/null +++ b/justfile @@ -0,0 +1,16 @@ +[private] +default: + @just --choose + +[private] +rebuild *args: + @git add . + @sudo nixos-rebuild --flake . {{args}} + +# Rebuild the current machine +switch: + @just rebuild switch + +# Update the flake +update: + @nix flake update diff --git a/machines/chai/default.nix b/machines/chai/default.nix new file mode 100644 index 0000000..47f84bb --- /dev/null +++ b/machines/chai/default.nix @@ -0,0 +1,56 @@ +{ pkgs, ... }: +let username = "jolheiser"; +in { + imports = [ ./hardware.nix ../common ]; + + boot = { + kernelPackages = pkgs.linuxPackages_latest; + kernelParams = [ "quiet" "splash" ]; + loader.efi.canTouchEfiVariables = true; + loader.systemd-boot.enable = true; + initrd.systemd.enable = true; + }; + + hardware = { bluetooth.enable = true; }; + + networking = { + hostName = "chai"; + networkmanager.enable = true; + firewall.enable = true; + }; + + boot.initrd.luks.devices = { + "luks-83586073-35f8-438d-9203-99f1e966c2ca" = { + device = "/dev/disk/by-uuid/83586073-35f8-438d-9203-99f1e966c2ca"; + keyFile = "/crypto_keyfile.bin"; + }; + }; + + services = { + blueman.enable = true; + pcscd.enable = true; + openssh = { + enable = true; + settings = { X11Forwarding = true; }; + }; + }; + + virtualisation.docker.enable = true; + + users.users."${username}" = { + extraGroups = [ "wheel" "docker" ]; + isNormalUser = true; + shell = pkgs.nushell; + }; + + environment.systemPackages = with pkgs; [ + xorg.xauth + teams + jetbrains.pycharm-professional + jetbrains.idea-ultimate + jetbrains.datagrip + subversion + ]; + + system.stateVersion = "22.11"; +} diff --git a/machines/chai/hardware.nix b/machines/chai/hardware.nix new file mode 100644 index 0000000..1994641 --- /dev/null +++ b/machines/chai/hardware.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot.initrd.availableKernelModules = + [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/b8a0cc98-5882-4b69-a8cb-375726767606"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-bd0a4998-266e-4aae-8f20-89561a2fa169".device = + "/dev/disk/by-uuid/bd0a4998-266e-4aae-8f20-89561a2fa169"; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/5531-69DC"; + fsType = "vfat"; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/eb7acf5d-e5db-45fa-8691-8ef5641cde68"; }]; + + networking.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/machines/common/default.nix b/machines/common/default.nix new file mode 100644 index 0000000..4139750 --- /dev/null +++ b/machines/common/default.nix @@ -0,0 +1,61 @@ +{ pkgs, ... }: { + imports = [ ./sound.nix ./xserver.nix ]; + + console.colors = [ + "1e1e2e" + "585b70" + + "bac2de" + "a6adc8" + + "f38ba8" + "f38ba8" + + "a6e3a1" + "a6e3a1" + + "f9e2af" + "f9e2af" + + "89b4fa" + "89b4fa" + + "f5c2e7" + "f5c2e7" + + "94e2d5" + "94e2d5" + ]; + + time.timeZone = "America/Chicago"; + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + nixpkgs.config.allowUnfree = true; + + nix = { + gc.automatic = true; + package = pkgs.nixVersions.nix_2_15; + settings = { + experimental-features = [ "flakes" "nix-command" "repl-flake" ]; + auto-optimise-store = true; + }; + }; + + environment = { + systemPackages = with pkgs; [ podman podman-compose podman-tui ]; + }; + + fonts.fonts = with pkgs; + [ (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) ]; +} diff --git a/machines/common/sound.nix b/machines/common/sound.nix new file mode 100644 index 0000000..bcb852a --- /dev/null +++ b/machines/common/sound.nix @@ -0,0 +1,12 @@ +{ + sound.enable = true; + hardware.pulseaudio.enable = false; + security = { rtkit.enable = true; }; + services = { + pipewire = { + enable = true; + pulse.enable = true; + alsa.enable = true; + }; + }; +} diff --git a/machines/common/xserver.nix b/machines/common/xserver.nix new file mode 100644 index 0000000..eb712de --- /dev/null +++ b/machines/common/xserver.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + services.xserver = { + enable = true; + displayManager.lightdm.enable = true; + desktopManager.cinnamon.enable = true; + layout = "us"; + xkbVariant = ""; + }; +} diff --git a/machines/matcha/default.nix b/machines/matcha/default.nix new file mode 100644 index 0000000..44babaf --- /dev/null +++ b/machines/matcha/default.nix @@ -0,0 +1,50 @@ +{ pkgs, ... }: +let username = "jolheiser"; +in { + imports = [ ./hardware.nix ../common ]; + + boot = { + kernelPackages = pkgs.linuxPackages_latest; + kernelParams = [ "quiet" "splash" ]; + loader.grub = { + enable = true; + device = "/dev/sda"; + useOSProber = true; + enableCryptodisk = true; + }; + }; + + boot.initrd.secrets = { "/crypto_keyfile.bin" = null; }; + + boot.initrd.luks.devices = { + "luks-1f9bde68-9c4c-423c-a95f-17aa170dd2b4".keyFile = "/crypto_keyfile.bin"; + "luks-a2ca1842-1ce0-437e-ba5e-8864a41e81cb" = { + device = "/dev/disk/by-uuid/a2ca1842-1ce0-437e-ba5e-8864a41e81cb"; + keyFile = "/crypto_keyfile.bin"; + }; + }; + + hardware = { bluetooth.enable = true; }; + + networking = { + hostName = "matcha"; + networkmanager.enable = true; + firewall.enable = true; + }; + + services = { + blueman.enable = true; + openssh.enable = true; + pcscd.enable = true; + }; + + virtualisation.docker.enable = true; + + users.users."${username}" = { + extraGroups = [ "wheel" "docker" "storage" ]; + isNormalUser = true; + shell = pkgs.nushell; + }; + + system.stateVersion = "22.11"; +} diff --git a/machines/matcha/hardware.nix b/machines/matcha/hardware.nix new file mode 100644 index 0000000..35e7318 --- /dev/null +++ b/machines/matcha/hardware.nix @@ -0,0 +1,47 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, modulesPath, ... }: { + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot.initrd.availableKernelModules = [ + "xhci_pci" + "ehci_pci" + "ahci" + "usb_storage" + "usbhid" + "sd_mod" + "rtsx_pci_sdmmc" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/a3e3e496-9497-4340-9750-2104e2ab22ab"; + fsType = "ext4"; + }; + + fileSystems."/mnt/hdd" = { + device = "/dev/disk/by-uuid/eb8ad2da-12cf-454b-aa20-e497c4550b7c"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-1f9bde68-9c4c-423c-a95f-17aa170dd2b4".device = + "/dev/disk/by-uuid/1f9bde68-9c4c-423c-a95f-17aa170dd2b4"; + + swapDevices = + [{ device = "/dev/disk/by-uuid/7e84d904-b00a-4c6c-aba4-ec1dde2dff85"; }]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp3s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp5s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; +}