Initial experimental commit

This commit is contained in:
ooks-io 2024-01-13 22:52:45 +13:00
parent b848f9d893
commit 682a19b13c
146 changed files with 2463 additions and 2389 deletions

View file

@ -0,0 +1,11 @@
{
imports = [
./editor # Still need to implement nvim
./fileManager
# ./language
./multiplexer # Still need to implement tmux and screen
./prompt # only Starship is currently implemented
./shell
./utility
];
}

View file

@ -0,0 +1,27 @@
{ lib, ... }:
{
imports = [
./helix
# ./nvim
];
options.programs.console.editor = {
helix = {
enable = lib.mkEnableOption "Enable helix text editor";
default = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set helix as the default text editor in environment variables";
};
};
nvim = {
enable = lib.mkEnableOption "Enable nvim text editor";
default = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set nvim as the default text editor in environment variables";
};
};
};
}

View file

@ -0,0 +1,70 @@
{ inputs, config, pkgs, lib, ... }:
let
cfg = config.programs.console.editor.helix;
inherit (config) colorscheme;
in
{
imports = [
./languages.nix
];
config = {
programs.helix = lib.mkIf cfg.enable {
enable = true;
defaultEditor = lib.mkIf cfg.default true;
package =
inputs.helix.packages.${pkgs.system}.default.overrideAttrs (self: {
makeWrapperArgs = with pkgs;
self.makeWrapperArgs
or []
++ [
"--suffix"
"PATH"
":"
(lib.makeBinPath [
clang-tools
marksman
nil
nodePackages.bash-language-server
nodePackages.vscode-css-languageserver-bin
nodePackages.vscode-langservers-extracted
shellcheck
])
];
});
settings = {
theme = colorscheme.slug;
editor = {
color-modes = true;
middle-click-paste = false;
line-number = "relative";
indent-guides.render = true;
true-color = true;
cursorline = true;
cursor-shape = {
normal = "block";
insert = "bar";
select = "underline";
};
statusline = {
left = [ "mode" "spinner" ];
center = [ "file-name" ];
right = [ "diagnostics" "selections" "position" "file-encoding" "file-line-ending" "file-type" ];
};
lsp = {
display-messages = true;
display-inlay-hints = true;
};
keys.normal.space.u = {
f = ":format";
w = ":set whitespace.render all";
W = ":set whitespace.render none";
};
};
};
themes = import ./theme.nix { inherit colorscheme; };
};
};
}

View file

@ -0,0 +1,101 @@
{ pkgs, lib, ... }:
{
programs.helix.languages = {
language = let
deno = lang: {
command = "${pkgs.deno}/bin/deno";
args = ["fmt" "-" "--ext" lang];
};
prettier = lang: {
command = "${pkgs.nodePackages.prettier}/bin/prettier";
args = ["--parser" lang];
};
prettierLangs = map (e: {
name = e;
formatter = prettier e;
});
langs = ["css" "scss" "html"];
in
[
{
name = "bash";
auto-format = true;
formatter = {
command = "${pkgs.shfmt}/bin/shfmt";
args = ["-i" "2"];
};
}
{
name = "clojure";
injection-regex = "(clojure|clj|edn|boot|yuck)";
file-types = ["clj" "cljs" "cljc" "clje" "cljr" "cljx" "edn" "boot" "yuck"];
}
{
name = "javascript";
auto-format = true;
language-servers = ["deno-lsp"];
}
{
name = "json";
formatter = deno "json";
}
{
name = "markdown";
auto-format = true;
formatter = deno "md";
}
]
++ prettierLangs langs;
language-server = {
bash-language-server = {
command = "${pkgs.nodePackages.bash-language-server}/bin/bash-language-server";
args = ["start"];
};
clangd = {
command = "${pkgs.clang-tools}/bin/clangd";
clangd.fallbackFlags = ["-std=c++2b"];
};
deno-lsp = {
command = "${pkgs.deno}/bin/deno";
args = ["lsp"];
environment.NO_COLOR = "1";
config.deno = {
enable = true;
lint = true;
unstable = true;
suggest = {
completeFunctionCalls = false;
imports = {hosts."https://deno.land" = true;};
};
inlayHints = {
enumMemberValues.enabled = true;
functionLikeReturnTypes.enabled = true;
parameterNames.enabled = "all";
parameterTypes.enabled = true;
propertyDeclarationTypes.enabled = true;
variableTypes.enabled = true;
};
};
};
nil = {
command = lib.getExe pkgs.nil;
config.nil.formatting.command = ["${lib.getExe pkgs.alejandra}" "-q"];
};
vscode-css-language-server = {
command = "${pkgs.nodePackages.vscode-css-languageserver-bin}/bin/css-languageserver";
args = ["--stdio"];
config = {
provideFormatter = true;
css.validate.enable = true;
scss.validate.enable = true;
};
};
};
};
}

