re-organize home-modules

This commit is contained in:
2024-10-19 14:35:08 +02:00
parent f1d7b850fa
commit b95ebd8efc
52 changed files with 36 additions and 30 deletions

133
modules/home/borg.nix Normal file
View File

@@ -0,0 +1,133 @@
{
config,
pkgs,
...
}: let
defaultChecks = [
{
name = "repository";
frequency = "2 weeks";
}
{
name = "archives";
frequency = "4 weeks";
}
{
name = "data";
frequency = "6 weeks";
}
{
name = "extract";
frequency = "6 weeks";
}
];
passwordFile = "${config.home.homeDirectory}/.config/borg/password";
encCmd = ''cat ${passwordFile}'';
repo = "ssh://borg.jroeger.de/./comfy-station";
in {
sops.secrets = {
"borg/password" = {
sopsFile = ../../secrets/jonas/borg.yaml;
key = "password";
path = passwordFile;
};
};
services.borgmatic.enable = true;
services.borgmatic.frequency = "hourly";
programs.borgmatic.enable = true;
programs.borgmatic.backups = {
workspaces = {
location = {
sourceDirectories = ["${config.xdg.userDirs.extraConfig.XDG_WORKSPACES_DIR}"];
repositories = [repo];
excludeHomeManagerSymlinks = true;
extraConfig = {
archive_name_format = "{hostname}-workspaces-{now}";
exclude_patterns = [
"*/.venv"
"__pycache__"
];
};
};
retention = {
keepDaily = 7;
keepHourly = 12;
keepWeekly = 4;
keepMonthly = 6;
};
storage = {
encryptionPasscommand = encCmd;
};
consistency.checks = defaultChecks;
};
media = {
location = {
sourceDirectories = [
"${config.xdg.userDirs.documents}"
"${config.xdg.userDirs.music}"
"${config.xdg.userDirs.pictures}"
"${config.xdg.userDirs.videos}"
];
repositories = [repo];
excludeHomeManagerSymlinks = true;
extraConfig = {
archive_name_format = "{hostname}-media-{now}";
};
};
retention = {
keepDaily = 7;
keepWeekly = 2;
keepMonthly = 6;
};
storage = {
encryptionPasscommand = encCmd;
};
consistency.checks = defaultChecks;
};
sec = {
location = {
sourceDirectories = [
"${config.xdg.configHome}/sops"
];
repositories = [repo];
excludeHomeManagerSymlinks = true;
extraConfig = {
archive_name_format = "{hostname}-sec-{now}";
};
};
retention = {
keepDaily = 7;
keepWeekly = 2;
keepMonthly = 6;
};
storage = {
encryptionPasscommand = encCmd;
};
consistency.checks = defaultChecks;
};
var = {
location = {
sourceDirectories = [
"${config.xdg.userDirs.desktop}"
"${config.xdg.userDirs.download}"
];
repositories = [repo];
excludeHomeManagerSymlinks = true;
extraConfig = {
archive_name_format = "{hostname}-var-{now}";
};
};
retention = {
keepDaily = 7;
keepWeekly = 2;
keepMonthly = 6;
};
storage = {
encryptionPasscommand = encCmd;
};
consistency.checks = defaultChecks;
};
};
}

View File

@@ -0,0 +1,5 @@
{...}: {
imports = [
./doom.nix
];
}

165
modules/home/doom/doom.nix Normal file
View File

@@ -0,0 +1,165 @@
{
config,
pkgs,
lib,
...
}: let
doom-pkgs = with pkgs; [
fira
fira-code-nerdfont
emacs-all-the-icons-fonts
];
doom-path-pkgs = with pkgs; [
(ripgrep.override {withPCRE2 = true;})
binutils
clang-tools
cmake
editorconfig-core-c
fd
gcc
gdb
git
gnumake
gnutls
imagemagick
ispell
libtool
lldb
mermaid-filter
mlocate
nodejs_22
pandoc
pandoc-katex
python311
python311Packages.debugpy
python311Packages.grip
texlab
texlive.combined.scheme-medium
unzip
zstd
];
doom-socket-name = "main";
wrapped-emacs = pkgs.symlinkJoin {
name = "wrapped-emacs";
paths = [pkgs.emacs29-pgtk];
nativeBuildInputs = [pkgs.makeBinaryWrapper];
postBuild = ''
wrapProgram $out/bin/emacs \
--prefix PATH : ${lib.makeBinPath doom-path-pkgs} \
--add-flags "--init-directory=${config.xdg.configHome}/doom-emacs" \
--set DOOMDIR "${config.home.sessionVariables.DOOMDIR}" \
--set DOOMLOCALDIR "${config.home.sessionVariables.DOOMLOCALDIR}" \
--suffix LD_LIBRARY_PATH : "${pkgs.stdenv.cc.cc.lib}/lib"
wrapProgram $out/bin/emacsclient \
--prefix PATH : ${lib.makeBinPath doom-path-pkgs} \
--set DOOMDIR "${config.home.sessionVariables.DOOMDIR}" \
--set DOOMLOCALDIR "${config.home.sessionVariables.DOOMLOCALDIR}" \
--suffix LD_LIBRARY_PATH : "${pkgs.stdenv.cc.cc.lib}/lib" \
--add-flags "--socket-name=${doom-socket-name}"
'';
};
doom-setup = pkgs.writeShellScript "doom-setup" ''
export PATH="${lib.makeBinPath doom-path-pkgs}:$PATH"
export EMACS="${wrapped-emacs}/bin/emacs"
export DOOMDIR="${config.home.sessionVariables.DOOMDIR}"
export DOOMLOCALDIR="${config.home.sessionVariables.DOOMLOCALDIR}"
export LD_LIBRARY_PATH "$LD_LIBRARY_PATH:${pkgs.stdenv.cc.cc.lib}/lib"
if [ ! -d "$DOOMLOCALDIR" ]; then
${config.xdg.configHome}/doom-emacs/bin/doom install --force --no-env
else
${config.xdg.configHome}/doom-emacs/bin/doom "$@"
fi
'';
in {
programs.emacs = {
enable = true;
package = wrapped-emacs;
};
home = {
sessionPath = ["${config.xdg.configHome}/doom-emacs/bin"];
sessionVariables = {
DOOMDIR = "${config.xdg.configHome}/doom-config";
DOOMLOCALDIR = "${config.xdg.configHome}/doom-local";
};
};
systemd.user.services.doom-emacs-server = {
Unit = {
Description = "Doom Emacs Server";
};
Service = {
ExecStart = "${wrapped-emacs}/bin/emacs --fg-daemon=${doom-socket-name}";
SuccessExitStatus = 15;
};
Install = {
WantedBy = []; # Lazy start by socket
};
};
systemd.user.sockets.doom-emacs-server = {
Socket = {
ListenStream = "/run/user/%U/emacs/${doom-socket-name}";
DirectoryMode = "0700";
};
Install = {
WantedBy = ["sockets.target"];
};
};
xdg = {
enable = true;
configFile = {
"doom-config/splash.png" = {
source = ./static/splash.png;
};
"doom-config/config.el" = {
source = ./static/config.el;
};
"doom-config/init.el" = {
source = ./static/init.el;
onChange = "${doom-setup} sync --force -e";
};
"doom-config/packages.el" = {
source = ./static/packages.el;
onChange = "${doom-setup} sync --force -u -e";
};
"doom-emacs" = {
source = builtins.fetchGit {
url = "https://github.com/doomemacs/doomemacs";
rev = "ff3fd15b0249954f3a859e533f6c09a8b1988a72";
};
onChange = "${doom-setup} --force sync -u -e";
};
};
desktopEntries = {
emacs = {
name = "Doom Emacs";
genericName = "Text Editor";
icon = ./static/icon.png;
exec = "${wrapped-emacs}/bin/emacs %F";
terminal = false;
categories = ["Application" "Development" "TextEditor"];
mimeType = ["text/*"];
settings = {
StartupWMClass = "Doom Emacs";
};
};
emacsclient = {
name = "Doom Emacs (Client)";
genericName = "Text Editor";
icon = ./static/icon.png;
exec = ''
sh -c "if [ -n \\"\\$*\\" ]; then exec ${wrapped-emacs}/bin/emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec emacsclient --alternate-editor= --create-frame; fi" sh %F
'';
terminal = false;
categories = ["Application" "Development" "TextEditor"];
mimeType = ["text/*"];
settings = {
StartupWMClass = "Doom Emacs";
};
};
};
};
home.packages = doom-pkgs;
}

