[feat] Restructure the repo

This commit is contained in:
uttarayan21
2024-03-13 23:04:54 +05:30
parent f5bcff9c73
commit 6961bb2733
125 changed files with 0 additions and 5411 deletions

63
common/firefox.nix Normal file
View File

@@ -0,0 +1,63 @@
{ device, pkgs, ... }: {
programs.firefox = {
enable = device.isLinux;
profiles.default = {
userChrome = let
csshacks = pkgs.fetchFromGitHub {
owner = "MrOtherGuy";
repo = "firefox-csshacks";
rev = "master";
sha256 = "sha256-XJ+MTEADzOsCIh0I8EAxbtIpDHfMJsN68sKBy7/1l60=";
};
in ''
@import url(${csshacks}/chrome/toolbars_below_content.css);
@import url(${csshacks}/chrome/scrollable_menupopups.css);
@import url(${csshacks}/chrome/linux_gtk_window_control_patch.css);
'';
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
privacy-badger
bitwarden
tridactyl
];
};
nativeMessagingHosts = [ pkgs.tridactyl-native ];
policies = {
ExtensionSettings = {
"uBlock0@raymondhill.net" = {
install_url =
"https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
installation_mode = "force_installed";
};
};
DisableFirefoxStudies = true;
DisablePocket = true;
DisableTelemetry = true;
FeatureRecommendations = false;
SkipOnboarding = true;
Preferences = {
"toolkit.legacyUserProfileCustomizations.stylesheets" = {
Value = true;
Status = "default";
};
"browser.urlbar.suggest.calculator" = {
Value = true;
Status = "default";
};
"extensions.quarantinedDomains.enabled" = {
Value = false;
Status = "default";
};
};
FirefoxHome = {
"Search" = true;
"TopSites" = false;
"SponsoredTopSites" = false;
"Highlights" = false;
"Pocket" = false;
"SponsoredPocket" = false;
"Snippets" = false;
"Locked" = false;
};
};
};
}

257
common/home.nix Normal file
View File

