This commit is contained in:
mrsu 2024-06-06 18:11:36 +01:00
commit 08e3aeeb38
41 changed files with 1125 additions and 756 deletions

View File

@ -5,6 +5,9 @@
# Nixpkgs
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# Import personal packages repo
sqlfmt.url = "git+https://git.bitlab21.com/sam/flake-packages?dir=sqlfmt";
# Home manager
home-manager = {
url = "github:nix-community/home-manager";
@ -20,6 +23,9 @@
inputs.nixpkgs.follows = "nixpkgs";
};
# Nix colors
nix-colors.url = "github:misterio77/nix-colors";
# Declarative partitioning and formatting
disko = {
url = "github:nix-community/disko";
@ -46,8 +52,6 @@
self,
nixpkgs,
home-manager,
disko,
#impermanence,
...
} @ inputs:
let

View File

@ -1,12 +1,12 @@
{ config, lib, pkgs, outputs, ... }:
{ pkgs, inputs, ... }:
{
imports = [
inputs.nix-colors.homeManagerModules.default
./zsh.nix
./nixvim.nix
./nixvim
./fonts.nix
];
# Global home packages without config go here (for all hosts and users)
home.packages = builtins.attrValues {
inherit (pkgs)
@ -17,6 +17,10 @@
tree
jq
coreutils
;};
btop
htop
postgresql
;
};
home.stateVersion = "23.11";
}

View File