View File

@@ -0,0 +1,122 @@
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
;; (setq user-full-name "John Doe"
;; user-mail-address "john@doe.com")
;; Doom exposes five (optional) variables for controlling fonts in Doom:
;;
;; - `doom-font' -- the primary font to use
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;; - `doom-symbol-font' -- for symbols
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;;
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
;;
;; (setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13))
(setq doom-font (font-spec :family "FiraCode Nerd Font" :size 14 :weight 'semi-light)
doom-variable-pitch-font (font-spec :family "Fira Sans" :size 15))
;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-molokai)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")
;; Whenever you reconfigure a package, make sure to wrap your config in an
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
;;
;; (after! PACKAGE
;; (setq x y))
;;
;; The exceptions to this rule:
;;
;; - Setting file/directory variables (like `org-directory')
;; - Setting variables which explicitly tell you to set them before their
;; package is loaded (see 'C-h v VARIABLE' to look up their documentation).
;; - Setting doom variables (which start with 'doom-' or '+').
;;
;; Here are some additional functions/macros that will help you configure Doom.
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
;; etc).
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
(after! treemacs
(setq treemacs-position 'right))
(add-hook 'git-commit-mode-hook #'conventional-commit-setup)
(map! :leader
:desc "Project VTerm" "p RET" #'projectile-run-vterm)
(map! :leader
:desc "File Symbols" "c s" #'consult-lsp-file-symbols
:desc "All Symbols" "c S" #'consult-lsp-symbols)
(use-package! direnv
:config
(direnv-mode))
;; accept completion from copilot and fallback to company
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word)))
(add-hook! 'prog-mode-hook #'undo-tree-mode)
(after! undo-tree
(setq undo-tree-auto-save-history t)
(setq undo-tree-enable-undo-in-region nil)
(setq undo-tree-history-directory-alist '(("." . "~/.cache/doom/undo"))))
(after! markdown-mode
(setq markdown-split-window-direction 'right)
(setq markdown-command "pandoc -t html5 -f markdown_mmd --embed-resources --standalone --mathjax --quiet --highlight-style=zenburn")
(setq markdown-enable-math t))
(add-hook! 'markdown-mode-hook 'pandoc-mode)
(require 'dap-cpptools)
(set-frame-parameter nil 'alpha-background 85)
(add-to-list 'default-frame-alist '(alpha-background . 85))

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View File

@@ -0,0 +1,198 @@
;;; init.el -*- lexical-binding: t; -*-
;; This file controls what Doom modules are enabled and what order they load
;; in. Remember to run 'doom sync' after modifying it!
;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
;; documentation. There you'll find a link to Doom's Module Index where all
;; of our modules are listed, including what flags they support.
;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or
;; 'C-c c k' for non-vim users) to view its documentation. This works on
;; flags as well (those symbols that start with a plus).
;;
;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its
;; directory (for easy access to its source code).
(doom! :input
;;bidi ; (tfel ot) thgir etirw uoy gnipleh
;;chinese
;;japanese
;;layout ; auie,ctsrnm is the superior home row
:completion
(company +childframe) ; the ultimate code completion backend
;;(corfu +orderless) ; complete with cap(f), cape and a flying feather!
;;helm ; the *other* search engine for love and life
;;ido ; the other *other* search engine...
;;ivy ; a search engine for love and life
vertico ; the search engine of the future
:ui
;;deft ; notational velocity for Emacs
doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs
;;doom-quit ; DOOM quit-message prompts when you quit Emacs
(emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;hydra
;;indent-guides ; highlighted indent columns
ligatures ; ligatures and symbols to make your code pretty again
;;minimap ; show a map of the code on the side
modeline ; snazzy, Atom-inspired modeline, plus API
;;nav-flash ; blink cursor line after big motions
;;neotree ; a project drawer, like NERDTree for vim
ophints ; highlight the region an operation acts on
(popup +defaults) ; tame sudden yet inevitable temporary windows
;;tabs ; a tab bar for Emacs
treemacs ; a project drawer, like neotree but cooler
;;unicode ; extended unicode support for various languages
(vc-gutter +pretty) ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
window-select ; visually switch windows
workspaces ; tab emulation, persistence & separate workspaces
zen ; distraction-free coding or writing
:editor
(evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
(format +onsave) ; automated prettiness
;;god ; run Emacs commands without modifier keys
;;lispy ; vim for lisp, for people who don't like vim
;;multiple-cursors ; editing in many places at once
;;objed ; text object editing for the innocent
;;parinfer ; turn lisp into python, sort of
;;rotate-text ; cycle region at point between text candidates
snippets ; my elves. They type so I don't have to
;;word-wrap ; soft wrapping with language-aware indent
:emacs
dired ; making dired pretty [functional]
electric ; smarter, keyword-based electric-indent
;;ibuffer ; interactive buffer management
undo ; persistent, smarter undo for your inevitable mistakes
vc ; version-control and Emacs, sitting in a tree
:term
;;eshell ; the elisp shell that works everywhere
;;shell ; simple shell REPL for Emacs
;;term ; basic terminal emulator for Emacs
vterm ; the best terminal emulation in Emacs
:checkers
syntax ; tasing you for every semicolon you forget
(spell +flyspell) ; tasing you for misspelling mispelling
grammar ; tasing grammar mistake every you make
:tools
;;ansible
;;biblio ; Writes a PhD for you (citation needed)
;;collab ; buffers with friends
(debugger +realgud +lsp) ; FIXME stepping through code, to help you add bugs
;;direnv
;;docker
;;editorconfig ; let someone else argue about tabs vs spaces
ein ; tame Jupyter notebooks with emacs
(eval +overlay) ; run code, run (also, repls)
lookup ; navigate your code and its documentation
lsp ; M-x vscode
magit ; a git porcelain for Emacs
;;make ; run make tasks from Emacs
;;pass ; password manager for nerds
pdf ; pdf enhancements
;;prodigy ; FIXME managing external services & code builders
;;rgb ; creating color strings
;;taskrunner ; taskrunner for all your projects
;;terraform ; infrastructure as code
;;tmux ; an API for interacting with tmux
tree-sitter ; syntax and parsing, sitting in a tree...
;;upload ; map local to remote projects via ssh/ftp
:os
(:if (featurep :system 'macos) macos) ; improve compatibility with macOS
;;tty ; improve the terminal Emacs experience
:lang
;;agda ; types of types of types of types...
;;beancount ; mind the GAAP
(cc +lsp +tree-sitter) ; C > C++ == 1
;;clojure ; java with a lisp
;;common-lisp ; if you've seen one lisp, you've seen them all
;;coq ; proofs-as-programs
;;crystal ; ruby at the speed of c
;;csharp ; unity, .NET, and mono shenanigans
;;data ; config/data formats
;;(dart +flutter) ; paint ui and not much else
;;dhall
;;elixir ; erlang done right
;;elm ; care for a cup of TEA?
emacs-lisp ; drown in parentheses
;;erlang ; an elegant language for a more civilized age
;;ess ; emacs speaks statistics
;;factor
;;faust ; dsp, but you get to keep your soul
;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER)
;;fsharp ; ML stands for Microsoft's Language
;;fstar ; (dependent) types and (monadic) effects and Z3
;;gdscript ; the language you waited for
;;(go +lsp) ; the hipster dialect
;;(graphql +lsp) ; Give queries a REST
;;(haskell +lsp) ; a language that's lazier than I am
;;hy ; readability of scheme w/ speed of python
;;idris ; a language you can depend on
json ; At least it ain't XML
;;(java +lsp) ; the poster child for carpal tunnel syndrome
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
(latex +lsp) ; writing papers in Emacs has never been so fun
;;lean ; for folks with too much to prove
;;ledger ; be audit you can be
;;lua ; one-based indices? one-based indices
markdown ; writing docs for people to ignore
;;nim ; python + lisp at the speed of c
(nix +tree-sitter +lsp) ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel
org ; organize your plain life in plain text
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional
(python +lsp +poetry +pyenv +pyright +tree-sitter) ; beautiful is better than ugly
;;qt ; the 'cutest' gui framework ever
;;racket ; a DSL for DSLs
;;raku ; the artist formerly known as perl6
;;rest ; Emacs as a REST client
;;rst ; ReST in peace
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good
;;(scheme +guile) ; a fully conniving family of lisps
sh ; she sells {ba,z,fi}sh shells on the C xor
;;sml
;;solidity ; do you need a blockchain? No.
;;swift ; who asked for emoji variables?
;;terra ; Earth and Moon in alignment for performance.
;;web ; the tubes
yaml ; JSON, but readable
;;zig ; C, but simpler
:email
;;(mu4e +org +gmail)
;;notmuch
;;(wanderlust +gmail)
:app
;;calendar
;;emms
;;everywhere ; *leave* Emacs!? You must be joking
;;irc ; how neckbeards socialize
;;(rss +org) ; emacs as an RSS reader
;;twitter ; twitter client https://twitter.com/vnought
:config
;;literate
(default +bindings +smartparens))
(setq fancy-splash-image "~/.config/doom-config/splash.png")

View File

@@ -0,0 +1,64 @@
;; -*- no-byte-compile: t; -*-
;;; $DOOMDIR/packages.el
;; To install a package with Doom you must declare them here and run 'doom sync'
;; on the command line, then restart Emacs for the changes to take effect -- or
;; use 'M-x doom/reload'.
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;; (package! some-package)
;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
;; https://github.com/radian-software/straight.el#the-recipe-format
;; (package! another-package
;; :recipe (:host github :repo "username/repo"))
;; If the package you are trying to install does not contain a PACKAGENAME.el
;; file, or is located in a subdirectory of the repo, you'll need to specify
;; `:files' in the `:recipe':
;; (package! this-package
;; :recipe (:host github :repo "username/repo"
;; :files ("some-file.el" "src/lisp/*.el")))
;; If you'd like to disable a package included with Doom, you can do so here
;; with the `:disable' property:
;; (package! builtin-package :disable t)
;; You can override the recipe of a built in package without having to specify
;; all the properties for `:recipe'. These will inherit the rest of its recipe
;; from Doom or MELPA/ELPA/Emacsmirror:
;; (package! builtin-package :recipe (:nonrecursive t))
;; (package! builtin-package-2 :recipe (:repo "myfork/package"))
;; Specify a `:branch' to install a package from a particular branch or tag.
;; This is required for some packages whose default branch isn't 'master' (which
;; our package manager can't deal with; see radian-software/straight.el#279)
;; (package! builtin-package :recipe (:branch "develop"))
;; Use `:pin' to specify a particular commit to install.
;; (package! builtin-package :pin "1a2b3c4d5e")
;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages...
;; (unpin! pinned-package)
;; ...or multiple packages
;; (unpin! pinned-package another-pinned-package)
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
;; (unpin! t)
(package! conventional-commit
:recipe (:host github :repo "akirak/conventional-commit.el" :files ("conventional-commit.el")))
(package! copilot
:recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")))
(package! direnv)
(package! copilot)
(package! undo-tree)
(package! pdf-tools)
(package! eww)
(package! pandoc-mode)
(package! tramp)

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

View File

@@ -0,0 +1,19 @@
{config, ...}: {
services.dunst.settings = {
global = {
origin = "top-right";
frame_color = "#33ccff";
transparency = 20;
background = "#000000";
timeout = 5;
offset = "20x50";
force_xwayland = true;
corner_radius = 15;
};
urgency_critical = {
timeout = 15;
background = "#500005";
};
};
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./dunst.nix
];
}

View File

@@ -0,0 +1,3 @@
{...}: {
services.dunst.enable = true;
}

54
modules/home/firefox.nix Normal file
View File

@@ -0,0 +1,54 @@
{
config,
inputs,
pkgs,
...
}: {
programs.firefox = {
enable = true;
# Default profile
profiles.jonas = {
name = "Jonas";
id = 0;
isDefault = true;
# Search
search = {
default = "DuckDuckGo";
order = ["DuckDuckGo" "Google"];
force = true;
engines = {
"Nix Packages" = {
urls = [
{
template = "https://search.nixos.org/packages";
params = [
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}
];
};
};
};
# Extensions
extensions = with inputs.firefox-addons.packages."x86_64-linux"; [
ublock-origin
violentmonkey
plasma-integration
passff
];
};
};
home.packages = with pkgs; [
passff-host
];
}

View File

@@ -0,0 +1,194 @@
{
config,
pkgs,
lib,
...
}: {
wayland.windowManager.hyprland = lib.mkIf config.wayland.windowManager.hyprland.enable {
settings = {
exec-once = [
"${pkgs.dbus}/bin/dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
"${pkgs.systemd}/bin/systemctl --user import-environment DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
"${pkgs.wpaperd}/bin/wpaperd &"
];
"$mod" = "SUPER";
bind =
[
"$mod, RETURN, exec, ${pkgs.kitty}/bin/kitty"
"$mod, d, exec, ${pkgs.wofi}/bin/wofi --show drun"
"$mod, h, movefocus, l"
"$mod, j, movefocus, d"
"$mod, k, movefocus, u"
"$mod, l, movefocus, r"
"$mod, LEFT, movefocus, l"
"$mod, DOWN, movefocus, d"
"$mod, UP, movefocus, u"
"$mod, RIGHT, movefocus, r"
"$mod SHIFT, h, movewindow, l"
"$mod SHIFT, j, movewindow, d"
"$mod SHIFT, k, movewindow, u"
"$mod SHIFT, l, movewindow, r"
"$mod SHIFT, LEFT, movewindow, l"
"$mod SHIFT, DOWN, movewindow, d"
"$mod SHIFT, UP, movewindow, u"
"$mod SHIFT, RIGHT, movewindow, r"
"$mod CTRL SHIFT, LEFT, moveactive, -10 0"
"$mod CTRL SHIFT, DOWN, moveactive, 0 10"
"$mod CTRL SHIFT, UP, moveactive, 0 -10"
"$mod CTRL SHIFT, RIGHT, moveactive, 10 0"
"$mod CTRL SHIFT, h, moveactive, -10 0"
"$mod CTRL SHIFT, j, moveactive, 0 10"
"$mod CTRL SHIFT, k, moveactive, 0 -10"
"$mod CTRL SHIFT, l, moveactive, 10 0"
"$mod SHIFT, q, killactive"
"$mod CTRL, h, resizeactive, -5% 0%"
"$mod CTRL, l, resizeactive, 5% 0%"
"$mod CTRL, j, resizeactive, 0% -5%"
"$mod CTRL, k, resizeactive, 0% 5%"
"$mod, SPACE, togglefloating, active"
"$mod SHIFT, SPACE, centerwindow"
"$mod, f, fullscreen, 1"
"$mod SHIFT, f, fullscreen, 0"
"$mod CTRL, f, fakefullscreen"
"$mod SHIFT, s, pin"
"$mod SHIFT, x, exec, ${pkgs.hyprland}/bin/hyprctl kill"
", XF86AudioRaiseVolume, exec, ${pkgs.pulsemixer}/bin/pulsemixer --change-volume +5"
", XF86AudioLowerVolume, exec, ${pkgs.pulsemixer}/bin/pulsemixer --change-volume -5"
", XF86AudioMute, exec, ${pkgs.pulsemixer}/bin/pulsemixer --toggle-mute"
", XF86AudioMicMute, exec, ${pkgs.pulsemixer}/bin/pulsemixer --toggle-mute --id 1"
", XF86MonBrightnessUp, exec, ${pkgs.brightnessctl}/bin/brightnessctl set +5%"
", XF86MonBrightnessDown, exec, ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"
"$mod, 0, exec, ${pkgs.wlogout}/bin/wlogout"
]
++ (
# workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
builtins.concatLists (builtins.genList (
x: let
ws = builtins.toString (x + 1);
in [
"$mod, ${ws}, workspace, ${ws}"
"$mod SHIFT, ${ws}, movetoworkspace, ${ws}"
"$mod CTRL, ${ws}, movetoworkspacesilent, ${ws}"
]
)
8)
);
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor = ",preferred,auto,1";
env = [
"GDK_SCALE,1"
"XCURSOR_SIZE,12"
];
xwayland = {
force_zero_scaling = true;
};
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# Execute your favorite apps at launch
# exec-once = waybar & hyprpaper & firefox
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input = {
kb_layout = "de";
kb_variant = "";
kb_model = "";
kb_options = "caps:ctrl_modifier";
kb_rules = "";
follow_mouse = 1;
touchpad = {
natural_scroll = "yes";
};
sensitivity = 0; # -1.0 - 1.0, 0 means no modification.
};
general = {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
gaps_in = 5;
gaps_out = 10;
border_size = 2;
"col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg";
"col.inactive_border" = "rgba(595959aa)";
layout = "dwindle";
# Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
allow_tearing = false;
};
decoration = {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
rounding = 10;
blur = {
enabled = true;
size = 8;
passes = 1;
new_optimizations = true;
};
drop_shadow = "yes";
shadow_range = 4;
shadow_render_power = 3;
"col.shadow" = "rgba(1a1a1aee)";
};
animations = {
enabled = "yes";
# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = "myBezier, 0.05, 0.9, 0.1, 1.05";
animation = [
"windows, 1, 7, myBezier"
"windowsOut, 1, 7, default, popin 80%"
"border, 1, 10, default"
"borderangle, 1, 8, default"
"fade, 1, 7, default"
"workspaces, 1, 6, default"
];
};
dwindle = {
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = "yes"; # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = "yes"; # you probably want this
no_gaps_when_only = 0;
};
master = {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
# new_is_master = true;
no_gaps_when_only = 0;
};
gestures = {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = "off";
};
misc = {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
force_default_wallpaper = 0; # Set to 0 to disable the anime mascot wallpapers
};
# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
# "device:epic-mouse-v1" = {
# sensitivity = -0.5;
# };
};
};
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./hyprland.nix
];
}

View File

@@ -0,0 +1,23 @@
{
pkgs,
...
}: {
wayland.windowManager.hyprland = {
enable = true;
systemd.variables = ["--all"];
xwayland.enable = true;
};
home.packages = with pkgs; [
wl-clipboard
];
programs.wpaperd = {
enable = true;
settings = {
default = {
path = ../../../static/wallpaper/stones.jpg;
};
};
};
}

View File

@@ -0,0 +1,19 @@
{
pkgs,
...
}: {
programs.kitty = {
shellIntegration.enableZshIntegration = true;
font = {
package = pkgs.fira-code-nerdfont;
name = "Fira Code Nerd Font";
size = 12;
};
theme = "Molokai";
settings = {
background_opacity = "0.6";
enable_audio_bell = false;
confirm_os_window_close = 0;
};
};
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./kitty.nix
];
}