@@ -0,0 +1,257 @@
{ inputs, config, pkgs, lib, device, ... }:
let
# https://mipmip.github.io/home-manager-option-search/
start-tmux = (import ../scripts/start-tmux.nix) pkgs;
lazy = false;
in
{
imports = [
inputs.nix-index-database.hmModules.nix-index
# Include the results of the hardware scan.
./tmux.nix
./wezterm.nix
] ++ lib.optionals device.isLinux [ ../linux ]
++ lib.optionals (!lazy) [ ./nvim.nix ];
home.packages = with pkgs;
[
gnupg
gpg-tui
ngrok
slack
yarn
spotify-player
qmk
nodejs
neovide
sqls
vcpkg
file
yt-dlp
gh
just
jq
tldr
bottom
macchina
ripgrep
fd
nixfmt
dust
cachix
rustup
cmake
fzf
clang
neovim-nightly
nil
pkg-config
lua-language-server
# mpv
(nerdfonts.override { fonts = [ "Hasklig" ]; })
] ++ lib.optionals device.isLinux [
psst
gnome.seahorse
gnome.nautilus
nextcloud-client
sbctl
gparted
gptfdisk
polkit_gnome
dig
mullvad
steam-run
(pkgs.catppuccin-gtk.override {
variant = "mocha";
size = "standard";
accents = [ "mauve" ];
tweaks = [ "normal" ];
})
(pkgs.catppuccin-papirus-folders.override {
accent = "mauve";
flavor = "mocha";
})
usbutils
handlr-regex
webcord-vencord
spotify
lsof
wl-clipboard
ncpamixer
(pkgs.writeShellApplication {
name = "xdg-open";
runtimeInputs = [ handlr-regex ];
text = ''
handlr open "$@"
'';
})
] ++ lib.optionals device.isMac [ ];
# xdg.enable = true;
programs = {
nix-index-database.comma.enable = true;
helix = {
enable = true;
settings = {
theme = "base16";
editor = {
line-number = "relative";
lsp.display-messages = true;
};
keys.normal = {
space.space = "file_picker";
space.w = ":w";
space.q = ":q";
esc = [ "collapse_selection" "keep_primary_selection" ];
};
};
};
git = {
enable = true;
userName = "uttarayan21";
userEmail = "email@uttarayan.me";
};
nix-index = {
enable = true;
enableFishIntegration = true;
};
fish = {
enable = true;
shellAbbrs = {
vim = "nvim";
vi = "nvim";
nv = "neovide";
g = "git";
yy = "yazi";
cd = "z";
ls = "eza";
cat = "bat";
t = "${start-tmux}";
};
shellAliases = { g = "git"; };
shellInit = ''
set fish_greeting
yes | fish_config theme save "Catppuccin Mocha"
'';
interactiveShellInit = ''
${pkgs.spotify-player}/bin/spotify_player generate fish | source
${pkgs.macchina}/bin/macchina
'';
};
nushell = {
enable = true;
shellAliases = {
cd = "z";
yy = "yazi";
nv = "neovide";
cat = "bat";
};
package = pkgs.nushellFull;
configFile.text = ''
$env.config = {
show_banner: false,
}
'';
};
zoxide = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
starship = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
settings =
let flavour = "mocha"; # Replace with your preferred palette
in {
# Other config here
format = "$all"; # Remove this line to disable the default prompt format
palette = "catppuccin_${flavour}";
} // builtins.fromTOML (builtins.readFile
(pkgs.catppuccinThemes.starship + /palettes/${flavour}.toml));
};
eza = {
enable = true;
# enableAliases = true;
git = true;
icons = true;
};
carapace = {
enable = true;
# enableFishIntegration = true;
enableNushellIntegration = true;
};
fzf = {
enable = true;
package = pkgs.fzf;
enableFishIntegration = true;
tmux.enableShellIntegration = true;
};
yazi = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
bat = {
enable = true;
config = { theme = "catppuccin"; };
themes = {
catppuccin = {
src = "${pkgs.catppuccinThemes.bat}/themes";
file = "Catppuccin Mocha.tmTheme";
};
};
};
rbw = {
enable = true;
settings = {
email = "uttarayan21@gmail.com";
base_url = "https://pass.uttarayan.me";
pinenttry =
if device.isMac then pkgs.pinentry_mac else pkgs.pinentry-qt;
};
};
# Let Home Manager install and manage itself.
home-manager = { enable = true; };
};
fonts.fontconfig.enable = true;
home = {
# Home Manager needs a bit of information about you and the paths it should
# manage.
username = device.user;
homeDirectory =
if device.isMac then
lib.mkForce "/Users/${device.user}"
else
lib.mkForce "/home/${device.user}";
stateVersion = "23.11";
file = {
".config/tmux/sessions".source = ../../tmux/sessions;
".config/macchina".source = ../../macchina;
".config/fish/themes".source = pkgs.catppuccinThemes.fish + "/themes";
# ".cache/nix-index".source = pkgs.nix-index-database;
} // (if lazy then {
".config/nvim/lua".source = ../../nvim/lua;
".config/nvim/init.lua".source = ../../nvim/init.lua;
} else
{ });
sessionVariables = {
EDITOR = "nvim";
SHELL = "${pkgs.nushellFull}/bin/nu";
CARGO_TARGET_DIR = "${config.xdg.cacheHome}/cargo/target";
BROWSER = "xdg-open";
};
sessionPath = [
"${config.home.homeDirectory}/.local/bin"
"${config.home.homeDirectory}/.nix-profile/bin"
];
};
}

349
common/nvim.nix Normal file
View File