@ -1,356 +0,0 @@
{ inputs, pkgs, ... }: {
imports = [
inputs.nixvim.homeManagerModules.nixvim
];
programs.nixvim = {
enable = true;
enableMan = true; # install man pages for nixvim options
clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers
colorschemes.kanagawa = {
enable = true;
settings = {
commentStyle = {
italic = true;
};
dimInactive = true;
terminalColors = true;
theme = "wave";
transparent = false;
undercurl = true;
};
};
opts = {
#
# ========= General Appearance =========
#
background = "";
number = true; # show line numbers
relativenumber = true; # show relative linenumbers
laststatus = 0; # Display status line always
history = 1000; # Store lots of :cmdline history
showcmd = true; # Show incomplete cmds down the bottom
showmode = true; # Show current mode down the bottom
autoread = true; # Reload files changed outside vim
lazyredraw = true; # Redraw only when needed
showmatch = true; # highlight matching braces
ruler = true; # show current line and column
visualbell = true; # No sounds
listchars = "trail:·"; # Display tabs and trailing spaces visually
# ========= Font =========
guifont = "NotoSansMono:h9"; # fontname:fontsize
# ========= Cursor =========
guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20,n-v-i:blinkon0";
# ========= Redirect Temp Files =========
# backup
backupdir = "$HOME/.local/state/vim/backup//,/tmp//,.";
writebackup = false;
# swap
directory = "$HOME/.local/vim/swap//,/tmp//,.";
# ================ Indentation ======================
autoindent = true;
cindent = true; # automatically indent braces
smartindent = true;
smarttab = true;
shiftwidth = 2;
softtabstop = 4;
tabstop = 2;
expandtab = true;
# ================ Folds ============================
foldmethod = "indent"; # fold based on indent
foldnestmax = 3; # deepest fold is 3 levels
foldenable = false; # don't fold by default
# ================ Completion =======================
wildmode = "list:longest";
wildmenu = true; # enable ctrl-n and ctrl-p to scroll thru matches
# stuff to ignore when tab completing
wildignore = "*.o,*.obj,*~,vim/backups,sass-cache,DS_Store,vendor/rails/**,vendor/cache/**,*.gem,log/**,tmp/**,*.png,*.jpg,*.gif";
# ================ Scrolling ========================
scrolloff = 4; # Start scrolling when we're 4 lines away from margins
sidescrolloff = 15;
sidescroll = 1;
# ================ Searching ========================
incsearch = true;
hlsearch = true;
ignorecase = true;
smartcase = true;
# ================ Movement ========================
backspace = "indent,eol,start"; # allow backspace in insert mode
};
#
# ========= UI Plugins =========
#
plugins.nvim-colorizer = {
enable = true;
fileTypes = [ "*" ];
};
plugins.lualine = {
enable = true;
theme = "auto";
componentSeparators = {
left = "";
right = "";
};
sectionSeparators = {
left = "";
right = "";
};
sections = {
lualine_a = [ "mode" ];
lualine_b = [ "branch" "diff" "diagnostics" ];
lualine_c = [ "filename" ];
lualine_x = [ "encoding" "fileformat" "filetype" ];
lualine_y = [ "progress" ];
lualine_z = [ "locations" ];
};
};
#
# ========= File Search =========
#
plugins.telescope = {
# https://github.com/nvim-telescope/telescope.nvim
enable = true;
extensions.fzy-native.enable = true;
};
# ========= File Nav ===========
#
plugins.harpoon = {
enable = true;
keymaps = {
toggleQuickMenu = "<leader>b";
};
};
plugins.nvim-tree = {
enable = true;
view.width = {
min = 30;
max = -1;
padding = 1;
};
disableNetrw = true;
filters.dotfiles = true;
};
#
# ========== Dev Tools =========
#
plugins.surround.enable = true; # vim-surround
plugins.gitsigns = {
enable = true;
settings.signs.add = {
hl = "GitSignsAdd";
text = " ";
numhl = "GitSignsAddNr";
linehl = "GitSignsAddLn";
};
settings.signs.change = {
hl = "GitSignsChange";
text = " ";
numhl = "GitSignsChangeNr";
linehl = "GitSignsChangeLn";
};
settings.signs.delete = {
hl = "GitSignsDelete";
text = " ";
numhl = "GitSignsDeleteNr";
linehl = "GitSignsDeleteLn";
};
settings.signs.topdelete = {
hl = "GitSignsDelete";
text = " ";
numhl = "GitSignsDeleteNr";
linehl = "GitSignsDeleteLn";
};
settings.signs.changedelete = {
hl = "GitSignsChange";
text = " ";
numhl = "GitSignsChangeNr";
linehl = "GitSignsChangeLn";
};
};
# Load Plugins that aren't provided as modules by nixvim
extraPlugins = builtins.attrValues {
inherit (pkgs.vimPlugins)
ale
vim-numbertoggle# Use relative number on focused buffer only
vimade# Dim unfocused buffers
vimwiki# Vim Wiki
YouCompleteMe# Code completion engine
vim-dadbod
vim-dadbod-ui
# Keep vim-devicons as last entry
vim-devicons;
};
# ========= Mapleader =========
globals.mapleader = ";";
#
# ========= Key binds =========
#
keymaps = [
# Switching windows
{
mode = [ "n" ];
action = "<C-W>h";
key = "<S-h>";
options = {
silent = true;
};
}
{
mode = [ "n" ];
action = "<C-W>j";
key = "<S-j>";
options = {
silent = true;
};
}
{
mode = [ "n" ];
action = "<C-W>k";
key = "<S-k>";
options = {
silent = true;
};
}
{
mode = [ "n" ];
action = "<C-W>l";
key = "<S-l>";
options = {
silent = true;
};
}
# Toggle nvim-tree
{
mode = [ "n" ];
action = "<cmd>NvimTreeFindFileToggle<CR>";
key = "tt";
options = {
silent = true;
};
}
{
# clear search highlighting
mode = [ "n" ];
key = "<space><space>";
action = "<cmd>nohlsearch<CR>";
options = { noremap = true; };
}
# ========== Telescope Plugin =========
{
# find files
mode = [ "n" ];
key = "<Leader>ff";
action = "<cmd>Telescope find_files<CR>";
options = { noremap = true; };
}
{
# live grep
mode = [ "n" ];
key = "<Leader>fg";
action = "<cmd>Telescope live_grep<CR>";
options = { noremap = true; };
}
{
# buffers
mode = [ "n" ];
key = "<Leader>fb";
action = "<cmd>Telescope buffers<CR>";
options = { noremap = true; };
}
{
# help tags
mode = [ "n" ];
key = "<Leader>fh";
action = "<cmd>Telescope help_tags<CR>";
options = { noremap = true; };
}
];
extraConfigVim = ''
" ================ Persistent Undo ==================
" Keep undo history across sessions, by storing in file.
" Only works all the time.
if has('persistent_undo')
silent !mkdir ~/.vim/backups > /dev/null 2>&1
set undodir=~/.vim/backups
set undofile
endif
" ================ Vim Wiki config =================
" See :h vimwiki_list for info on registering wiki paths
let wiki_0 = {}
let wiki_0.path = '~/dotfiles.wiki/'
let wiki_0.index = 'home'
let wiki_0.syntax = 'markdown'
let wiki_0.ext = '.md'
" fill spaces in page names with _ in pathing
let wiki_0.links_space_char = '_'
" ================ Ale ========================
" linter and fixer packages have to be installed via AUR or pamac
let g:ale_linters = {
\ 'c': ['clang-tidy'],
\ 'python': ['flake8'],
\ 'vim': ['vint'],
\ 'markdown': ['markdownlint'],
\ }
let g:ale_fixers = {
\ 'c': ['clang-format'],
\ 'javascript': ['prettier', 'eslint'],
\ 'json': ['fixjson', 'prettier'],
\ 'python': ['black', 'isort'],
\ }
" Set global fixers for all file types except Markdown
" Why? because double spaces at the end of a line in markdown indicate a
" linebreak without creating a new paragraph
function! SetGlobalFixers()
let g:ale_fixers['*'] = ['trim_whitespace', 'remove_trailing_lines']
endfunction
augroup GlobalFixers
autocmd!
autocmd VimEnter * call SetGlobalFixers()
augroup END
" Set buffer-local fixers for Markdown files
augroup MarkdownFixers
autocmd!
autocmd FileType markdown let b:ale_fixers = ['prettier']
augroup END
let g:ale_fix_on_save = 1
'';
};
}

View File

@ -0,0 +1,44 @@
{ inputs, pkgs, ... }: {
imports = [
inputs.nixvim.homeManagerModules.nixvim
./plugins
./options.nix
./theme.nix
./keymaps.nix
];
# Install home packages needed for nixvim
home.packages = builtins.attrValues {
inherit (pkgs)
nixpkgs-fmt
prettierd
;
};
programs.nixvim = {
enable = true;
enableMan = true; # install man pages for nixvim options
clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers
globals.mapleader = ";";
extraConfigVim = ''
" ================ Persistent Undo ==================
" Keep undo history across sessions, by storing in file.
" Only works all the time.
if has('persistent_undo')
silent !mkdir ~/.vim/backups > /dev/null 2>&1
set undodir=~/.vim/backups
set undofile
endif
" ================ Vim Wiki config =================
" See :h vimwiki_list for info on registering wiki paths
let wiki_0 = {}
let wiki_0.path = '~/docs/wiki/'
let wiki_0.index = 'home'
let wiki_0.syntax = 'markdown'
let wiki_0.ext = '.md'
'';
};
}

View File