View File

@@ -0,0 +1,5 @@
{
...
}: {
programs.kitty.enable = true;
}

View File

@@ -0,0 +1,5 @@
{pkgs, ...}: {
home.packages = [
(pkgs.callPackage ./mqtt-explorer.nix {})
];
}

View File

@@ -0,0 +1,41 @@
{
stdenv,
lib,
fetchurl,
appimageTools,
electron_27,
makeWrapper,
}:
stdenv.mkDerivation rec {
pname = "MQTT-Explorer";
version = "0.4.0-beta1";
src = appimageTools.extract {
name = pname;
src = fetchurl {
url = "https://github.com/thomasnordquist/${pname}/releases/download/0.0.0-${version}/${pname}-${version}.AppImage";
sha256 = "0x9ava13hn1nkk2kllh5ldi4b3hgmgwahk08sq48yljilgda4ppn";
};
};
buildInputs = [makeWrapper];
installPhase = ''
install -m 444 -D resources/app.asar $out/libexec/app.asar
install -m 444 -D mqtt-explorer.png $out/share/icons/mqtt-explorer.png
install -m 444 -D mqtt-explorer.desktop $out/share/applications/mqtt-explorer.desktop
makeWrapper ${electron_27}/bin/electron $out/bin/mqtt-explorer --add-flags $out/libexec/app.asar
'';
meta = with lib; {
description = "A comprehensive and easy-to-use MQTT Client";
homepage = "https://mqtt-explorer.com/";
license =
# TODO: make licenses.cc-by-nd-40
{
free = false;
fullName = "Creative Commons Attribution-No Derivative Works v4.00";
shortName = "cc-by-nd-40";
spdxId = "CC-BY-ND-4.0";
url = "https://spdx.org/licenses/CC-BY-ND-4.0.html";
};
maintainers = [maintainers.yorickvp];
inherit (electron_27.meta) platforms;
};
}