View file

@ -0,0 +1,73 @@
{ colorscheme }: {
"${colorscheme.slug}" = {
palette = builtins.mapAttrs (name: value: "#${value}") colorscheme.colors; # Add leading '#'
"attributes" = "base09";
"comment" = { fg = "base03"; modifiers = [ "italic" ]; };
"constant" = "base09";
"constant.character.escape" = "base0C";
"constant.numeric" = "base09";
"constructor" = "base0D";
"debug" = "base03";
"diagnostic" = { modifiers = [ "underlined" ]; };
"diagnostic.error" = { underline = { style = "curl"; }; };
"diagnostic.hint" = { underline = { style = "curl"; }; };
"diagnostic.info" = { underline = { style = "curl"; }; };
"diagnostic.warning" = { underline = { style = "curl"; }; };
"diff.delta" = "base09";
"diff.minus" = "base08";
"diff.plus" = "base0B";
"error" = "base08";
"function" = "base0D";
"hint" = "base03";
"info" = "base0D";
"keyword" = "base0E";
"label" = "base0E";
"markup.bold" = { fg = "base0A"; modifiers = [ "bold" ]; };
"markup.heading" = "base0D";
"markup.italic" = { fg = "base0E"; modifiers = [ "italic" ]; };
"markup.link.text" = "base08";
"markup.link.url" = { fg = "base09"; modifiers = [ "underlined" ]; };
"markup.list" = "base08";
"markup.quote" = "base0C";
"markup.raw" = "base0B";
"markup.strikethrough" = { modifiers = [ "crossed_out" ]; };
"namespace" = "base0E";
"operator" = "base05";
"special" = "base0D";
"string" = "base0B";
"type" = "base0A";
"ui.background" = { bg = "base00"; };
"ui.bufferline" = { fg = "base04"; bg = "base00"; };
"ui.bufferline.active" = { fg = "base00"; bg = "base03"; modifiers = [ "bold" ]; };
"ui.cursor" = { fg = "base04"; modifiers = [ "reversed" ]; };
"ui.cursor.insert" = { fg = "base0A"; modifiers = [ "underlined" ]; };
"ui.cursor.match" = { fg = "base0A"; modifiers = [ "underlined" ]; };
"ui.cursor.select" = { fg = "base0A"; modifiers = [ "underlined" ]; };
"ui.cursorline.primary" = { fg = "base05"; bg = "base01"; };
"ui.gutter" = { bg = "base00"; };
"ui.help" = { fg = "base06"; bg = "base01"; };
"ui.linenr" = { fg = "base03"; bg = "base00"; };
"ui.linenr.selected" = { fg = "base04"; bg = "base01"; modifiers = [ "bold" ]; };
"ui.menu" = { fg = "base05"; bg = "base01"; };
"ui.menu.scroll" = { fg = "base03"; bg = "base01"; };
"ui.menu.selected" = { fg = "base01"; bg = "base04"; };
"ui.popup" = { bg = "base01"; };
"ui.selection" = { bg = "base02"; };
"ui.selection.primary" = { bg = "base02"; };
"ui.statusline" = { fg = "base0B"; bg = "base02"; };
"ui.statusline.inactive" = { bg = "base01"; fg = "base02"; };
"ui.statusline.insert" = { fg = "base00"; bg = "base0B"; };
"ui.statusline.normal" = { fg = "base00"; bg = "base04"; };
"ui.statusline.select" = { fg = "base00"; bg = "base0E"; };
"ui.text" = "base05";
"ui.text.focus" = "base05";
"ui.virtual.indent-guide" = { fg = "base03"; };
"ui.virtual.ruler" = { bg = "base01"; };
"ui.virtual.whitespace" = { fg = "base01"; };
"ui.window" = { bg = "base01"; };
"variable" = "base08";
"variable.other.member" = "base08";
"warning" = "base09";
};
}

View file

@ -0,0 +1,28 @@
{ lib, ... }:
{
imports = [
./lf #configuration still needs some work
# ./ranger
];
options.programs.console.fileManager = {
lf = {
enable = lib.mkEnableOption "Enable lf file manager";
default = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set lf as the default terminal file manager";
};
};
ranger = {
enable = lib.mkEnableOption "Enable ranger file manager";
default = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set ranger as the default terminal file manager";
};
};
};
}

View file