@ -0,0 +1,85 @@
{
programs.nixvim.keymaps = [
# Switching buffers
{
mode = [ "n" ];
action = "<C-W>h";
key = "<S-h>";
options = {
silent = true;
};
}
{
mode = [ "n" ];
action = "<C-W>j";
key = "<S-j>";
options = {
silent = true;
};
}
{
mode = [ "n" ];
action = "<C-W>k";
key = "<S-k>";
options = {
silent = true;
};
}
{
mode = [ "n" ];
action = "<C-W>l";
key = "<S-l>";
options = {
silent = true;
};
}
# Toggle nvim-tree
{
mode = [ "n" ];
action = "<cmd>NvimTreeFindFileToggle<CR>";
key = "tt";
options = {
silent = true;
};
}
# Clear search highlighting
{
mode = [ "n" ];
key = "<space><space>";
action = "<cmd>nohlsearch<CR>";
options = { noremap = true; };
}
# Telescope Plugin
{
# find files
mode = [ "n" ];
key = "<Leader>ff";
action = "<cmd>Telescope find_files<CR>";
options = { noremap = true; };
}
{
# live grep
mode = [ "n" ];
key = "<Leader>fg";
action = "<cmd>Telescope live_grep<CR>";
options = { noremap = true; };
}
{
# buffers
mode = [ "n" ];
key = "<Leader>fb";
action = "<cmd>Telescope buffers<CR>";
options = { noremap = true; };
}
{
# help tags
mode = [ "n" ];
key = "<Leader>fh";
action = "<cmd>Telescope help_tags<CR>";
options = { noremap = true; };
}
];
}

View File

@ -0,0 +1,35 @@
{
programs.nixvim.opts = {
background = "";
number = true; # show line numbers
relativenumber = true; # show relative linenumbers
laststatus = 0; # Display status line always
history = 1000; # Store lots of :cmdline history
showcmd = true; # Show incomplete cmds down the bottom
showmode = true; # Show current mode down the bottom
autoread = true; # Reload files changed outside vim
lazyredraw = true; # Redraw only when needed
showmatch = true; # highlight matching braces
ruler = true; # show current line and column
visualbell = true; # No sounds
listchars = "trail:·"; # Display tabs and trailing spaces visually
autoindent = true;
cindent = true; # automatically indent braces
smartindent = true;
smarttab = true;
shiftwidth = 2;
softtabstop = 4;
tabstop = 2;
expandtab = true;
wildmode = "list:longest";
wildmenu = true; # enable ctrl-n and ctrl-p to scroll thru matches
scrolloff = 4; # Start scrolling when we're 4 lines away from margins
sidescrolloff = 15;
sidescroll = 1;
incsearch = true;
hlsearch = true;
ignorecase = true;
smartcase = true;
backspace = "indent,eol,start"; # allow backspace in insert mode
};
}

View File

@ -0,0 +1,119 @@
{
programs.nixvim.plugins = {
cmp-emoji = { enable = true; };
cmp = {
enable = true;
settings = {
autoEnableSources = true;
experimental = { ghost_text = true; };
performance = {
debounce = 60;
fetchingTimeout = 200;
maxViewEntries = 30;
};
snippet = { expand = "luasnip"; };
formatting = {
fields = [ "kind" "abbr" "menu" ];
format = ''
function(entry, vim_item)
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
vim_item.menu = ({
nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
["vim-dadbod-completion"] = "[SQL-dadbod]"
})[entry.source.name]
return vim_item
end,
'';
};
sources = [
{ name = "nvim_lsp"; }
{ name = "nvim_lua"; }
{ name = "luasnip"; }
{ name = "buffer"; }
{ name = "path"; }
{ name = "vim-dadbod-completion"; }
];
window = {
completion = { border = "solid"; };
documentation = { border = "solid"; };
};
mapping = {
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<C-j>" = "cmp.mapping.select_next_item()";
"<C-k>" = "cmp.mapping.select_prev_item()";
"<C-e>" = "cmp.mapping.abort()";
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
};
};
};
cmp-nvim-lsp = { enable = true; }; # lsp
cmp-buffer = { enable = true; };
cmp-path = { enable = true; }; # file system paths
cmp_luasnip = { enable = true; }; # snippets
cmp-cmdline = { enable = false; }; # autocomplete for cmdline
};
programs.nixvim.extraConfigLua = ''
luasnip = require("luasnip")
kind_icons = {
Text = "󰊄",
Method = "",
Function = "󰡱",
Constructor = "",
Field = "",
Variable = "󱀍",
Class = "",
Interface = "",
Module = "󰕳",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
local cmp = require'cmp'
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({'/', "?" }, {
sources = {
{ name = 'buffer' }
}
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}),
}) '';
}

View File

@ -0,0 +1,6 @@
{
programs.nixvim.plugins.nvim-colorizer = {
enable = true;
fileTypes = [ "*" ];
};
}

View File

@ -0,0 +1,21 @@
{
programs.nixvim.plugins.conform-nvim = {
enable = true;
formatOnSave = {
lspFallback = true;
timeoutMs = 500;
};
notifyOnError = true;
formattersByFt = {
html = [["prettierd" "prettier"]];
css = [["prettierd" "prettier"]];
javascript = [["prettierd" "prettier"]];
python = ["black"];
lua = ["stylua"];
nix = ["alejandra"];
markdown = [["prettierd" "prettier"]];
yaml = ["yamllint" "yamlfmt"];
sql = ["sqlfmt"];
};
};
}

View File

