refactor home-manager

This commit is contained in:
♥ Minnie ♥ 2024-01-21 21:01:42 +08:00
parent a48829bbe6
commit caed1fc0d4
31 changed files with 243 additions and 270 deletions

View file

@ -0,0 +1,17 @@
{ pkgs, ... }:
{
imports = [
./git.nix
./zsh.nix
];
home.packages = with pkgs; [
lazygit
];
programs.ssh = {
enable = true;
matchBlocks."viridian".hostname = "192.168.1.102";
};
}

View file

@ -0,0 +1,18 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
lazygit
];
programs.git = {
enable = true;
userName = "sajenim";
userEmail = "its.jassy@pm.me";
extraConfig = {
init.defaultBranch = "main";
core.sshCommand = "~/.ssh/sajenim_sk";
user.signingkey = "~/.ssh/signing_sk";
};
};
}

View file

@ -0,0 +1,61 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
fzf # command-line fuzzy finder
];
programs.zsh = {
enable = true;
# Enable extra features
enableAutosuggestions = true;
enableCompletion = true;
syntaxHighlighting = {
enable = true;
};
dotDir = ".config/zsh";
# Commands that should be added to to top of '.zshrc'
initExtraFirst = ''
'';
# Aliases
shellAliases = {
c = "clear";
la = "ls -a";
ll = "ls -l";
tt = "wezterm cli set-tab-title ";
};
# An attribute set that adds to named directory hash table
dirHashes = {
# QMK Keymaps
crkbd = "$HOME/.github/qmk_keymaps/keyboards/crkbd/keymaps/sajenim";
kchrn = "$HOME/.github/qmk_keymaps/keyboards/keychron/q4/ansi_v2/keymaps/sajenim";
};
# Install plugins
plugins = [
{
name = "fzf-tab";
src = pkgs.fetchFromGitHub {
owner = "Aloxaf";
repo = "fzf-tab";
rev = "5a81e13792a1eed4a03d2083771ee6e5b616b9ab";
sha256 = "dPe5CLCAuuuLGRdRCt/nNruxMrP9f/oddRxERkgm1FE=";
};
}
];
# Extra commands that should be added to '.zshrc'
initExtra = ''
eval "$(direnv hook zsh)"
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
path+=('/home/sajenim/.local/bin')
export PATH
PROMPT='%F{blue}%n@%m %F{cyan}%~ %F{red} %f';
'';
};
}

View file

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

View file

@ -1,5 +1,5 @@
:root {
--font-primary: Fira Code;
--font-primary: Fisa Code;
/* Gruvbox Material Dark Hard */
--fg0: #d4be98;
@ -22,6 +22,7 @@
--interactive-normal: var(--grey0);
--interactive-active: var(--grey0);
--channel-icon: var(--grey0);
--channeltextarea-background: var(--bg0_66);
--scrollbar-auto-thumb: var(--grey0);
--scrollbar-auto-track: var(--bg1);
@ -33,35 +34,8 @@
--background-secondary: var(--bg0_66);
--background-secondary-alt: var(--bg0_33);
--background-tertiary: var(--bg1);
--background-message-hover: var(--bg1);
--background-mentioned: var(--bg1);
--background-message-hover: var(--bg0_33);
--background-mentioned: var(--bg0_66);
--bg-overlay-selected: var(--bg1);
}
/* Message Box */
.scrollableContainer-15eg7h {
background-color: var(--bg1);
}
.slateTextArea-27tjG0 {
color: var(--grey0);
}
/* Search Box */
.search-39IXmY {
display: none;
}
/* Add a Server + Explore Public Servers */
.circleIconButton-1VxDrg {
color: var(--grey0);
}
/* Remove: Nitro, Gif, Stickers, Emoji buttons */
.buttons-uaqb-5 {
display: none;
}
/* Remove: New Message Bar */
.newMessagesBar-1hF-9G {
display: none;
}

View file