141
modules/home/plasma.nix Normal file
View File

@@ -0,0 +1,141 @@
{
pkgs,
lib,
...
}: {
home.file.".local/share/wallpaper" = {
source = ./static/wallpaper;
recursive = true;
};
# load hm-vars in x-session
xsession.enable = true;
# Use kvantum-theme
home.sessionVariables = {
QT_STYLE_OVERRIDE = "kvantum";
};
programs.konsole = {
enable = true;
defaultProfile = "default";
profiles = {
default = {
name = "default";
colorScheme = "Utterly-Nord-Konsole";
font = {
name = "Fira Code";
size = 10;
};
};
};
};
# use kvantum theme
qt.enable = true;
qt.style.name = "kvantum";
programs.plasma = {
enable = true;
overrideConfig = true;
#
# Some high-level settings:
#
workspace = {
clickItemTo = "select";
lookAndFeel = "Utterly-Nord";
theme = "breeze";
colorScheme = "UtterlyNord";
cursorTheme = "Breeze";
wallpaper = "/home/jonas/.local/share/wallpaper/nord.png";
};
hotkeys.commands."launch-konsole" = {
name = "Launch Konsole";
key = "Meta+Return";
command = "konsole";
};
panels = [
# Windows-like panel at the bottom
{
location = "bottom";
widgets = [
"org.kde.plasma.kickoff"
"org.kde.plasma.pager"
# We can also configure the widgets. For example if you want to pin
# konsole and dolphin to the task-launcher the following widget will
# have that.
{
name = "org.kde.plasma.icontasks";
config = {
General.launchers = [
"applications:org.kde.dolphin.desktop"
"applications:org.kde.konsole.desktop"
];
};
}
"org.kde.plasma.marginsseperator"
"org.kde.plasma.systemtray"
"org.kde.plasma.digitalclock"
];
hiding = null;
}
];
#
# Some mid-level settings:
#
shortcuts = {
ksmserver = {
"Lock Session" = ["Screensaver" "Meta+Ctrl+Alt+L"];
};
kwin =
{
"Expose" = "Meta+,";
"Switch Window Down" = "Meta+J";
"Switch Window Left" = "Meta+H";
"Switch Window Right" = "Meta+L";
"Switch Window Up" = "Meta+K";
"Window Quick Tile Bottom" = "Meta+Shift+J";
"Window Quick Tile Left" = "Meta+Shift+H";
"Window Quick Tile Right" = "Meta+Shift+L";
"Window Quick Tile Top" = "Meta+Shift+K";
"Kill Window" = "Meta+Alt+Q";
"Window Close" = "Meta+Shift+Q";
}
// (
with lib; let
desktops = map toString (lists.range 1 8);
in
listToAttrs
(map
(i: {
name = "Switch to Desktop ${i}";
value = "Meta+${i}";
})
desktops)
// listToAttrs (map
(i: {
name = "Window to Desktop ${i}";
value = "Meta+Shift+${i}";
})
desktops)
);
};
#
# Some low-level settings:
#
configFile = {
"baloofilerc"."Basic Settings"."Indexing-Enabled".value = false;
"kwinrc"."org.kde.kdecoration2"."ButtonsOnLeft".value = "SF";
"kwinrc"."Desktops"."Number" = {
value = 8;
# Forces kde to not change this value (even through the settings app).
immutable = true;
};
};
};
}