@@ -0,0 +1,349 @@
{ pkgs, config, inputs, ... }: {
imports = [ inputs.nixneovim.nixosModules.default ];
programs.nixneovim = {
enable = true;
options = {
number = true;
relativenumber = true;
tabstop = 4;
softtabstop = 4;
shiftwidth = 4;
expandtab = true;
hidden = true;
smartcase = true;
termguicolors = true;
signcolumn = "yes";
wrap = true;
completeopt = "menu,menuone,popup,noselect";
undodir = "${config.xdg.cacheHome}/undodir";
undofile = true;
};
globals = { mapleader = " "; };
plugins = {
lspconfig = {
enable = true;
servers = {
nil = {
enable = true;
extraConfig =
/* lua */
''
settings = {
['nil'] = {
formatting = {
command = { "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" },
},
nix = {
flake = {
autoArchive = true,
},
},
},
},
'';
};
lua-language-server.enable = true;
jsonls.enable = true;
html.enable = true;
# pylyzer.enable = true;
sqls = {
enable = true;
onAttachExtra =
/* lua */
''
require('sqls').on_attach(client, bufnr)
'';
};
# rust-analyzer.enable = true;
};
extraLua.pre =
/* lua */
''
local lsp_zero = require'lsp-zero'
local lspconfig = require 'lspconfig'
lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({buffer = bufnr})
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(bufnr, true)
end
end)
'';
# extraLua.post = ''
# vim.lsp.inlay_hint.enable(bufnr, true)
# '';
};
nvim-dap.enable = true;
todo-comments.enable = true;
lualine.enable = true;
commentary.enable = true;
surround.enable = true;
which-key.enable = true;
ufo.enable = true;
fugitive.enable = true;
markdown-preview = {
enable = true;
autoStart = true;
};
treesitter-context.enable = true;
ts-context-commentstring.enable = true;
treesitter = {
enable = true;
indent = true;
folding = true;
refactor = {
smartRename = {
enable = true;
};
};
grammars = [ pkgs.tree-sitter-grammars.tree-sitter-just ];
installAllGrammars = true;
};
mini = {
enable = true;
ai.enable = true;
# pairs.enable = true;
# cursorword.enable = true;
starter.enable = true;
};
};
colorschemes = {
catppuccin = {
enable = true;
flavour = "mocha";
};
};
mappings = {
normal = {
"<leader>ff" = "require'telescope.builtin'.find_files";
"<leader>gg" = "require'telescope.builtin'.live_grep";
"<leader>;" = "require'telescope.builtin'.buffers";
"<leader>o" = "[[<cmd>TroubleToggle<cr>]]";
"<leader>ee" = "require'rest-nvim'.run";
"<leader>ec" = "function() require'rest-nvim'.run(true) end";
"<leader>\\\"" = ''[["+]]'';
"vff" = "[[<cmd>vertical Gdiffsplit<cr>]]";
"<C-k>" = "vim.lsp.buf.definition";
"gi" = "require'telescope.builtin'.lsp_incoming_calls";
"<leader>a" = "vim.lsp.buf.code_action";
"F" = "function() vim.lsp.buf.format({ async = true }) end";
"<leader><leader>" = "'<c-^>'";
"<leader>q" = "[[<cmd>bw<cr>]]";
"<leader>n" = "[[<cmd>bnext<cr>]]";
"<leader>p" = "[[<cmd>bprev<cr>]]";
"<C-w>\\\"" = "[[<cmd>split<cr>]]";
"<C-w>%" = "[[<cmd>vsplit<cr>]]";
"<C-l>" = "[[<cmd>Outline<cr>]]";
"<C-\\\\>" = "require('FTerm').toggle";
};
terminal = {
"<C-\\\\>" = "require('FTerm').toggle";
};
insert = {
"<C-\\\\>" = "require('FTerm').toggle";
};
};
extraPlugins = with pkgs.vimPlugins; [
comfortable-motion
vim-abolish
telescope-nvim
telescope-ui-select-nvim
telescope-fzf-native-nvim
telescope-file-browser-nvim
telescope-dap-nvim
rustaceanvim
# Treesitter stuff
outline-nvim
# lsp stuff
nvim-cmp
cmp-buffer
cmp-path
cmp-cmdline
cmp-nvim-lsp
cmp-nvim-lua
cmp_luasnip
cmp-tmux
cmp-treesitter
cmp-git
luasnip
fidget-nvim
copilot-lua
lsp-zero-nvim
trouble-nvim
crates-nvim
sqls-nvim
# No more postman
rest-nvim
# UI
noice-nvim
nvim-web-devicons
# Utils
FTerm-nvim
plenary-nvim
nix-develop-nvim
pkgs.tree-sitter-grammars.tree-sitter-just
];
extraConfigLua = /* lua */ ''
require('rest-nvim').setup()
require('telescope').setup {
defaults = {
initial_mode = 'insert',
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
}
}
}
require('telescope').load_extension("ui-select")
require('telescope').load_extension("dap")
require('telescope').load_extension("fzf")
require('telescope').load_extension("file_browser")
require('telescope').load_extension("rest")
vim.g.rustaceanvim = {
tools = {
enable_clippy = false,
},
server = {
capabilities = require 'lsp-zero'.get_capabilities(),
on_attach = function(client, bufnr)
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(bufnr, true)
end
end,
},
dap = {
autoload_configurations = false
},
}
require("copilot").setup({
suggestion = {
enabled = true,
auto_trigger = true,
keymap = {
accept = "<C-l>",
}
},
panel = { enabled = true },
})
require 'fidget'.setup()
-- =======================================================================
-- nvim-cmp
-- =======================================================================
local cmp = require("cmp")
cmp.setup({
view = {
entries = { name = 'custom', selection_order = 'near_cursor' }
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
sources = cmp.config.sources({
{ name = "copilot", },
{ name = 'buffer' },
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'treesitter' },
{ name = 'path' },
{ name = 'git' },
{ name = 'tmux' }
}),
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm(),
['<C-y>'] = cmp.mapping.complete(),
-- ['<C-Space>'] = cmp.mapping.complete(),
['<C-n>'] = cmp.config.next,
['<C-p>'] = cmp.config.prev,
})
})
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline {
-- ['<C-n>'] = cmp.config.disable,
-- ['<C-p>'] = cmp.config.disable,
},
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline {
-- ['<C-n>'] = cmp.config.disable,
-- ['<C-p>'] = cmp.config.disable,
},
-- mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})
require('crates').setup()
require('outline').setup()
require("noice").setup({
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
},
},
-- you can enable a preset for easier configuration
presets = {
bottom_search = false, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = true, -- add a border to hover docs and signature help
},
})
require 'FTerm'.setup({
border = 'double',
dimensions = {
height = 0.95,
width = 0.95,
},
cmd = "fish",
blend = 10,
})
'';
# builtins.readFile ./extraConfig.lua;
package = pkgs.neovim-nightly;
};
}