@ -1,4 +1,4 @@
{ inputs, outputs, lib, config, pkgs, ... }:
{ pkgs, ... }:
{
nixpkgs.overlays = [
@ -16,4 +16,9 @@
enable = true;
source = ./config/custom.css;
};
home.persistence."/persist/home/sajenim".directories = [
".config/discord"
".config/BetterDiscord"
];
}

View file

@ -0,0 +1,33 @@
{ inputs, pkgs, ... }:
{
imports = [
./picom.nix
./rofi.nix
];
home.packages = with pkgs; [
feh
xmobar
unstable.wezterm
];
home.file = {
".local/share/fonts" = {
recursive = true;
source = "${inputs.self}/pkgs/patched-fonts";
};
".xinitrc".source = ./xinitrc;
};
xdg.configFile = {
wezterm = { source = ./wezterm/config; recursive = true; };
};
xsession.windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
config = "${inputs.self}/pkgs/xmonad-config/src/xmonad.hs";
};
}

View file

@ -0,0 +1,9 @@
{ ... }:
{
programs.rofi = {
enable = true;
font = "Fisa Code 10";
};
}

View file

@ -0,0 +1,21 @@
{ pkgs, ... }:
{
imports = [
./mangohud.nix
];
home = {
packages = with pkgs; [
gamemode
protonup-ng
prismlauncher
runelite
];
persistence."/persist/home/sajenim" = {
directories = [
".runelite"
];
};
};
}

View file

@ -0,0 +1,31 @@
--
-- Bootstrap lazy.nvim
--
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
--
-- Load our configurations
--
require('configs.options')
--
-- Load our plugin specs
--
require('lazy').setup('plugins')

View file

@ -0,0 +1,17 @@
-- Keybinds
vim.g.mapleader = ' '
-- General
vim.opt.number = true
vim.opt.showmode = false
vim.opt.swapfile = false
vim.opt.clipboard = 'unnamedplus'
-- Tabs & spaces
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.autoindent = true
vim.opt.copyindent = true

View file

@ -0,0 +1,165 @@
return {
--
-- LSP Configuration
--
{
'neovim/nvim-lspconfig',
event = { 'BufReadPost', 'BufNewFile' },
dependencies = {
'hrsh7th/nvim-cmp', -- Autocompletion plugin
'hrsh7th/cmp-nvim-lsp', -- LSP source for nvim-cmp
'saadparwaiz1/cmp_luasnip', -- Snippets source for nvim-cmp
'L3MON4D3/LuaSnip', -- Snippets plugin
},
config = function ()
--
-- Setup language servers.
--
local lspconfig = require('lspconfig')
-- Lua
lspconfig.lua_ls.setup {
on_init = function(client)
local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
}
}
})
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end
}
-- Haskell
lspconfig.hls.setup{
filetypes = { 'haskell', 'lhaskell', 'cabal' },
}
-- Nix
lspconfig.nil_ls.setup{}
--
-- Global mappings
--
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})
--
-- Autocompletion
--
-- Add additional capabilities supported by nvim-cmp
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
-- on_attach = my_custom_on_attach,
capabilities = capabilities,
}
end
-- luasnip setup
local luasnip = require 'luasnip'
-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-u>'] = cmp.mapping.scroll_docs(-4), -- Up
['<C-d>'] = cmp.mapping.scroll_docs(4), -- Down
-- C-b (back) C-f (forward) for snippet placeholder navigation.
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}
end
},
}

View file

@ -0,0 +1,21 @@
return {
--
-- Modified version of gruvbox
--
{
'sainnhe/gruvbox-material',
lazy = false,
priority = 1000,
config = function()
vim.o.termguicolors = true
vim.o.background = 'dark'
vim.g.gruvbox_material_background = 'hard'
vim.g.gruvbox_material_better_performance = 1
vim.cmd([[colorscheme gruvbox-material]])
end,
},
}

View file