View File

@@ -0,0 +1,11 @@
{config, ...}: {
programs.ranger = {
settings = {
preview_images = true;
preview_images_method =
if config.programs.kitty.enable
then "kitty"
else "ueberzug";
};
};
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./ranger.nix
];
}

View File

@@ -0,0 +1,3 @@
{...}: {
programs.ranger.enable = true;
}

View File

@@ -0,0 +1,10 @@
{
config,
pkgs,
...
}: {
programs.rofi = {
location = "left";
theme = "${pkgs.rofi}/share/rofi/themes/sidebar-v2.rasi";
};
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./rofi.nix
];
}

View File

@@ -0,0 +1,3 @@
{...}: {
programs.rofi.enable = true;
}

29
modules/home/ssh.nix Normal file
View File

@@ -0,0 +1,29 @@
{
config,
...
}: let
sshKeys = name: {
"ssh/id_rsa_${name}.pub" = {
sopsFile = ../../secrets/jonas/ssh.yaml;
key = "keys/${name}/pub";
path = "${config.home.homeDirectory}/.ssh/id_rsa_${name}.pub";
};
"ssh/id_rsa_${name}" = {
sopsFile = ../../secrets/jonas/ssh.yaml;
key = "keys/${name}/priv";
path = "${config.home.homeDirectory}/.ssh/id_rsa_${name}";
};
};
in {
sops.secrets =
{
"ssh/config" = {
sopsFile = ../../secrets/jonas/ssh.yaml;
key = "config";
path = "${config.home.homeDirectory}/.ssh/config";
};
}
// (sshKeys "borg")
// (sshKeys "passgit")
// (sshKeys "ansible");
}