74
common/tmux.nix Normal file
View File

@@ -0,0 +1,74 @@
{ pkgs, ... }:
let
scratchpad = pkgs.writeShellScript "scratchpad" ''
width=''${2:-95%}
height=''${2:-95%}
if [ "$(tmux display-message -p -F "#{session_name}")" = "scratch" ];then
tmux detach-client
else
tmux popup -d '#{pane_current_path}' -xC -yC -w$width -h$height -E "tmux attach -t scratch || tmux new -s scratch"
fi
'';
in {
programs.tmux = {
enable = true;
shell = "${pkgs.nushellFull}/bin/nu";
terminal = "tmux-256color";
prefix = "C-q";
historyLimit = 100000;
keyMode = "vi";
plugins = with pkgs; [
tmuxPlugins.better-mouse-mode
tmuxPlugins.tmux-fzf
tmuxPlugins.fzf-tmux-url
{
plugin = tmuxPlugins.tmux-super-fingers;
extraConfig = "set -g @super-fingers-key o";
}
{
plugin = tmuxPlugins.catppuccin;
extraConfig =
# tmux
''
set -g @catppuccin_flavour 'mocha'
set -g @catppuccin_window_default_text ''''''
'';
}
{
plugin = tmuxPlugins.battery;
extraConfig =
# tmux
''
set -g @catppuccin_status_modules_right "battery application session date_time"
'';
}
];
extraConfig =
# tmux
''
set -gw mode-keys vi
set -g status-keys vi
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM
set -sg escape-time 10
set -sa terminal-features ',wezterm:RGB'
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -n C-\\ run-shell ${scratchpad}
bind C-n next-window
bind C-p previous-window
bind C-q last-window
if-shell 'uname | grep -q "Darwin"' { set -s copy-command "pbcopy" }
if-shell 'uname | grep -q "Linux"' { set -s copy-command "wl-copy" }
'';
};
}

33
common/wezterm.nix Normal file
View File

@@ -0,0 +1,33 @@
{ pkgs, ... }: {
programs.wezterm = {
enable = true;
extraConfig =
/* lua */
''
local wezterm = require 'wezterm';
return {
term = "wezterm",
font = wezterm.font_with_fallback({
"Hasklug Nerd Font Mono",
"Symbols Nerd Font Mono"
}),
color_scheme = "Catppuccin Mocha",
font_size = 16,
initial_cols = 200,
hide_tab_bar_if_only_one_tab = true,
window_background_opacity = 0.8,
cursor_blink_rate = 8,
default_cursor_style = "BlinkingBlock",
default_prog = { "${pkgs.fish.outPath}/bin/fish", "-l" },
window_padding = {
left = 2,
right = 0,
top = 2,
bottom = 0,
},
window_decorations = "RESIZE",
use_ime = false,
}
'';
};
}