@ -0,0 +1,98 @@
return {
--
-- Treesitter
--
{
'nvim-treesitter/nvim-treesitter',
build = ":TSUpdate",
config = function()
local configs = require('nvim-treesitter.configs')
configs.setup({
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
})
end
},
--
-- Fuzzy Finder
--
{
'nvim-telescope/telescope.nvim',
tag = '0.1.3',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
},
keys = {
{ '<leader>ff', '<cmd>Telescope find_files<cr>', desc = 'Find Files' },
{ '<leader>fg', '<cmd>Telescope live_grep<cr>' , desc = 'Live Grep' },
{ '<leader>fb', '<cmd>Telescope buffers<cr>' , desc = 'Buffers' },
{ '<leader>fh', '<cmd>Telescope help_tags<cr>' , desc = 'Help Tags' },
},
config = function()
require('telescope').setup()
end
},
--
-- Commenting
--
{
'numToStr/Comment.nvim',
config = function()
require('Comment').setup()
end
},
--
-- Git Commands
--
{
'kdheepak/lazygit.nvim',
dependencies = {
'nvim-lua/plenary.nvim'
},
keys = {
{ '<leader>gg', '<cmd>LazyGit<cr>', desc = 'LazyGit' },
}
},
--
-- Display Keybindings
--
{
'folke/which-key.nvim',
event = 'VeryLazy',
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = { },
},
--
-- Preview Markdown
--
{
'iamcco/markdown-preview.nvim',
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
build = "cd app && npm install",
init = function ()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
},
}

View file

@ -0,0 +1,60 @@
return {
--
-- File explorer
--
{
'nvim-neo-tree/neo-tree.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
'MunifTanjim/nui.nvim',
},
keys = {
{ '\\', '<cmd>Neotree reveal<cr>', desc = 'Neotree' },
},
opts = {
close_if_last_window = true,
}
},
--
-- Statusline
--
{
'nvim-lualine/lualine.nvim',
event = 'VeryLazy',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'gruvbox-material',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
globalstatus = true,
extensions = {
'neotree'
},
}
}
end,
},
--
-- Git decorations
--
{
'lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup()
end
}
}

View file

@ -0,0 +1,27 @@
{ pkgs, ... }:
{
programs.neovim = {
enable = true;
#package = pkgs.neovim-nightly;
defaultEditor = true;
extraPackages = with pkgs; [
# Required for nvim-treesitter
gcc
# Required for telescope.nvim
fd
ripgrep
# Required for markdown-preview.nvim
nodejs
yarn
# Language server packages
nil
haskell-language-server
lua-language-server
];
};
home.persistence."/persist/home/sajenim".directories = [ ".local/share/nvim" ];
xdg.configFile.nvim = { source = ./config; recursive = true; };
}

View file

@ -0,0 +1,17 @@
{ pkgs, ... }:
{
home = {
packages = with pkgs; [
blender
freecad
openscad
prusa-slicer
];
persistence."/persist/home/sajenim" = {
directories = [
".config/PrusaSlicer"
];
};
};
}

View file

@ -0,0 +1,48 @@
{ pkgs, ... }:
{
imports = [
./global
./features/desktop/common
./features/desktop/jade
./features/printing
./features/games
];
home = {
packages = with pkgs; [
spotify
jellyfin-media-player
firefox
pulsemixer
# Graphics
gimp
inkscape
krita
# Games
gamemode
protonup-ng
prismlauncher
runelite
# Hardware
libratbag
piper
];
persistence."/persist/home/sajenim" = {
directories = [
".mozilla"
".config/Yubico"
"Documents"
"Downloads"
"Games"
"Music"
"Pictures"
"Printer"
"Videos"
];
};
};
}

View file