View File

@@ -0,0 +1,20 @@
{
config,
pkgs,
...
}: {
gtk = {
cursorTheme = {
package = pkgs.nordzy-cursor-theme;
name = "Nordzy-cursors";
};
theme = {
package = pkgs.nordic;
name = "Nordic";
};
iconTheme = {
package = pkgs.tela-circle-icon-theme;
name = "Tela-circle-nord";
};
};
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./gtk.nix
];
}

View File

@@ -0,0 +1,3 @@
{config, ...}: {
gtk.enable = true;
}

View File

@@ -0,0 +1,7 @@
{
config,
pkgs,
...
}: {
qt.style.name = "kvantum";
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./qt.nix
];
}

View File

@@ -0,0 +1,11 @@
{
config,
pkgs,
...
}: {
qt.enable = true;
home.packages = [
pkgs.utterly-nord-plasma
pkgs.libsForQt5.qtstyleplugin-kvantum
];
}

View File

@@ -0,0 +1,251 @@
{
config,
pkgs,
lib,
...
}: let
for_hyprland = config.programs.waybar.enable && config.wayland.windowManager.hyprland.enable;
in {
wayland.windowManager.hyprland = lib.mkIf for_hyprland {
settings = {
exec-once = [
"${pkgs.waybar}/bin/waybar &"
"${pkgs.networkmanagerapplet}/bin/nm-applet &"
"${pkgs.pasystray}/bin/pasystray &"
"${pkgs.blueman}/bin/blueman-applet &"
];
};
};
programs.waybar = lib.mkIf for_hyprland {
settings.mainBar = {
position = "top";
layer = "top";
height = 5;
margin-top = 0;
margin-bottom = 0;
margin-left = 0;
margin-right = 0;
modules-left = [
"custom/launcher"
"hyprland/workspaces"
];
modules-center = [
"hyprland/window"
];
modules-right = [
"clock"
"cpu"
"memory"
"disk"
"battery"
"network"
"tray"
];
clock = {
calendar = {
format = {today = "<span color='#b4befe'><b>{}</b></span>";};
};
format = " {:%H:%M}";
tooltip = "true";
tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
format-alt = " {:%d/%m}";
};
"hyprland/workspaces" = {
active-only = false;
disable-scroll = true;
format = "{icon}";
on-click = "activate";
format-icons = {
"1" = "1";
"2" = "2";
"3" = "3";
"4" = "4";
"5" = "5";
"6" = "6";
"7" = "7";
"8" = "8";
urgent = "";
default = "";
sort-by-number = true;
};
persistent-workspaces = {
"1" = [];
"2" = [];
"3" = [];
"4" = [];
"5" = [];
"6" = [];
"7" = [];
"8" = [];
};
};
memory = {
format = "󰟜 {}%";
format-alt = "󰟜 {used} GiB"; # 
interval = 2;
};
cpu = {
format = " {usage}%";
format-alt = " {avg_frequency} GHz";
interval = 2;
};
disk = {
# path = "/";
format = "󰋊 {percentage_used}%";
interval = 60;
};
network = {
format-wifi = " {signalStrength}%";
format-ethernet = "󰀂 ";
tooltip-format = "Connected to {essid} {ifname} via {gwaddr}";
format-linked = "{ifname} (No IP)";
format-disconnected = "󰖪 ";
};
tray = {
icon-size = 20;
spacing = 8;
};
pulseaudio = {
format = "{icon} {volume}%";
format-muted = "󰖁 {volume}%";
format-icons = {
default = [" "];
};
scroll-step = 5;
on-click = "pamixer -t";
};
battery = {
format = "{icon} {capacity}%";
format-icons = [" " " " " " " " " "];
format-charging = " {capacity}%";
format-full = " {capacity}%";
format-warning = " {capacity}%";
interval = 5;
states = {
warning = 20;
};
format-time = "{H}h{M}m";
tooltip = true;
tooltip-format = "{time}";
};
"custom/launcher" = {
format = "";
on-click = "${pkgs.wofi}/bin/wofi --show drun";
tooltip = "false";
};
};
style = ''
* {
border: none;
font-family: Font Awesome, Roboto, Arial, sans-serif;
font-size: 13px;
color: #ffffff;
border-radius: 15px;
}
window {
/*font-weight: bold;*/
}
window#waybar {
border-style: none;
border-width: 1px;
border-color: #33ccff;
background: rgba(0, 0, 0, 0);
}
/*-----module groups----*/
.modules-right {
background-color: rgba(0,43,51,0.85);
margin: 2px 10px 2px 0;
}
.modules-left {
margin: 2px 0 2px 5px;
background-color: rgba(0,119,179,0.6);
}
/*-----modules indv----*/
#workspaces button {
padding: 1px 5px;
background-color: transparent;
}
#workspaces button:hover {
box-shadow: inherit;
background-color: rgba(0,153,153,1);
}
#workspaces button.empty {
color: rgba(0 ,40, 40, 40);
}
#workspaces button.active {
background-color: rgba(0,43,51,0.85);
}
#window {
border-style: solid;
background-color: rgba(0,43,51,0.5);
margin: 2px 5px;
padding: 2px 5px;
border-width: 1px;
border-color: #33ccff;
}
#window.empty {
border-style: none;
background-color: transparent;
}
#custom-launcher {
background-color: rgba(0,119,179,0.6);
border-radius: 100px;
margin: 5px 5px;
}
#clock,
#battery,
#cpu,
#memory,
#temperature,
#network,
#pulseaudio,
#custom-media,
#tray,
#mode,
#custom-power,
#custom-menu,
#idle_inhibitor {
padding: 0 10px;
}
#mode {
color: #cc3436;
font-weight: bold;
}
#custom-power {
background-color: rgba(0,119,179,0.6);
border-radius: 100px;
margin: 5px 5px;
padding: 1px 1px 1px 6px;
}
/*-----Indicators----*/
#idle_inhibitor.activated {
color: #2dcc36;
}
#pulseaudio.muted {
color: #cc3436;
}
#battery.charging {
color: #2dcc36;
}
#battery.warning:not(.charging) {
color: #e6e600;
}
#battery.critical:not(.charging) {
color: #cc3436;
}
#temperature.critical {
color: #cc3436;
}
/*-----Colors----*/
/*
*rgba(0,85,102,1),#005566 --> Indigo(dye)
*rgba(0,43,51,1),#002B33 --> Dark Green
*RGBA(0,153,153,1),#009999 --> PERSIAN GREEN
*
*/
'';
};
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./waybar.nix
./config.nix
];
}