@ -0,0 +1,85 @@
{ pkgs, ... }:
{
imports = [
./cmp.nix
./colorizer.nix
./conform.nix
./gitsigns.nix
./harpoon.nix
./lsp.nix
./lualine.nix
./luasnip.nix
./nvim-tree.nix
./surround.nix
./telescope.nix
./treesitter.nix
];
# Load Plugins that aren't provided as modules by nixvim
programs.nixvim.extraPlugins = [
pkgs.vimPlugins.vim-numbertoggle
pkgs.vimPlugins.vimwiki
pkgs.vimPlugins.vim-dadbod
pkgs.vimPlugins.vim-dadbod-ui
pkgs.vimPlugins.vim-dadbod-completion
# Keep vim-devicons as last entry
pkgs.vimPlugins.vim-devicons
(pkgs.vimUtils.buildVimPlugin
{
name = "buffer_manager.nvim";
src = pkgs.fetchFromGitHub {
owner = "j-morano";
repo = "buffer_manager.nvim";
rev = "fd36131";
sha256 = "sha256-abe9ZGmL7U9rC+LxC3LO5/bOn8lHke1FCKO0V3TZGs0=";
};
})
];
programs.nixvim.extraConfigLua = ''
-- buffer_manager.nvim
local opts = {noremap = true}
require("buffer_manager").setup(
{
line_keys = "1234567890",
select_menu_item_commands = {
edit = {
key = "<CR>",
command = "edit"
}
},
focus_alternate_buffer = true,
short_file_names = false,
short_term_names = true,
height = 15,
width = 0.8,
loop_nav = true,
highlight = "",
win_extra_options = {},
borderchars = { "", "", "", "", "", "", "", "" },
order_buffers = "lastused",
show_indicators = "before",
}
)
-- Custom color for modified buffers
vim.api.nvim_set_hl(0, "BufferManagerModified", { fg = "#988100" })
local bmui = require("buffer_manager.ui")
vim.keymap.set('n', '<leader>b', bmui.toggle_quick_menu, opts)
vim.keymap.set('n', '<leader>n', bmui.nav_next, opts)
vim.keymap.set('n', '<leader>p', bmui.nav_prev, opts)
local keys="1234567890"
for i = 1, #keys do
local key = keys:sub(i,i)
vim.keymap.set('n', string.format('<leader>%s', key),
function () bmui.nav_file(i) end,
opts
)
end
'';
}

View File

@ -0,0 +1,35 @@
{
programs.nixvim.plugins.gitsigns = {
enable = true;
settings.signs.add = {
hl = "GitSignsAdd";
text = " ";
numhl = "GitSignsAddNr";
linehl = "GitSignsAddLn";
};
settings.signs.change = {
hl = "GitSignsChange";
text = " ";
numhl = "GitSignsChangeNr";
linehl = "GitSignsChangeLn";
};
settings.signs.delete = {
hl = "GitSignsDelete";
text = " ";
numhl = "GitSignsDeleteNr";
linehl = "GitSignsDeleteLn";
};
settings.signs.topdelete = {
hl = "GitSignsDelete";
text = " ";
numhl = "GitSignsDeleteNr";
linehl = "GitSignsDeleteLn";
};
settings.signs.changedelete = {
hl = "GitSignsChange";
text = " ";
numhl = "GitSignsChangeNr";
linehl = "GitSignsChangeLn";
};
};
}

View File

@ -0,0 +1,8 @@
{
programs.nixvim.plugins.harpoon = {
enable = true;
keymaps = {
toggleQuickMenu = "<leader>h";
};
};
}

View File

@ -0,0 +1,51 @@
{
programs.nixvim.plugins.lsp = {
enable = true;
servers = {
lua-ls = {enable = true;};
nixd = {enable = true;};
bashls = {enable = true;};
pyright = {enable = true;};
html = {enable = true;};
yamlls = {enable = true;};
marksman = {enable = true;};
#sqls = {enable = true;};
};
keymaps = {
lspBuf = {
gd = {
action = "definition";
desc = "Goto Definition";
};
gr = {
action = "references";
desc = "Goto References";
};
gD = {
action = "declaration";
desc = "Goto Declaration";
};
gI = {
action = "implementation";
desc = "Goto Implementation";
};
gT = {
action = "type_definition";
desc = "Type Definition";
};
K = {
action = "hover";
desc = "Hover";
};
"<leader>cw" = {
action = "workspace_symbol";
desc = "Workspace Symbol";
};
"<leader>cr" = {
action = "rename";
desc = "Rename";
};
};
};
};
}

View File

@ -0,0 +1,13 @@
{
# Add tiny pictograms to lsp
programs.nixvim.plugins.lspkind = {
enable = true;
symbolMap = {
Copilot = "";
};
extraOptions = {
maxwidth = 50;
ellipsis_char = "...";
};
};
}

View File

@ -0,0 +1,22 @@
{
programs.nixvim.plugins.lualine = {
enable = true;
theme = "auto";
componentSeparators = {
left = "";
right = "";
};
sectionSeparators = {
left = "";
right = "";
};
sections = {
lualine_a = [ "mode" ];
lualine_b = [ "branch" "diff" "diagnostics" ];
lualine_c = [ "filename" ];
lualine_x = [ "encoding" "fileformat" "filetype" ];
lualine_y = [ "progress" ];
lualine_z = [ "locations" ];
};
};
}

View File

@ -0,0 +1,15 @@
{ pkgs, ... }: {
programs.nixvim.plugins.luasnip = {
enable = true;
extraConfig = {
enable_autosnippets = true;
store_selection_keys = "<Tab>";
};
fromVscode = [
{
lazyLoad = true;
paths = "${pkgs.vimPlugins.friendly-snippets}";
}
];
};
}

View File

@ -0,0 +1,12 @@
{
programs.nixvim.plugins.nvim-tree = {
enable = true;
view.width = {
min = 30;
max = -1;
padding = 1;
};
disableNetrw = true;
filters.dotfiles = true;
};
}

View File

@ -0,0 +1,3 @@
{
programs.nixvim.plugins.surround.enable = true; # vim-surround
}

