small refactor of own modules

This commit is contained in:
catvayor 2024-09-26 11:51:04 +02:00
parent dc4d777962
commit 9bc1722517
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
16 changed files with 218 additions and 195 deletions

54
kat/default.nix Normal file
View file

@ -0,0 +1,54 @@
{
lib,
config,
pkgs,
...
}:
with lib;
{
imports = [
./users
./root.nix
];
options.kat = {
path = mkOption {
readOnly = true;
type = types.path;
};
anywhere = lib.mkOption {
type = lib.types.package;
readOnly = true;
};
};
config = {
kat = {
path = ./.;
anywhere = pkgs.writeShellApplication {
name = "anywhere-deploy_${name}.sh";
runtimeInputs = [ pkgs.nixos-anywhere ];
# --kexec ${nodes.kat-kexec.config.system.build.kexecTarball}/${nodes.kat-kexec.config.system.kexec-installer.name}-${pkgs.stdenv.hostPlatform.system}.tar.gz
text = ''
nixos-anywhere --store-paths ${config.system.build.diskoScriptNoDeps} ${config.system.build.toplevel} ${config.deployment.targetHost}
'';
};
};
boot.tmp.useTmpfs = true;
networking.nftables.enable = true;
nix = {
nixPath = [
"nixpkgs=${builtins.storePath pkgs.path}"
"nixos=${builtins.storePath pkgs.path}"
];
channel.enable = false;
settings.nix-path = config.nix.nixPath;
package = pkgs.lix;
};
services = {
resolved.enable = !config.boot.isContainer;
openssh.settings = {
ClientAliveInterval = 60;
ClientAliveCountMax = 1;
};
};
};
}

7
kat/root.nix Normal file
View file

@ -0,0 +1,7 @@
{ ... }:
{
users.users.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAA16foz+XzwKwyIR4wFgNIAE3Y7AfXyEsUZFVVz8Rie catvayor@katvayor"
];
home-manager.users.root = { };
}

17
kat/users/default.nix Normal file
View file

@ -0,0 +1,17 @@
{ config, lib, ... }:
with lib;
let
zsh = import ./zsh.nix;
in
{
imports = [ (import ./zsh.nix).system ];
home-manager.sharedModules = [{
imports = [ zsh.user ./neovim ];
# options.kat = {
# ssh = mkEnableOption "ssh configuration";
# };
config = {
home.stateVersion = config.system.stateVersion;
};
}];
}

View file

@ -0,0 +1,38 @@
{
pkgs,
config,
lib,
...
}:
with lib;
{
options.kat.neovim = mkEnableOption "neovim configuration" // {
default = true;
};
config = mkIf config.kat.neovim {
programs.neovim = {
enable = true;
defaultEditor = true;
plugins = with pkgs.vimPlugins; [
(nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars))
nvim-treesitter.withAllGrammars
vim-nix
telescope-nvim
todo-comments-nvim
gitsigns-nvim
];
extraPackages = with pkgs; [
git
ripgrep
fd
gcc
];
extraConfig = builtins.readFile ./nvimrc;
extraLuaConfig = builtins.readFile ./nvim.lua;
vimAlias = true;
viAlias = true;
};
};
}

20
kat/users/neovim/nvim.lua Normal file
View file

@ -0,0 +1,20 @@
local actions = require('telescope.actions')
require("telescope").setup {
pickers = {
buffers = {
show_all_buffers = true,
sort_lastused = true,
--theme = "dropdown",
--previewer = false,
mappings = {
i = {
["<c-d>"] = actions.delete_buffer,
},
n = {
["<c-d>"] = actions.delete_buffer,
}
}
}
}
}

167
kat/users/neovim/nvimrc Normal file
View file