@ -0,0 +1,48 @@
{ inputs, outputs, ... }: {
imports = [
inputs.impermanence.nixosModules.home-manager.impermanence
../features/cli
../features/nvim
];
nixpkgs = {
overlays = [
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.unstable-packages
];
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
};
programs.home-manager.enable = true;
home = {
username = "sajenim";
homeDirectory = "/home/sajenim";
sessionVariables = {
EDITOR = "nvim";
};
persistence."/persist/home/sajenim" = {
directories = [
".backup"
".github"
".gnupg"
".ssh"
".local/bin"
".local/share/nix"
];
files = [
".zsh_history"
];
allowOther = true;
};
};
systemd.user.startServices = "sd-switch";
home.stateVersion = "22.11";
}

View file

@ -1,148 +0,0 @@
# This is your home-manager configuration file
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
{ inputs, outputs, pkgs, ... }: {
# You can import other home-manager modules here
imports = [
# If you want to use modules your own flake exports (from modules/home-manager):
# outputs.homeManagerModules.example
# Or modules exported from other flakes (such as nix-colors):
# inputs.nix-colors.homeManagerModules.default
inputs.impermanence.nixosModules.home-manager.impermanence
# You can also split up your configuration and import pieces of it here:
# User services
./services/picom
# User programs
./programs/discord
./programs/mangohud
./programs/rofi
# Common programs
../common/programs/git
../common/programs/zsh
../common/programs/nvim
];
nixpkgs = {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.unstable-packages
# You can also add overlays exported from other flakes:
# inputs.neovim-nightly-overlay.overlays.default
# Or define it inline, for example:
# (final: prev: {
# hi = final.hello.overrideAttrs (oldAttrs: {
# patches = [ ./change-hello-to-hi.patch ];
# });
# })
];
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
# Workaround for https://github.com/nix-community/home-manager/issues/2942
allowUnfreePredicate = (_: true);
};
};
# Enable home-manager
programs = {
home-manager.enable = true;
ssh = {
enable = true;
matchBlocks = {
"viridian" = {
hostname = "192.168.1.102";
};
};
};
};
home = {
# Setup our user environment
username = "sajenim";
homeDirectory = "/home/sajenim";
sessionVariables = {
EDITOR = "nvim";
};
# Install some packages
packages = with pkgs; [
# Stable user programs
feh
gamemode
spotify
prismlauncher
runelite
jellyfin-media-player
xmobar
# Unstable user programs
unstable.wezterm
];
persistence."/persist/home/sajenim" = {
directories = [
"Documents"
"Downloads"
"Games"
"Music"
"Pictures"
"Printer"
"Videos"
".gnupg"
".ssh"
".github"
".mozilla"
".zsh_history"
".runelite"
".local/bin"
".local/share/nix"
".local/share/nvim"
".config/discord"
".config/BetterDiscord"
".config/PrusaSlicer"
".config/Yubico"
];
allowOther = true;
};
};
# Setup our window manager
xsession.windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
config = ../../pkgs/xmonad-config/src/xmonad.hs;
};
# Copy our personal font collection
home.file.".local/share/fonts" = {
recursive = true;
source = ../common/fonts;
};
# Copy some configuration files to $XDG_CONFIG_HOME
xdg.configFile = {
wezterm = { source = ./programs/wezterm/config; recursive = true; };
};
# Setup our desktop environment
home.file.".xinitrc".source = ./xinitrc;
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
home.stateVersion = "22.11";
}

View file

@ -1 +0,0 @@
sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIN6zrgWQj9NbuZEvqK3r2U9jSJjLotGb8asUkcr+co5sAAAABHNzaDo= sajenim@fuchsia

View file

@ -1,9 +0,0 @@
{ inputs, outputs, lib, config, pkgs, ... }:
{
programs.rofi = {
enable = true;
font = "Fira Code 10";
};
}

View file

@ -0,0 +1 @@
sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBAyOgJgJ1d3uNb/sRWp7cN2n6CoJ4zyvf8VklwdwmV8zx0uNipD/HxRKkCEpSR3Ids72i5uSBtEzjAtv9UR5r4IAAAALc3NoOnNhamVuaW0= sajenim@fuchsia

View file

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