View File

@ -0,0 +1,6 @@
{
programs.nixvim.plugins.telescope = {
enable = true;
extensions.fzy-native.enable = true;
};
}

View File

@ -0,0 +1,5 @@
{
programs.nixvim.plugins.treesitter = {
enable = true;
};
}

View File

@ -0,0 +1,15 @@
{
programs.nixvim.colorschemes.kanagawa = {
enable = true;
settings = {
commentStyle = {
italic = true;
};
dimInactive = true;
terminalColors = true;
theme = "wave";
transparent = true;
undercurl = true;
};
};
}

View File

@ -82,6 +82,23 @@
HISTSIZE=10000000
SAVEHIST=10000000
setopt appendhistory
# Change cursor shape for different vi modes.
function zle-keymap-select () {
case $KEYMAP in
vicmd) echo -ne '\e[1 q';; # block
viins|main) echo -ne '\e[5 q';; # beam
esac
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
'';
};
}

View File

@ -0,0 +1,51 @@
{ config, pkgs, ... }:
{
programs.alacritty = {
enable = true;
settings = {
colors = with config.colorScheme.palette; {
bright = {
black = "0x${base03}";
blue = "0x${base04}";
cyan = "0x${base0F}";
green = "0x${base01}";
magenta = "0x${base06}";
red = "0x${base09}";
white = "0x${base07}";
yellow = "0x${base02}";
};
cursor = {
cursor = "0x${base05}";
text = "0x${base00}";
};
normal = {
black = "0x${base00}";
blue = "0x${base0D}";
cyan = "0x${base0C}";
green = "0x${base0B}";
magenta = "0x${base0E}";
red = "0x${base08}";
white = "0x${base05}";
yellow = "0x${base0A}";
};
primary = {
background = "0x${base00}";
foreground = "0x${base05}";
};
};
window = {
padding = {
x = 5;
y = 5;
};
blur = true;
opacity = 0.9;
};
shell.program = "${pkgs.zsh}/bin/zsh";
};
};
}

View File

@ -1,12 +1,16 @@
{ pkgs, ... }: {
imports = [
./firefox.nix
./alacritty.nix
];
# Global packages for desktop environments
home.packages = [
pkgs.kitty
pkgs.alacritty
pkgs.libnotify
pkgs.zathura
pkgs.xfce.thunar
pkgs.wofi
pkgs.kcolorchooser
pkgs.zotero
];
}

View File