@ -0,0 +1,167 @@
let &packpath = &runtimepath
filetype plugin indent on
syntax enable
" Use :help 'option' to see the documentation for the given option.
set autoindent
set backspace=indent,eol,start
set complete-=i
set smarttab
let g:mapleader=";"
set nrformats-=octal
set ttimeout
set ttimeoutlen=100
set incsearch
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
set laststatus=2
set ruler
set showcmd
set wildmenu
if !&scrolloff
set scrolloff=1
endif
if !&sidescrolloff
set sidescrolloff=5
endif
set display+=lastline
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment character when joining commented lines
endif
if has('path_extra')
setglobal tags-=./tags tags^=./tags;
endif
set autoread
if &history < 1000
set history=1000
endif
if &tabpagemax < 50
set tabpagemax=50
endif
if !empty(&viminfo)
set viminfo^=!
endif
set sessionoptions-=options
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux'
set t_Co=16
endif
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
inoremap <C-U> <C-G>u<C-U>
set mouse=a
vmap <LeftRelease> "*ygv
set tabstop=2
set shiftwidth=2
set expandtab
syntax enable
nnoremap ff <cmd>Telescope find_files<cr>
nnoremap fg <cmd>Telescope live_grep<cr>
nnoremap fb <cmd>Telescope buffers<cr>
" let g:coqtail_nomap = 1
"
" function Coqfun(count, cmd)
" if a:count == 0
" let l:count=1
" else
" let l:count=a:count
" endif
" execute a:cmd . l:count
" endfunction
"
" map <A-c> :CoqStart<CR>
" map <A-q> :CoqStop<CR>
" map <A-j> :<C-U>call Coqfun(v:count,"CoqNext")<CR>
" map <A-k> :<C-U>call Coqfun(v:count,"CoqUndo")<CR>
" map <A-l> :CoqToLine<CR>
" imap <A-j> <C-O>:call Coqfun(v:count,"CoqNext")<CR>
" imap <A-k> <C-O>:call Coqfun(v:count,"CoqUndo")<CR>
" imap <A-l> <C-O>:CoqToLine<CR>
"
" au BufRead,BufNewFile *.lus,*.ept setlocal filetype=lustre
""""""""""""""""""""""""""""""""" Colors
nnoremap <C-J> a<CR><Esc>k$
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "perso"
set cursorline
set number
set relativenumber
autocmd InsertEnter * set relativenumber!
autocmd InsertLeave * set relativenumber!
map <F2> :set number!<CR>
map <F3> :set relativenumber!<CR>
colorscheme vim
set notermguicolors
hi Normal guifg=cyan guibg=black
hi NonText guifg=yellow guibg=#303030
hi comment guifg=green
hi constant guifg=cyan gui=bold
hi identifier guifg=cyan gui=NONE
hi statement guifg=lightblue gui=NONE
hi preproc guifg=Pink2
hi type guifg=seagreen gui=bold
hi special guifg=yellow
hi ErrorMsg guifg=Black guibg=Red
hi WarningMsg guifg=Black guibg=Green
hi Error guibg=Red
hi Todo guifg=Black guibg=orange
hi Cursor guibg=#60a060 guifg=#00ff00
hi Search guibg=darkgray guifg=black gui=bold
hi IncSearch gui=NONE guibg=steelblue
hi LineNr guifg=darkgrey ctermbg=234 ctermfg=141
hi CursorLine cterm = NONE
hi CursorLineNR cterm=NONE ctermbg=black
hi title guifg=darkgrey
hi ShowMarksHL ctermfg=cyan ctermbg=lightblue cterm=bold guifg=yellow guibg=black gui=bold
hi StatusLineNC gui=NONE guifg=lightblue guibg=darkblue
hi StatusLine gui=bold guifg=cyan guibg=blue
hi label guifg=gold2
hi operator guifg=orange
hi clear Visual
hi Visual term=reverse cterm=reverse gui=reverse
hi DiffChange guibg=darkgreen
hi DiffText guibg=olivedrab
hi DiffAdd guibg=slateblue
hi DiffDelete guibg=coral
hi Folded guibg=gray30
hi FoldColumn guibg=gray30 guifg=white
hi cIf0 guifg=gray
hi diffOnly guifg=red gui=bold

91
kat/users/zsh.nix Normal file
View file

@ -0,0 +1,91 @@
{
system =
{
config,
pkgs,
lib,
...
}:
with lib;
mkMerge [
{
users.users = mapAttrs (
_: val:
mkIf val.kat.zsh {
shell = pkgs.zsh;
}
) config.home-manager.users;
}
(mkIf (any (val: val.kat.zsh) (attrValues config.home-manager.users)) {
programs.zsh.enable = true;
})
];
user =
{
config,
pkgs,
lib,
...
}:
with lib;
{
options.kat.zsh = mkEnableOption "zsh configuration" // {
default = true;
};
config = mkIf config.kat.zsh {
programs = {
zsh = {
enable = true;
oh-my-zsh = {
enable = true;
plugins = [ "git" ];
};
plugins = [
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.8.0";
sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7";
};
}
{
name = "zsh-autosuggestion";
file = "zsh-autosuggestions.zsh";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-autosuggestions";
rev = "v0.7.0";
sha256 = "1g3pij5qn2j7v7jjac2a63lxd97mcsgw6xq6k5p7835q9fjiid98";
};
}
{
name = "zsh-syntax-highlighting";
file = "zsh-syntax-highlighting.zsh";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-syntax-highlighting";
rev = "0.8.0";
sha256 = "1yl8zdip1z9inp280sfa5byjbf2vqh2iazsycar987khjsi5d5w8";
};
}
];
};
starship = {
enable = true;
enableZshIntegration = true;
settings.battery.disabled = true;
};
direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true;
};
};
};
};
}