@ -0,0 +1,65 @@
{ pkgs, lib, config, ... }:
#TODO - mkif wayland for previewer
# - manage previewer dependencies better
# - ripdrag support
# - color parity with eza
let
cfg = config.programs.console.fileManager.lf;
in
{
config = lib.mkIf cfg.enable {
home.sessionVariables.TERMFILEMANAGER = lib.mkIf cfg.default "lf";
xdg.configFile."lf/icons".source = ./icons;
programs.lf = {
enable = true;
settings = {
hidden = true;
ignorecase = true;
drawbox = true;
icons = true;
};
previewer = {
keybinding = "i";
source = "${pkgs.ctpv}/bin/ctpv";
};
commands = {
fzf-lf = ''
''${{
res="$(find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune -o -print 2> /dev/null | sed 1d | cut -b3- | fzf +m)"
if [ -d "$res" ] ; then
cmd="cd"
elif [ -f "$res" ] ; then
cmd="select"
else
exit 0
fi
lf -remote "send $id $cmd \"$res\""
}}
'';
mkdir = ''
''${{
printf "Directory Name: "
read DIR
mkdir $DIR
}}
'';
};
keybindings = {
c = "mkdir";
"<a-f>" = "fzf-lf";
};
extraConfig = ''
&${pkgs.ctpv}/bin/ctpv -s $id
cmd on-quit %${pkgs.ctpv}/bin/ctpv -e $id
set cleaner ${pkgs.ctpv}/bin/ctpvclear
set sixel true
'';
};
home.packages = with pkgs; [ chafa ctpv glow ];
};
}

View file

View file

View file

@ -0,0 +1,14 @@
{ lib, config, ... }:
{
imports = [
./zellij
#./screen
#./tmux
];
options.programs.console.multiplexer = {
zellij = {
enable = lib.mkEnableOption "Enable zellij multiplexer";
};
};
}

View file

@ -0,0 +1,35 @@
{ lib, config, ... }:
let
inherit (config) colorscheme;
inherit (colorscheme) colors;
cfg = config.programs.console.multiplexer.zellij;
in
{
config = lib.mkIf cfg.enable {
programs.zellij = {
enable = true;
settings = {
theme = "${colorscheme.slug}";
default_layout = "compact";
pane_frames = false;
themes = {
"${colorscheme.slug}" = {
fg = "#${colors.base05}";
bg = "#${colors.base00}";
black = "#${colors.base00}";
red = "#${colors.base08}";
green = "#${colors.base0B}";
yellow = "#${colors.base0A}";
blue = "#${colors.base0D}";
magenta = "#${colors.base0E}";
cyan = "#${colors.base0C}";
white = "#${colors.base05}";
orange = "#${colors.base09}";
};
};
};
};
};
}

View file

@ -0,0 +1,12 @@
{ lib, ... }:
{
imports = [
./starship
];
options.programs.console.prompt = {
starship = {
enable = lib.mkEnableOption "Enable starship prompt";
};
};
}

View file

@ -0,0 +1,110 @@
{ config, lib, ... }:
let
cfg = config.programs.console.prompt.starship;
in
{
config = lib.mkIf cfg.enable {
programs.starship = {
enable = true;
settings = {
format =
let
git = "$git_branch$git_commit$git_state$git_status";
cloud = "$aws$gcloud$openstack";
in
''
($nix_shell)$directory(${git})(- ${cloud})$jobs$character
'';
fill = {
symbol = " ";
disabled = false;
};
# Core
username = {
format = "[$user]($style)";
show_always = true;
};
hostname = {
format = "[@$hostname]($style) ";
ssh_only = false;
style = "bold green";
};
shlvl = {
format = "[$shlvl]($style) ";
style = "bold cyan";
threshold = 2;
repeat = true;
disabled = false;
};
cmd_duration = {
format = "took [$duration]($style) ";
};
directory = {
format = "[$path]($style)( [$read_only]($read_only_style)) ";
};
nix_shell = {
format = "[($name \\(develop\\) <- )$symbol]($style) ";
impure_msg = "";
symbol = " ";
style = "bold red";
};
character = {
error_symbol = "[](bold red)";
success_symbol = "[](bold green)";
vimcmd_symbol = "[](bold yellow)";
vimcmd_visual_symbol = "[](bold cyan)";
vimcmd_replace_symbol = "[](bold purple)";
vimcmd_replace_one_symbol = "[](bold purple)";
};
time = {
format = "\\\[[$time]($style)\\\]";
disabled = false;
};
# Cloud
gcloud = {
format = "on [$symbol$active(/$project)(\\($region\\))]($style)";
};
aws = {
format = "on [$symbol$profile(\\($region\\))]($style)";
};
# Icon changes only \/
aws.symbol = " ";
conda.symbol = " ";
dart.symbol = " ";
directory.read_only = " ";
docker_context.symbol = " ";
elixir.symbol = " ";
elm.symbol = " ";
gcloud.symbol = " ";
git_branch.symbol = " ";
golang.symbol = " ";
hg_branch.symbol = " ";
java.symbol = " ";
julia.symbol = " ";
memory_usage.symbol = "󰍛 ";
nim.symbol = "󰆥 ";
nodejs.symbol = " ";
package.symbol = "󰏗 ";
perl.symbol = " ";
php.symbol = " ";
python.symbol = " ";
ruby.symbol = " ";
rust.symbol = " ";
scala.symbol = " ";
shlvl.symbol = "";
swift.symbol = "󰛥 ";
terraform.symbol = "󱁢";
};
};
};
}