@ -1,14 +1,12 @@
{
lib,
config,
pkgs,
...
{ lib
, config
, pkgs
, ...
}: {
imports = [
../wallpaper-changer/swww-wallpaper-changer
../common
../waybar.nix
../wayland
];
wayland.windowManager.hyprland = {
enable = true;
@ -21,9 +19,13 @@
"systemctl --user start hyprland-session.target"
];
};
extraConfig = let
extraConfig =
let
monitor = "${toString (builtins.map (m: "monitor=${ m.name },${ toString( m.width ) }x${ toString( m.height ) }@${ toString( m.refreshRate ) },${ toString( m.x ) }x${ toString( m.y ) },${ toString( m.scale ) }\n") config.monitors)}";
in ''
active = "rgba(${config.colorScheme.colors.base08}ee)";
inactive = "rgba(${config.colorScheme.colors.base0C}ee)";
in
''
${monitor}
$terminal = alacritty
@ -36,11 +38,10 @@
kb_layout = gb
kb_variant =
kb_model =
kb_options = caps:swapescape
kb_rules =
repeat_delay = 280
repeat_rate = 60
follow_mouse = 1
touchpad {
natural_scroll = no
}
@ -49,20 +50,18 @@
general {
gaps_in = 5
gaps_out = 20
gaps_in = 10
gaps_out = 10
border_size = 2
col.active_border = #22ff00
col.inactive_border = #aecbb4
col.active_border = ${active}
col.inactive_border = ${inactive}
layout = dwindle
allow_tearing = false
}
decoration {
rounding = 10
rounding = 5
blur {
enabled = true
@ -113,18 +112,17 @@
$mainMod = SUPER
bind = $mainMod, Q, exec, $terminal
bind = $mainMod, C, killactive,
bind = $mainMod, RETURN, exec, $terminal
bind = $mainMod, Q, killactive,
bind = $mainMod, M, exit,
bind = $mainMod, E, exec, $fileManager
bind = $mainMod, V, togglefloating,
bind = $mainMod, R, exec, $menu
bind = $mainMod, S, exec, rofi -show drun -show-icons
bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, movefocus, d
bind = $mainMod, h, movefocus, l
bind = $mainMod, l, movefocus, r
bind = $mainMod, k, movefocus, u
bind = $mainMod, j, movefocus, d
bind = $mainMod, 1, workspace, 1
bind = $mainMod, 2, workspace, 2
@ -157,7 +155,7 @@
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
exec-once=bash ~/.config/hypr/start.sh
exec-once=swww-wallpaper-changer
'';
};
}

View File

@ -1,36 +0,0 @@
{
pkgs,
...
}:
{
systemd.user.services.wallpaper-changer = {
Unit = {
Description = "Script to change wallpaper using swww";
PartOf = [ "hyprland-session.target" ];
After = [ "hyprland-session.target" ]; # or "wayland.target", depending on your system setup
};
Install = {
WantedBy = [ "default.target" ];
};
Service = {
Type = [ "oneshot" ];
ExecStart = "${pkgs.writeShellScript "swww-wallpaper-changer" ''
export WAYLAND_DISPLAY="wayland-1"
wallpaper_dir="$HOME/.local/share/bg/"
# Allow some time for desktop to start
sleep 3
echo "starting daemon..."
${pkgs.swww}/bin/swww-daemon &
while true; do
find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do
${pkgs.swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60
[ $? != 0 ] && echo "swww failed, reloading daemon" && ${pkgs.swww}/bin/swww-daemon &
sleep 600
done
done
''}";
};
};
}

View File

@ -1,220 +0,0 @@
{
lib,
config,
pkgs,
...
}: {
# Let it try to start a few more times
systemd.user.services.waybar = {
Unit.StartLimitBurst = 30;
};
programs.waybar = {
enable = true;
systemd.enable = true;
settings = {
primary = {
mode = "dock";
height = 30;
margin = "6";
spacing = 5;
modules-left = [
"custom/menu"
"wlr/workspaces"];
modules-center = [
"clock"
];
modules-right = [
"cpu"
"memory"
"network"
"pulseaudio"
"battery"
"tray"
"custom/exit"
"custom/hostname"
];
"wlr/workspaces" = {
"format" = "{icon}";
"on-click" = "activate";
"format-icons"= {
"1" = "";
"2" = "";
"3" = "";
"4" = "";
"5" = "";
"urgent" = "";
"active" = "";
"default" = "";
};
};
"clock" = {
"format" = "<span> </span>{:%m/%d %H:%M}";
"tooltip-format" = "<big>{:%B %Y}</big>\n<tt><small>{calendar}</small></tt>";
"on-click" = "calendar";
};
"cpu"= {
"interval" = 10;
"format" = " {}%";
"max-length" = 10;
"on-click" = "";
};
"memory" = {
"interval" = 30;
"format" = " {}%";
"format-alt" = " {used:0.1f}G";
"max-length" = 10;
};
"network" = {
"format-wifi" = " {signalStrength}%";
"format-ethernet" = " wired";
"format-disconnected" = "";
"on-click" = "bash ~/.config/waybar/scripts/rofi-wifi-menu.sh";
};
"battery" = {
"bat" = "BAT0";
"adapter" = "ADP0";
"interval" = 60;
"states" = {
"warning" = 30;
"critical" = 15;
};
"max-length" = 20;
"format" = "{icon} {capacity}%";
"format-warning" = "{icon} {capacity}%";
"format-critical" = "{icon} {capacity}%";
"format-charging" = "<span font-family='Font Awesome 6 Free'></span> {capacity}%";
"format-plugged" = " {capacity}%";
"format-alt" = "{icon} {time}";
"format-full" = " {capacity}%";
"format-icons" = [" " " " " " " " " "];
};
"tray" = {
"spacing" = 10;
};
"custom/menu" = {
"format" = "";
"on-click" = "rofi -show drun";
};
"custom/hostname" = {
"exec" = "echo $USER@$(hostname)";
"on-click" = "alacritty";
};
"custom/exit" = {
"format" = "";
"on-click" = "wlogout";
};
"pulseaudio" = {
"format" = "{icon} {volume}%";
"format-muted" = " 0%";
"format-icons" = {
"headphone" = "";
"headset" = "";
"portable" = "";
"default" = [ "" "" "" ];
};
"on-click" = "pavucontrol";
};
};
};
style = ''
* {
font-family: JetBrainsMono Nerd Font;
font-size: 12pt;
padding: 0 8px;
}
.modules-right {
margin-right: -15px;
}
.modules-left {
margin-left: -15px;
}
window#waybar {
color: white;
background-color: #002635;
opacity: 0.95;
padding: 0;
border-radius: 10px;
}
window#waybar.bottom {
opacity: 0.90;
background-color: #002635;
border: 2px solid #14747e;
border-radius: 10px;
}
#workspaces button {
padding: 0 5px;
color: #7984A4;
background-color: transparent;
box-shadow: inset 0 -3px transparent;
border: none;
border-radius: 0;
}
#workspaces button.hidden {
background-color: #002635;
color: #869696;
}
#workspaces button.focused {
color: #bf616a;
}
#workspaces button.active {
color: #6a92d7;
}
#workspaces button.urgent {
background-color: #eb4d4b;
}
#clock {
padding-left: 15px;
padding-right: 15px;
margin-top: 0;
margin-bottom: 0;
border-radius: 10px;
}
#tray {
color: #a1a19a;
}
#custom-hostname {
background-color: white;
color: #002635;
padding-left: 15px;
padding-right: 18px;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
border-radius: 10px;
}
#custom-menu {
font-size: 16pt;
background-color: white;
color: #002635;
padding-left: 15px;
padding-right: 22px;
margin-left: 0;
margin-right: 10px;
margin-top: 0;
margin-bottom: 0;
border-radius: 10px;
}
'';
};
}

View File

@ -0,0 +1,13 @@
{ pkgs, ... }:
{
imports = [
./mako.nix
./waybar.nix
./swww-wallpaper-changer.nix
];
home.packages = [
pkgs.wofi
pkgs.wl-clipboard
];
}

View File

@ -0,0 +1,12 @@
{ pkgs, config, ... }:
{
services.mako = {
enable = true;
backgroundColor = "#${config.colorScheme.colors.base00}";
borderColor = "#${config.colorScheme.colors.base0D}";
borderRadius = 5;
borderSize = 2;
textColor = "#${config.colorScheme.colors.base05}";
layer = "overlay";
};
}

View File

@ -0,0 +1,19 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
(writeShellScriptBin "swww-wallpaper-changer" ''
export WAYLAND_DISPLAY="wayland-1"
wallpaper_dir="$HOME/.local/share/bg/"
[ -d "$wallpaper_dir" ] || mkdir -p "$wallpaper_dir"
${swww}/bin/swww-daemon &
while true; do
find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do
${swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60
[ $? != 0 ] && echo "swww failed, exiting" && exit 1
sleep 600
done
done
'')
];
}

