From 3f9ef8fed311ab64c0e65fc5c007727ad5818ced Mon Sep 17 00:00:00 2001 From: Alina Sireneva Date: Sun, 3 Mar 2024 21:39:15 +0300 Subject: [PATCH] iosevka-nerd + new zsh prompt --- .gitignore | 4 +- assets/.gitignore | 1 + assets/build | 12 +++++ assets/iosevka-nerd.nix | 45 ++++++++++++++++ hosts/teidesu-osx/configuration.nix | 20 ++++---- readme.md | 7 +++ users/teidesu/darwin.nix | 41 ++++++++++----- users/teidesu/fonts.nix | 11 ++++ users/teidesu/zsh.nix | 79 +++++++++++++++++++++++++---- 9 files changed, 185 insertions(+), 35 deletions(-) create mode 100644 assets/.gitignore create mode 100755 assets/build create mode 100644 assets/iosevka-nerd.nix create mode 100644 users/teidesu/fonts.nix diff --git a/.gitignore b/.gitignore index e2f5dd2..badf753 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -result \ No newline at end of file +result +.DS_Store +/test.nix \ No newline at end of file diff --git a/assets/.gitignore b/assets/.gitignore new file mode 100644 index 0000000..cc8bf1e --- /dev/null +++ b/assets/.gitignore @@ -0,0 +1 @@ +built \ No newline at end of file diff --git a/assets/build b/assets/build new file mode 100755 index 0000000..659d128 --- /dev/null +++ b/assets/build @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -eau + +_name=$(basename $1) +name=${_name%.*} + +echo "Building $name" +nix build --file $1 -vL --show-trace + +echo "Copying $name to ./built/$name.tgz" +tar -czf "built/$name.tgz" result/* \ No newline at end of file diff --git a/assets/iosevka-nerd.nix b/assets/iosevka-nerd.nix new file mode 100644 index 0000000..24518ce --- /dev/null +++ b/assets/iosevka-nerd.nix @@ -0,0 +1,45 @@ +let + pkgs = import {}; + nerdify = { font, args ? "--complete" }: + pkgs.stdenvNoCC.mkDerivation { + name = "${font.name}-nerd"; + src = pkgs.fetchzip { + url = "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FontPatcher.zip"; + hash = "sha256-H2dPUs6HVKJcjxy5xtz9nL3SSPXKQF3w30/0l7A0PeY="; + stripRoot = false; + }; + buildInputs = with pkgs; [ + argparse + fontforge + (python3.withPackages (ps: with ps; [ setuptools fontforge ])) + ]; + buildPhase = '' + font_regexp='.*\.\(ttf\|ttc\|otf\|dfont\)' + find -L ${font} -regex "$font_regexp" -type f -print0 | while IFS= read -rd "" f_; do + f=$(basename "$f_") + echo "nerdifying $f" + mkdir -p $out/$f + fontforge -script $src/font-patcher "$f_" ${args} -out $out/$f -q + done + ''; + installPhase = '' + set -eaux + # fontforge tends to spit out a lot of files with the same name + # so we need to move them to a unique location + for f in $out/*; do + if [ -d "$f" ]; then + for g in $f/*; do + mv "$g" "$out/$(basename "$f")-$(basename "$g")" + done + rm -r "$f" + fi + done + ''; + }; +in nerdify { + font = pkgs.fetchzip { + url = "https://github.com/be5invis/Iosevka/releases/download/v28.1.0/PkgTTC-IosevkaSS05-28.1.0.zip"; + hash = "sha256-IOk0+Ha/FG29jIBr2+7Rx89TbnvK9ngx7gAFr5VfBpU="; + stripRoot = false; + }; +} \ No newline at end of file diff --git a/hosts/teidesu-osx/configuration.nix b/hosts/teidesu-osx/configuration.nix index 72bb847..c9b778d 100644 --- a/hosts/teidesu-osx/configuration.nix +++ b/hosts/teidesu-osx/configuration.nix @@ -25,17 +25,15 @@ programs.zsh.enable = true; - users.users.teidesu = { - home = "/Users/teidesu"; - }; - - home-manager.users.teidesu = { pkgs, ... }: { - imports = [ - (abs "users/teidesu/darwin.nix") - - ./arc-setup.nix - ]; - }; + imports = [ + (import (abs "users/teidesu/darwin.nix") { + home = { + imports = [ + ./arc-setup.nix + ]; + }; + }) + ]; system.stateVersion = 4; } diff --git a/readme.md b/readme.md index 611e316..b980d94 100755 --- a/readme.md +++ b/readme.md @@ -7,12 +7,19 @@ the config is pretty much a mess and the code sucks. ## impure dependencies note to self on what needs to be installed on the host manually: +### common +- `/etc/ssh/agenix_key` (darwin: `~/.ssh/agenix_key`) - private key for secret decryption + +### koi: - ~~`/etc/iso/win11.iso` - iso containing windows 11 installer (e.g. this: [magnet](magnet:?xt=urn:btih:56197d53136ffcecbae5225f0ac761121eacdac6&dn=Win11_22H2_English_x64v1.iso&tr=udp%3a%2f%2ftracker.torrent.eu.org%3a451%2fannounce&tr=udp%3a%2f%2ftracker.tiny-vps.com%3a6969%2fannounce&tr=udp%3a%2f%2fopen.stealth.si%3a80%2fannounce))~~ currently unused - `/etc/vms/haos.img` - qcow2 image for haos vm (can be downloaded from the official website, the KVM/Proxmox image). - `/etc/ssh/agenix_key` - private key for secret decryption - `/etc/secureboot/keys` - secure boot keys, generated with `sudo nix-shell -p sbctl --run "sbctl create-keys"` - to enroll fde onto tpm: `sudo systemd-cryptenroll /dev/nvme0n1p2 --tpm2-device=auto --tpm2-pcrs=0+2+7` +### teidesu-osx +`cp /var/run/current-system/Library/Fonts/* /Library/Fonts` - copy nix-managed fonts to system fonts (waiting for [this PR](https://github.com/LnL7/nix-darwin/pull/754)) + nginx may not start the first time, its fine, just run `sudo systemctl restart nginx` and it should work. its likely due to docker containers not resolving yet. diff --git a/users/teidesu/darwin.nix b/users/teidesu/darwin.nix index c016237..ed3b500 100644 --- a/users/teidesu/darwin.nix +++ b/users/teidesu/darwin.nix @@ -1,19 +1,32 @@ -{ abs, pkgs, lib, inputs, ... }: +{ home ? {}, ... }: { imports = [ - ./common.nix + ./fonts.nix ]; - home.packages = with pkgs; [ - scc - ripgrep - fnm - aria2 - ffmpeg - hyfetch - wget - watch - curl - ]; -} + users.users.teidesu = { + home = "/Users/teidesu"; + }; + + home-manager.users.teidesu = { pkgs, ... }: { + imports = [ + ./common.nix + + home + ]; + + home.packages = with pkgs; [ + scc + ripgrep + fnm + aria2 + ffmpeg + hyfetch + wget + watch + curl + android-tools + ]; + }; +} \ No newline at end of file diff --git a/users/teidesu/fonts.nix b/users/teidesu/fonts.nix new file mode 100644 index 0000000..5c74ff2 --- /dev/null +++ b/users/teidesu/fonts.nix @@ -0,0 +1,11 @@ +{ pkgs, lib, ... }: + +{ + fonts.fonts = [ + (pkgs.fetchzip { + name = "iosevka-nerd"; + url = "https://s3.tei.su/iosevka-nerd.tgz"; + hash = "sha256-WrtCS1nwsGtYG7W7EiaaC4LVq1bGod4ygFC7VpSuDx0="; + }) + ]; +} \ No newline at end of file diff --git a/users/teidesu/zsh.nix b/users/teidesu/zsh.nix index 3781e16..c2bcd0b 100644 --- a/users/teidesu/zsh.nix +++ b/users/teidesu/zsh.nix @@ -1,16 +1,73 @@ { pkgs, lib, ... }: -{ +let + starshipConfig = { + # based on https://starship.rs/presets/pastel-powerline.html + format = + "$character" + + "$hostname" + + "[](fg:#be15dc bg:#FCA17D)" + + "$git_branch" + + "$git_status" + + "[](fg:#FCA17D bg:#86BBD8)" + + "$nodejs" + + "[](fg:#86BBD8 bg:#33658A)" + + "$directory" + + "[ ](fg:#33658A)" + + ""; + add_newline = false; + + character = { + success_symbol = "[](#be15dc)[ алина 🌸 ](bg:#be15dc)"; + error_symbol = "[](#dc156b)[ алина 🌸 ](bg:#be15dc)"; + format = "$symbol"; + }; + + hostname = { + style = ''bg:#be15dc''; + format = "[$hostname ]($style)"; + ssh_only = true; + }; + + directory = { + style = "bg:#33658A"; + format = "[ $path ]($style)"; + truncation_length = 3; + truncation_symbol = "…/"; + }; + + git_branch = { + symbol = ""; + style = "bg:#FCA17D fg:black"; + format = "[ $symbol $branch ]($style)"; + }; + git_status = { + style = "bg:#FCA17D fg:black"; + format = "[$all_status$ahead_behind ]($style)"; + }; + + nodejs = { + symbol = ""; + style = "bg:#86BBD8 fg:black"; + version_format = "$major.$minor"; + format = "[ $symbol ($version) ]($style)"; + }; + + env_var._HOST_COLOR = { + format = "$env_value"; + }; + }; +in { programs.zsh = { enable = true; - oh-my-zsh = { - enable = true; - theme = "agnoster"; - extraConfig = '' - zstyle ':bracketed-paste-magic' active-widgets '.self-*' - ''; - }; + # oh-my-zsh = { + # enable = true; + # theme = "agnoster"; + # extraConfig = '' + # zstyle ':bracketed-paste-magic' active-widgets '.self-*' + # ''; + # }; syntaxHighlighting.enable = true; enableAutosuggestions = true; @@ -24,8 +81,12 @@ initExtra = '' unsetopt correct_all + zstyle ':bracketed-paste-magic' active-widgets '.self-*' + + export _HOST_COLOR="#$(([##16]`hostname | cksum | cut -f 1 -d ' '` % 16777215))" + export STARSHIP_CONFIG=${(pkgs.formats.toml {}).generate "starship.toml" starshipConfig} + eval "$(${pkgs.starship}/bin/starship init zsh)" - CURRENT_BG="$(( `hostname | cksum | cut -f 1 -d ' '` % 255 ))" CASE_SENSITIVE="false" HYPHEN_INSENSITIVE="true" ENABLE_CORRECTION="true"