View File

@@ -0,0 +1,13 @@
{
config,
pkgs,
...
}: {
programs.waybar.enable = true;
home.packages = with pkgs; [
pulsemixer
pavucontrol
pasystray
networkmanagerapplet
];
}

View File

@@ -0,0 +1,5 @@
{...}: {
imports = [
./wlogout.nix
];
}

View File

@@ -0,0 +1,3 @@
{...}: {
programs.wlogout.enable = true;
}

View File

@@ -0,0 +1,89 @@
{...}: {
programs.wofi.settings = {
location = "center";
allow_images = true;
allow_markup = true;
key_expand = "Tab";
key_up = "Ctrl-k";
key_down = "Ctrl-j";
key_left = "Ctrl-h";
key_right = "Ctrl-l";
insensitive = true;
};
programs.wofi.style = ''
#window {
border-radius: 15px;
border-color: #33ccff;
border-width: 2px;
border-style: solid;
background-color: rgba(0, 0, 0, 0.6);
}
#input {
margin: 5px;
border-radius: 15px;
border-color: #33ccff;
border-width: 2px;
border-style: solid;
background: transparent;
color: white;
}
#input {
margin: 5px;
border-radius: 15px;
border-color: #33ccff;
border-width: 2px;
border-style: solid;
background: transparent;
color: white;
}
#img {
background-color: transparent;
}
#inner-box {
background-color: transparent;
}
#outer-box {
margin: 2px;
padding: 10px;
background: transparent;
}
#scroll {
margin: 5px;
}
#text {
padding: 4px;
color: white;
background: transparent;
border: none;
}
#entry {
background: transparent;
border: none;
}
#entry:selected {
border-radius: 15px;
border-color: #33ccff;
border-width: 2px;
border-style: solid;
background: transparent;
}
#expander {
border-radius: 15px;
border-color: #33ccff;
border-width: 2px;
border-style: solid;
background: transparent;
}
'';
}