View File

@ -0,0 +1,230 @@
{ lib
, config
, pkgs
, ...
}: {
# Let it try to start a few more times
systemd.user.services.waybar = {
Unit.StartLimitBurst = 30;
};
programs.waybar = {
enable = true;
systemd.enable = true;
settings = {
primary = {
mode = "dock";
height = 30;
margin = "6";
spacing = 5;
modules-left = [
"custom/menu"
"hyprland/workspaces"
"hyprland/window"
];
modules-center = [
"clock"
];
modules-right = [
"cpu"
"memory"
"network"
"pulseaudio"
"battery"
"tray"
"custom/exit"
"custom/hostname"
"custom/ip"
];
"hyprland/window" = {
"format" = "{}";
"rewrite" = {
"(.*) Mozilla Firefox" = "$1";
};
"separate-outputs" = true;
};
"hyprland/workspaces" = {
"format" = "{name}";
"on-click" = "activate";
"format-icons" = {
"urgent" = "";
"active" = "";
"default" = "";
};
};
"clock" = {
"format" = "<span> </span>{:%y-%m-%d %H:%M:%S}";
"tooltip-format" = "<big>{:%B %Y}</big>\n<tt><small>{calendar}</small></tt>";
"on-click" = "calendar";
};
"cpu" = {
"interval" = 10;
"format" = " {}%";
"max-length" = 10;
"on-click" = "";
};
"memory" = {
"interval" = 30;
"format" = " {}%";
"format-alt" = " {used:0.1f}G";
"max-length" = 10;
};
"network" = {
"format-wifi" = " {signalStrength}%";
"format-ethernet" = " wired ({ipaddr})";
"format-disconnected" = "";
};
"battery" = {
"bat" = "BAT0";
"adapter" = "ADP0";
"interval" = 60;
"states" = {
"warning" = 30;
"critical" = 15;
};
"max-length" = 20;
"format" = "{icon} {capacity}%";
"format-warning" = "{icon} {capacity}%";
"format-critical" = "{icon} {capacity}%";
"format-charging" = "<span font-family='Font Awesome 6 Free'></span> {capacity}%";
"format-plugged" = " {capacity}%";
"format-alt" = "{icon} {time}";
"format-full" = " {capacity}%";
"format-icons" = [ " " " " " " " " " " ];
};
"tray" = {
"spacing" = 10;
};
"custom/menu" = {
"format" = " Nixos";
"on-click" = "wofi --show drun";
};
"custom/hostname" = {
"exec" = "echo $USER@$(hostname)";
"on-click" = "$TERMINAL";
};
"custom/exit" = {
"format" = "";
"on-click" = "wlogout";
};
"pulseaudio" = {
"format" = "{icon} {volume}%";
"format-muted" = " 0%";
"format-icons" = {
"headphone" = "";
"headset" = "";
"portable" = "";
"default" = [ "" "" "" ];
};
"on-click" = "pavucontrol";
};
};
};
style = ''
* {
font-family: JetBrainsMono Nerd Font;
font-size: 12pt;
padding: 0 8px;
}
.modules-right {
margin-right: -15px;
}
.modules-left {
margin-left: -15px;
}
window#waybar {
color: white;
background-color: #002635;
opacity: 0.95;
padding: 0;
border-radius: 10px;
}
window#waybar.bottom {
opacity: 0.90;
background-color: #002635;
border: 2px solid #14747e;
border-radius: 10px;
}
#workspaces button {
padding: 0 5px;
color: #7984A4;
background-color: transparent;
box-shadow: inset 0 -3px transparent;
border: none;
border-radius: 0;
}
#workspaces button.hidden {
background-color: #002635;
color: #869696;
}
#workspaces button.focused {
color: #bf616a;
}
#workspaces button.active {
color: #6a92d7;
}
#workspaces button.urgent {
background-color: #eb4d4b;
}
#clock {
padding-left: 15px;
padding-right: 15px;
margin-top: 0;
margin-bottom: 0;
border-radius: 10px;
}
#tray {
color: #a1a19a;
}
#custom-hostname {
background-color: white;
color: #002635;
padding-left: 15px;
padding-right: 18px;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
border-radius: 10px;
}
#custom-menu {
font-size: 16pt;
background-color: white;
color: #002635;
padding-left: 15px;
padding-right: 22px;
margin-left: 0;
margin-right: 10px;
margin-top: 0;
margin-bottom: 0;
border-radius: 10px;
}
'';
};
}

View File