View file

@ -0,0 +1,9 @@
{ config, lib, ... }:
let
cfg = config.programs.console.shell.bash;
in
{
config = lib.mkIf cfg.enable {
programs.bash.enable = true;
};
}

View file

@ -0,0 +1,19 @@
{ lib, ... }:
{
imports = [
./fish
./bash
];
options.programs.console.shell = {
fish = {
enable = lib.mkEnableOption "Enable fish configuration";
};
bash = {
enable = lib.mkEnableOption "Enable bash configuration";
};
zsh = {
enable = lib.mkEnableOption "Enable zsh configuration";
};
};
}

View file

@ -0,0 +1,134 @@
{ pkgs, lib, config, ... }:
let
cfg = config.programs.console.shell.fish;
inherit (lib) mkIf;
hasPackage = pname: lib.any (p: p ? pname && p.pname == pname) config.home.packages;
hasEza = hasPackage "eza";
hasNeovim = config.programs.neovim.enable;
hasBat = hasPackage "bat";
hasHelix = hasPackage "helix";
hasKitty = config.programs.kitty.enable;
in
{
config = {
programs.fish = mkIf cfg.enable {
enable = true;
shellAbbrs = rec {
jqless = "jq -C | less -r";
n = "nix";
nd = "nix develop -c $SHELL";
ns = "nix shell";
nsn = "nix shell nixpkgs#";
nb = "nix build";
nbn = "nix build nixpkgs#";
nf = "nix flake";
nr = "nixos-rebuild --flake .";
nrs = "nixos-rebuild --flake . switch";
snr = "sudo nixos-rebuild --flake .";
snrs = "sudo nixos-rebuild --flake . switch";
hm = "home-manager --flake .";
hms = "home-manager --flake . switch";
fe = mkIf hasHelix "cd $FLAKE; hx $FLAKE";
f = "cd $FLAKE";
tree = mkIf hasEza "eza -T --icons --group-directories-first";
ls = mkIf hasEza "eza -a --icons --group-directories-first";
lsd = mkIf hasEza "eza -al --icons --group-directories-first";
lst = mkIf hasEza "eza -T -L 5 --icons --group-directories-first";
lsta = mkIf hasEza "eza -T --icons --group-directories-first";
cat = mkIf hasBat "bat";
vim = mkIf hasNeovim "nvim";
};
functions = {
fish_greeting = "";
zellij_session_select = ''
if not set -q ZELLIJ
set -l ZJ_SESSIONS (zellij list-sessions | awk '{print $1}')
set -l NO_SESSIONS (count $ZJ_SESSIONS)
if test $NO_SESSIONS -gt 0
set -l SELECTED_SESSION (printf "%s\n" $ZJ_SESSIONS | sk --ansi)
if test -n "$SELECTED_SESSION"
zellij attach -c $SELECTED_SESSION
else
zellij
end
else
zellij
end
end
'';
fish_flake_edit = ''
cd $FLAKE
hx $FLAKE
'';
fish_hello_world = ''
echo "Hello World"; string repeat -N \n --count=(math (count (fish_prompt)) - 1); commandline -f repaint
'';
fish_user_key_bindings = ''
bind --preset -M insert \cf fish_flake_edit
bind --preset -M insert \ec skim_cd_widget
'';
};
interactiveShellInit =
# zellij auto start script
''
zellij_session_select
'' +
''
set --global KITTY_INSTALLATION_DIR "${pkgs.kitty}/lib/kitty"
set --global KITTY_SHELL_INTEGRATION enabled
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
'' +
# Use vim bindings and cursors
''
fish_vi_key_bindings
set fish_cursor_default block blink
set fish_cursor_insert line blink
set fish_cursor_replace_one underscore blink
set fish_cursor_visual block
'' +
# Use terminal colors
''
set -U fish_color_autosuggestion brblack
set -U fish_color_cancel -r
set -U fish_color_command brgreen
set -U fish_color_comment brmagenta
set -U fish_color_cwd green
set -U fish_color_cwd_root red
set -U fish_color_end brmagenta
set -U fish_color_error brred
set -U fish_color_escape brcyan
set -U fish_color_history_current --bold
set -U fish_color_host normal
set -U fish_color_match --background=brblue
set -U fish_color_normal normal
set -U fish_color_operator cyan
set -U fish_color_param brblue
set -U fish_color_quote yellow
set -U fish_color_redirection bryellow
set -U fish_color_search_match 'bryellow' '--background=brblack'
set -U fish_color_selection 'white' '--bold' '--background=brblack'
set -U fish_color_status red
set -U fish_color_user brgreen
set -U fish_color_valid_path --underline
set -U fish_pager_color_completion normal
set -U fish_pager_color_description yellow
set -U fish_pager_color_prefix 'white' '--bold' '--underline'
set -U fish_pager_color_progress 'brwhite' '--background=cyan'
'';
};
};
}