View File

@@ -0,0 +1,6 @@
{...}: {
imports = [
./config.nix
./wofi.nix
];
}

View File

@@ -0,0 +1,3 @@
{...}: {
programs.wofi.enable = true;
}

29
modules/home/yubikey.nix Normal file
View File

@@ -0,0 +1,29 @@
{
config,
pkgs,
...
}: {
programs.gpg = {
enable = true;
mutableKeys = false;
mutableTrust = false;
publicKeys = [
{
source = ../../static/keys/my_pub.asc;
trust = "ultimate";
}
];
};
services.gpg-agent = {
enable = true;
enableSshSupport = true;
enableZshIntegration = true;
pinentryPackage = pkgs.pinentry.qt;
extraConfig = ''
allow-emacs-pinentry
'';
};
home.sessionVariables = {
SSH_AUTH_SOCK = "$XDG_RUNTIME_DIR/gnupg/S.gpg-agent.ssh";
};
}

View File

@@ -0,0 +1,7 @@
{
...
}: {
imports = [
./zsh.nix
];
}

View File

@@ -0,0 +1,154 @@
# oh-my-zsh Bureau Theme
### NVM
ZSH_THEME_NVM_PROMPT_PREFIX="%B⬡%b "
ZSH_THEME_NVM_PROMPT_SUFFIX=""
### Git [±master ▾●]
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg_bold[green]%}±%{$reset_color%}%{$fg_bold[white]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[cyan]%}▴%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STASHED="(%{$fg_bold[blue]%}✹%{$reset_color%})"
bureau_nix_shell () {
if [ -n "$IN_NIX_SHELL" ]; then
if [ -n "$out" ]; then
local name=$(basename $(realpath -mL "$out/../../"))
echo -n "[nix-shell@$name]"
else
echo -n "[nix-shell]"
fi
else
echo -n ""
fi
}
bureau_nix_shell_prompt () {
if [ -n "$IN_NIX_SHELL" ]; then
echo -n "[nix]"
else
echo -n ""
fi
}
bureau_git_info () {
local ref
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
echo "${ref#refs/heads/}"
}
bureau_git_status() {
local result gitstatus
gitstatus="$(command git status --porcelain -b 2>/dev/null)"
# check status of files
local gitfiles="$(tail -n +2 <<< "$gitstatus")"
if [[ -n "$gitfiles" ]]; then
if [[ "$gitfiles" =~ $'(^|\n)[AMRD]. ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_STAGED"
fi
if [[ "$gitfiles" =~ $'(^|\n).[MTD] ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
if [[ "$gitfiles" =~ $'(^|\n)\\?\\? ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
if [[ "$gitfiles" =~ $'(^|\n)UU ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
else
result+="$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
# check status of local repository
local gitbranch="$(head -n 1 <<< "$gitstatus")"
if [[ "$gitbranch" =~ '^## .*ahead' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
if [[ "$gitbranch" =~ '^## .*behind' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
if [[ "$gitbranch" =~ '^## .*diverged' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
# check if there are stashed changes
if command git rev-parse --verify refs/stash &> /dev/null; then
result+="$ZSH_THEME_GIT_PROMPT_STASHED"
fi
echo $result
}
bureau_git_prompt() {
# ignore non git folders and hidden repos (adapted from lib/git.zsh)
if ! command git rev-parse --git-dir &> /dev/null \
|| [[ "$(command git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
return
fi
# check git information
local gitinfo=$(bureau_git_info)
if [[ -z "$gitinfo" ]]; then
return
fi
# quote % in git information
local output="${gitinfo:gs/%/%%}"
# check git status
local gitstatus=$(bureau_git_status)
if [[ -n "$gitstatus" ]]; then
output+=" $gitstatus"
fi
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${output}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
_PATH="%{$fg_bold[white]%}%~%{$reset_color%}"
if [[ $EUID -eq 0 ]]; then
_USERNAME="%{$fg_bold[red]%}%n"
_LIBERTY="%{$fg[red]%}#"
else
_USERNAME="%{$fg_bold[white]%}%n"
_LIBERTY="%{$fg[green]%}$"
fi
_USERNAME="$_USERNAME%{$reset_color%}@%m"
_LIBERTY="$_LIBERTY%{$reset_color%}"
get_space () {
local STR=$1$2
local zero='%([BSUbfksu]|([FB]|){*})'
local LENGTH=${#${(S%%)STR//$~zero/}}
local SPACES=$(( COLUMNS - LENGTH - ${ZLE_RPROMPT_INDENT:-1} ))
(( SPACES > 0 )) || return
printf ' %.0s' {1..$SPACES}
}
_1LEFT="$_USERNAME $_PATH"
_1RIGHT="[%*]"
bureau_precmd () {
_1SPACES=`get_space $_1LEFT $_1RIGHT`
print
print -rP "$_1LEFT$_1SPACES$_1RIGHT"
}
setopt prompt_subst
PROMPT='$(bureau_nix_shell_prompt)> $_LIBERTY '
RPROMPT='$(nvm_prompt_info) $(bureau_nix_shell) $(bureau_git_prompt)'
autoload -U add-zsh-hook
add-zsh-hook precmd bureau_precmd

48
modules/home/zsh/zsh.nix Normal file
View File

@@ -0,0 +1,48 @@
{
config,
...
}: let
omz_custom = "${config.home.homeDirectory}/.config/omz_custom";
in {
home.file."${omz_custom}" = {
source = ./static/omz_custom;
recursive = true;
};
# direnv
programs.direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true;
};
# Zsh
programs.zsh = {
enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
shellAliases = {
ll = "ls -l";
update = "sudo nixos-rebuild switch";
};
history.size = 10000;
history.path = "${config.xdg.dataHome}/zsh/history";
oh-my-zsh = {
enable = true;
plugins = [
"docker"
"docker-compose"
"fzf"
"git"
"pass"
"poetry"
"python"
"rust"
"thefuck"
];
theme = "my_bureau";
custom = omz_custom;
};
};
}