@ -1,10 +1,9 @@
{ inputs, config, osConfig, ... }:
{ inputs, config, ... }:
let
secretsDirectory = builtins.toString inputs.nix-secrets;
secretsFile = "${secretsDirectory}/secrets.yaml";
homeDirectory = config.home.homeDirectory;
username = config.home.username;
hostname = osConfig.networking.hostName;
in
{
imports = [
@ -12,11 +11,18 @@ in
];
sops = {
age.sshKeyPaths = ["${homeDirectory}/.ssh/id_ed25519"];
age = {
sshKeyPaths = [ "${homeDirectory}/.ssh/id_ed25519" ];
generateKey = true;
keyFile = "/home/${username}/.config/sops/age/keys.txt";
};
defaultSopsFile = "${secretsFile}";
validateSopsFiles = false;
secrets."ssh_keys/deploy_key/id_ed25519" = {
secrets = {
"ssh_keys/deploy_key/id_ed25519" = {
path = "/home/${username}/.ssh/deploy_key-ssh-ed25519";
};
};
};
}

View File

@ -1,8 +1,5 @@
{
pkgs,
config,
lib,
...
{ inputs
, ...
}: {
imports = [
# Import users
@ -18,27 +15,23 @@
];
home.packages = [
pkgs.alacritty
pkgs.zathura
pkgs.xfce.thunar
];
colorScheme = inputs.nix-colors.colorSchemes.kanagawa;
monitors = [
{
name = "Virtual-1";
width = 1920;
name = "DP-1";
width = 2560;
height = 1440;
refreshRate = 75;
refreshRate = 144;
x = 0;
primary = true;
}
{
name = "Virtual-2";
width = 1920;
name = "DP-2";
width = 2560;
height = 1440;
refreshRate = 75;
x = 1920;
x = 2560;
}
];
}

View File

@ -1,15 +1,11 @@
{
pkgs,
config,
lib,
...
{ inputs
, ...
}: {
imports = [
# Import users
./users/media
./common/core
./common/optional/sops.nix
# Import optional
./common/optional/git.nix
@ -17,4 +13,6 @@
./common/optional/desktop/cinnamon
];
colorScheme = inputs.nix-colors.colorSchemes.kanagawa;
}

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, outputs, ... }:
{ pkgs, outputs, ... }:
{
home.username = "sam";

View File

@ -1,17 +1,18 @@
{ pkgs, ... }:
{
sound.enable = true;
hardware.pulseaudio.enable = false;
hardware.pulseaudio.enable = true;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
hardware.pulseaudio.package = pkgs.pulseaudioFull;
# services.pipewire = {
# enable = true;
# alsa.enable = true;
# alsa.support32Bit = true;
pulse.enable = true;
wireplumber.enable = true;
jack.enable = true;
};
# pulse.enable = true;
# wireplumber.enable = true;
# jack.enable = true;
#
# };
environment.systemPackages = [
pkgs.pamixer

View File

@ -40,6 +40,7 @@ in
".local"
];
files = [
".config/cinnamon-monitors.xml"
];
};
};
@ -61,6 +62,20 @@ in
};
};
# The containing ssh folders are created as root and if this is the first ~/.ssh/ entry when writing keys,
# the ownership is busted and home-manager can't target because it can't write into .ssh...
# FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed
system.activationScripts.sopsSetSshOwnwership =
let
sshFolder = "/home/${username}/.ssh";
user = config.users.users.${username}.name;
group = config.users.users.${username}.group;
in
''
mkdir -p ${sshFolder} || true
chown -R ${user}:${group} /home/${username}/.ssh
'';
services.flatpak.enable = true;
programs.zsh.enable = true;

View File

@ -35,8 +35,48 @@ in
mode = "0644";
owner = "${username}";
};
"passwords/postgres" = { };
};
# Setup postgres connections for db_ui
# Should be part of home-manager - waiting for templates functionality
# See here https://github.com/Mic92/sops-nix/issues/423 and here https://github.com/Mic92/sops-nix/issues/498
# TODO migrate db_ui connection to home-manager when issue 423 and 498 are resolved in github:Mic92/sops-nix
sops.templates."dbui_connections.json" = {
path = "/home/${username}/.local/share/db_ui/connections.json";
owner = "${username}";
mode = "0600";
content = ''
[
{
"url": "postgresql://postgres:${config.sops.placeholder."passwords/postgres"}@10.0.10.100/btc_models",
"name": "btc_models"
}
]
'';
};
# The containing ssh folders are created as root and if this is the first ~/.ssh/ entry when writing keys,
# the ownership is busted and home-manager can't target because it can't write into .ssh...
# FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed
system.activationScripts.sopsSetSshOwnwership =
let
sshFolder = "/home/${username}/.ssh";
user = config.users.users.${username}.name;
group = config.users.users.${username}.group;
in
''
mkdir -p ${sshFolder} || true
chown -R ${user}:${group} /home/${username}/.ssh
'';
environment.persistence."/persist" = {
directories = [
"/home/${username}"
];
};
programs.zsh.enable = true;
home-manager = {
@ -47,5 +87,6 @@ in
};
environment.systemPackages = [
inputs.sqlfmt.packages.x86_64-linux.sqlfmt
];
}

View File

@ -35,6 +35,8 @@ in
];
boot = {
blacklistedKernelModules = [ "snd_hda_intel" "snd_soc_skl" ];
kernelPackages = pkgs.linuxPackagesFor pkgs.linux_latest;
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
@ -42,14 +44,9 @@ in
};
};
environment.persistence."/persist" = {
hideMounts = true;
users.${user} = {
directories = [
"/home/${user}"
hardware.firmware = [
pkgs.sof-firmware
];
};
};
networking = {
hostName = "semita";

View File

@ -2,5 +2,4 @@
# You can build them using 'nix build .#example'
pkgs: {
sddm-theme = pkgs.callPackage ./sddm-theme { };
wallpaper_changer = pkgs.callPackage ./wallpaper-changer { };
}

View File

@ -1,16 +1,15 @@
{ pkgs ? import <nixpkgs> { }, stdenv, fetchFromGitHub }:
pkgs.stdenv.mkDerivation rec {
{ pkgs ? import <nixpkgs> { }, fetchFromGitHub }:
pkgs.stdenv.mkDerivation {
pname = "sddm-theme";
version = "1.6";
dontBuild = true;
# nativeBuildInputs = with pkgs; [
# sddm
# ];
installPhase = ''
mkdir -p $out/share/sddm/themes
cp -aR $src $out/share/sddm/themes/sugar-candy
touch $out/share/sddm/themes/balls
'';
src = fetchFromGitHub {
owner = "Kangie";
repo = "sddm-sugar-candy";