View file

@ -0,0 +1,20 @@
{ lib, ... }:
{
imports = [
./nixIndex
./git
./tools
];
options.programs.console.utility = {
nixIndex = {
enable = lib.mkEnableOption "Enable nixIndex configuration";
};
git = {
enable = lib.mkEnableOption "Enable git + tools";
};
tools = {
enable = lib.mkEnableOption "Enable various console tools";
};
};
}

View file

@ -0,0 +1,24 @@
{ pkgs, config, lib, ... }:
let
cfg = config.programs.console.utility.git;
in
{
config = {
programs.git = lib.mkIf cfg.enable {
enable = true;
package = pkgs.gitAndTools.gitFull;
userName = "ooks-io";
userEmail = "ooks@protonmail.com";
extraConfig = {
gpg."ssh".program = "${pkgs._1password-gui}/bin/op-ssh-sign";
};
ignores = [ ".direnv" "result" ];
lfs.enable = true;
};
home.packages = with pkgs; [
git-credential-1password
];
};
}

View file

@ -0,0 +1,38 @@
{ pkgs, config, lib, ... }:
let
cfg = config.programs.console.utility.nixIndex;
update-script = pkgs.writeShellApplication {
name = "fetch-nix-index-database";
runtimeInputs = with pkgs; [ wget coreutils ];
text = ''
filename="index-x86_64-linux"
mkdir -p ~/.cache/nix-index
cd ~/.cache/nix-index
wget -N "https://github.com/Mic92/nix-index-database/releases/latest/download/$filename"
ln -f "$filename" files
'';
};
in
{
config = lib.mkIf cfg.enable {
programs.nix-index.enable = true;
systemd.user.services.nix-index-database-sync = {
Unit = { Description = "fetch mic92/nix-index-database"; };
Service = {
Type = "oneshot";
ExecStart = "${update-script}/bin/fetch-nix-index-database";
Restart = "on-failure";
RestartSec = "5m";
};
};
systemd.user.timers.nix-index-database-sync = {
Unit = { Description = "Automatic github:mic92/nix-index-database fetching"; };
Timer = {
OnBootSec = "10m";
OnUnitActiveSec = "24h";
};
Install = { WantedBy = [ "timers.target" ]; };
};
};
}

View file

@ -0,0 +1,69 @@
{ pkgs, lib, config, ... }:
let
cfg = config.programs.console.utility.tools;
in
{
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
bc # Calculator
# file utility
duf
du-dust
fd
ripgrep
# archive
zip
unzip
unrar
# file transfer
wget
httpie # Better curl
# resource manager
powertop
diffsitter # Better diff
jq # JSON pretty printer and manipulator
comma # Install and run with ","
tldr # Community maintained help pages
progress
killall
acpi
# Nix tooling
alejandra
];
programs = {
btop.enable = true;
eza.enable = true;
bat = {
enable = true;
config = {
theme = "base16";
pager = "less -FR";
};
};
direnv = {
enable = true;
nix-direnv.enable = true;
};
skim = {
enable = true;
enableFishIntegration = lib.mkIf config.programs.console.shell.fish.enable true;
defaultCommand = "rg --files --hidden";
changeDirWidgetOptions = [
"--preview 'eza --icons -L 3 -T --color always {} | head -200'"
"--exact"
];
fileWidgetCommand = "rg --files";
fileWidgetOptions = [
"--preview 'bat --color=always {}'"
];
};
};
};
}