Skip to content

Commit

Permalink
Merge pull request #72 from sbulav/nix
Browse files Browse the repository at this point in the history
Nix
  • Loading branch information
sbulav authored Oct 3, 2023
2 parents 58baa3c + e68683c commit cdb3d24
Show file tree
Hide file tree
Showing 61 changed files with 2,689 additions and 167 deletions.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
# My configuration files

![Always wip](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRrgUjNod0ETGyHau0Tkn-WAnFjXLP493ryUQ&usqp=CAU)

[![GitGuardian scan](https://github.com/sbulav/dotfiles/actions/workflows/gitguardian.yml/badge.svg)](https://github.com/sbulav/dotfiles/actions/workflows/gitguardian.yml)
[![release-please](https://github.com/sbulav/dotfiles/actions/workflows/please_release.yml/badge.svg)](https://github.com/sbulav/dotfiles/actions/workflows/please_release.yml)

This file is auto-generated, do not modify it!

## Nix

I am currently in the process of migration to [Nix](https://nixos.org/)

- MacOS
- [Nix Flakes](https://nixos.wiki/wiki/Flakes)
- [Nix-Darwin](https://github.com/LnL7/nix-darwin)
- [Home-Manager](https://nix-community.github.io/home-manager/)
- NixOS
- [Nix Flakes](https://nixos.wiki/wiki/Flakes)
- [Home-Manager](https://nix-community.github.io/home-manager/)
- [Hyprland](https://wiki.hyprland.org) + Waybar, Swaylock, Rofi, mako, hyprpaper

To trigger a new build both on Mac and Nix, run

```sh
./bin/build
```

Kudos for config inspiration to:

- [Introduction to Nix & NixOS](https://nixos-and-flakes.thiscute.world/introduction/)
- [Nix for MacOS by dustinlyons](https://github.com/dustinlyons/nixos-config)
- [Nix starter configs by Misterio77](https://github.com/Misterio76/nix-starter-configs)

You might also want to check out my blog with [#Nix category](https://sbulav.github.io/categories/#nix)

### Useful NIX commands

Quickly try out new package in the shell without installing it:

```sh
nix shell nixpkgs#glow
```

## Automated workflows

I'm using following workflows to automate management of my dotfiles:
Expand All @@ -20,7 +57,7 @@ I'm using following workflows to automate management of my dotfiles:
generate this README


## Tools installation
## Tools installation(Obsolete)

Run make and specify tool to install:

Expand Down
4 changes: 3 additions & 1 deletion fish/fish_variables
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ SETUVAR _fish_abbr_ks:kubens
SETUVAR _fish_abbr_kx:kubectx
SETUVAR _fisher_danhper_2F_fish_2D_ssh_2D_agent_files:/Users/sab/\x2econfig/fish/functions/__ssh_agent_is_started\x2efish\x1e/Users/sab/\x2econfig/fish/functions/__ssh_agent_start\x2efish\x1e/Users/sab/\x2econfig/fish/conf\x2ed/fish\x2dssh\x2dagent\x2efish
SETUVAR _fisher_evanlucas_2F_fish_2D_kubectl_2D_completions_files:/Users/sab/\x2econfig/fish/completions/kubectl\x2efish
SETUVAR _fisher_jorgebucaran_2F_fisher_files:/Users/sab/\x2econfig/fish/functions/fisher\x2efish\x1e/Users/sab/\x2econfig/fish/completions/fisher\x2efish
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1eevanlucas/fish\x2dkubectl\x2dcompletions\x1edanhper/fish\x2dssh\x2dagent
SETUVAR _fisher_upgraded_to_4_4:\x1d
SETUVAR fish_color_autosuggestion:555\x1ebrblack
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:005fd7
Expand Down Expand Up @@ -38,3 +39,4 @@ SETUVAR fish_pager_color_description:B3A06D\x1eyellow
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SETUVAR fish_pager_color_selected_background:\x2dr
SETUVAR fish_user_paths:/opt/homebrew/opt/mysql\x2dclient/bin
93 changes: 61 additions & 32 deletions fish/functions/fisher.fish
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function fisher --argument-names cmd --description "A plugin manager for Fish"
set --query fisher_path || set --local fisher_path $__fish_config_dir
set --local fisher_version 4.3.1
set --local fisher_version 4.4.3
set --local fish_plugins $__fish_config_dir/fish_plugins

switch "$cmd"
Expand All @@ -13,10 +13,10 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
echo " fisher update Update all installed plugins"
echo " fisher list [<regex>] List installed plugins matching regex"
echo "Options:"
echo " -v or --version Print version"
echo " -h or --help Print this help message"
echo " -v, --version Print version"
echo " -h, --help Print this help message"
echo "Variables:"
echo " \$fisher_path Plugin installation path. Default: ~/.config/fish"
echo " \$fisher_path Plugin installation path. Default: $__fish_config_dir" | string replace --regex -- $HOME \~
case ls list
string match --entire --regex -- "$argv[2]" $_fisher_plugins
case install update remove
Expand All @@ -29,17 +29,19 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
set --local old_plugins $_fisher_plugins
set --local new_plugins

test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins)

if ! set --query argv[2]
if test "$cmd" != update
echo "fisher: Not enough arguments for command: \"$cmd\"" >&2 && return 1
else if test ! -e $fish_plugins
else if ! set --query file_plugins
echo "fisher: \"$fish_plugins\" file not found: \"$cmd\"" >&2 && return 1
end
set arg_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins)
set arg_plugins $file_plugins
end

for plugin in $arg_plugins
test -e "$plugin" && set plugin (realpath $plugin)
set plugin (test -e "$plugin" && realpath $plugin || string lower -- $plugin)
contains -- "$plugin" $new_plugins || set --append new_plugins $plugin
end

Expand Down Expand Up @@ -70,30 +72,39 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
set --local pid_list
set --local source_plugins
set --local fetch_plugins $update_plugins $install_plugins
set --local fish_path (status fish-path)

echo (set_color --bold)fisher $cmd version $fisher_version(set_color normal)

for plugin in $fetch_plugins
set --local source (command mktemp -d)
set --append source_plugins $source

command mkdir -p $source/{completions,conf.d,functions}
command mkdir -p $source/{completions,conf.d,themes,functions}

fish --command "
$fish_path --command "
if test -e $plugin
command cp -Rf $plugin/* $source
else
set temp (command mktemp -d)
set name (string split \@ $plugin) || set name[2] HEAD
set url https://codeload.github.com/\$name[1]/tar.gz/\$name[2]
set repo (string split -- \@ $plugin) || set repo[2] HEAD
if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1])
set name (string split -- / \$path)[-1]
set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz
else
set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2]
end
echo Fetching (set_color --underline)\$url(set_color normal)
if curl --silent \$url | tar -xzC \$temp -f - 2>/dev/null
if command curl --silent -L \$url | command tar -xzC \$temp -f - 2>/dev/null
command cp -Rf \$temp/*/* $source
else
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
command rm -rf $source
end
command rm -rf \$temp
end
Expand Down Expand Up @@ -123,31 +134,32 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var)
emit {$name}_uninstall
end
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
set --erase _fisher_plugins[$index]
end

command rm -rf $$plugin_files_var
command rm -rf (string replace -- \~ ~ $$plugin_files_var)

functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var)

for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var)
complete --erase --command $name
end

set --erase _fisher_plugins[$index]
set --erase $plugin_files_var
end
end

if set --query update_plugins[1] || set --query install_plugins[1]
command mkdir -p $fisher_path/{functions,conf.d,completions}
command mkdir -p $fisher_path/{functions,themes,conf.d,completions}
end

for plugin in $update_plugins $install_plugins
set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)]
set --local files $source/{functions,conf.d,completions}/*
set --local files $source/{functions,themes,conf.d,completions}/*

if set --local index (contains --index -- $plugin $install_plugins)
set --local user_files $fisher_path/{functions,conf.d,completions}/*
set --local user_files $fisher_path/{functions,themes,conf.d,completions}/*
set --local conflict_files

for file in (string replace -- $source/ $fisher_path/ $files)
Expand All @@ -161,18 +173,19 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
end

for file in (string replace -- $source/ "" $files)
command cp -Rf $source/$file $fisher_path/$file
command cp -RLf $source/$file $fisher_path/$file
end

set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files)

set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | string replace -- ~ \~)

contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin
contains -- $plugin $install_plugins && set --local event install || set --local event update

printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var
printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~

for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var)
for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~)
source $file
if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file)
emit {$name}_$event
Expand All @@ -182,12 +195,25 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"

command rm -rf $source_plugins

set --query _fisher_plugins[1] || set --erase _fisher_plugins
set --query _fisher_plugins &&
printf "%s\n" $_fisher_plugins >$fish_plugins ||
if set --query _fisher_plugins[1]
set --local commit_plugins

for plugin in $file_plugins
contains -- (string lower -- $plugin) (string lower -- $_fisher_plugins) && set --append commit_plugins $plugin
end

for plugin in $_fisher_plugins
contains -- (string lower -- $plugin) (string lower -- $commit_plugins) || set --append commit_plugins $plugin
end

printf "%s\n" $commit_plugins >$fish_plugins
else
set --erase _fisher_plugins
command rm -f $fish_plugins
end

set --local total (count $install_plugins) (count $update_plugins) (count $remove_plugins)

test "$total" != "0 0 0" && echo (string join ", " (
test $total[1] = 0 || echo "Installed $total[1]") (
test $total[2] = 0 || echo "Updated $total[2]") (
Expand All @@ -198,14 +224,17 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
end
end

## Migrations ##
function _fisher_fish_postexec --on-event fish_postexec
if ! set --query _fisher_upgraded_to_4_4
set --universal _fisher_upgraded_to_4_4
if functions --query _fisher_list
set --query XDG_DATA_HOME[1] || set --local XDG_DATA_HOME ~/.local/share
command rm -rf $XDG_DATA_HOME/fisher
functions --erase _fisher_{list,plugin_parse}
fisher update >/dev/null 2>/dev/null
set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share
test -e $XDG_DATA_HOME/fisher && command rm -rf $XDG_DATA_HOME/fisher
functions --erase _fisher_list _fisher_plugin_parse
set --erase fisher_data
else
for var in (set --names | string match --entire --regex '^_fisher_.+_files$')
set $var (string replace -- ~ \~ $$var)
end
functions --erase _fisher_fish_postexec
end
functions --erase _fisher_fish_postexec
end
8 changes: 4 additions & 4 deletions kitty/kitty.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ font_family CaskaydiaCove Nerd Font
#: italic_font Operator Mono Book Italic
#: bold_italic_font Operator Mono Medium Italic

font_size 18.0
font_size 14.0

#: Font size (in pts)

Expand Down Expand Up @@ -526,7 +526,7 @@ sync_to_monitor no
#: when resizing the OS window. Note that this does not currently work
#: on Wayland.

# confirm_os_window_close 0
confirm_os_window_close 0

#: Ask for confirmation when closing an OS window or a tab that has at
#: least this number of kitty windows in it. A value of zero disables
Expand Down Expand Up @@ -1011,7 +1011,7 @@ macos_quit_when_last_window_closed no

#: map ctrl+f>2 set_font_size 20

# kitty_mod ctrl+shift
kitty_mod ctrl+shift

#: The value of kitty_mod is used as the modifier for all default
#: shortcuts, you can change it in your kitty.conf to change the
Expand Down Expand Up @@ -1285,7 +1285,7 @@ macos_quit_when_last_window_closed no

#: Miscellaneous {{{

# map kitty_mod+f11 toggle_fullscreen
map kitty_mod+f toggle_fullscreen
# map kitty_mod+f10 toggle_maximized
# map kitty_mod+u kitten unicode_input
# map kitty_mod+f2 edit_config_file
Expand Down
2 changes: 1 addition & 1 deletion lf/lf_kitty_clean
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

kitty +icat --clear --silent --transfer-mode file
kitty +kitten icat --clear --stdin no --silent --transfer-mode file < /dev/null > /dev/tty
11 changes: 6 additions & 5 deletions lf/lf_kitty_preview
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ x=$4
y=$5

if [[ "$( file -Lb --mime-type "$file")" =~ ^image ]]; then
kitty +icat --silent --transfer-mode file --place "${w}x${h}@${x}x${y}" "$file"
# kitty +icat --silent --transfer-mode file --place "${w}x${h}@${x}x${y}" "$file"
kitty +kitten icat --silent --stdin no --transfer-mode file --place "${w}x${h}@${x}x${y}" "$file" < /dev/null > /dev/tty
exit 1
elif [[ "$( file -Lb --mime-type "$file")" =~ ^video ]]; then
thumb_dir="$HOME/.cache/ffmpegthumbnailer"
if [[ ! -d "$thumb_dir" ]]; then
mkdir -p $thumb_dir
fi

thumb_file="$thumb_dir/$(realpath $file | md5).jpg"
ffmpegthumbnailer -i "$file" -o "$thumb_file" -s0 -t15
kitty +icat --silent --transfer-mode file --place "${w}x${h}@${x}x${y}" "$thumb_file"
md5sum=$(echo $file | md5)
thumb_file="$thumb_dir/$md5sum.jpg"
ffmpeg -ss 00:00:05.000 -i "$file" -vframes 1 "$thumb_file"
kitty +kitten icat --silent --stdin no --transfer-mode file --place "${w}x${h}@${x}x${y}" "$thumb_file" < /dev/null > /dev/tty
exit 1
fi

Expand Down
20 changes: 20 additions & 0 deletions nix/bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh -e

VERSION=1.0
export args=$@

# Navigate to the directory of this script
cd $(dirname $(readlink -f $0))
cd ..

build() {
if [ "$(uname)" == "Darwin" ]; then
./bin/darwin-build $args
elif [ "$(uname)" == "Linux" ]; then
./bin/nixos-build $args
else
echo "Unknown platform"
fi
}

build
Loading

0 comments on commit cdb3d24

Please sign in to comment.