wip: modularize home-manager

This commit is contained in:
xinyangli 2023-12-17 13:59:09 +08:00
parent 8b735dd5da
commit ac9918c759
14 changed files with 200 additions and 119 deletions

View file

@ -63,6 +63,7 @@
home-manager.users.xin = import ./home/${user}/${host};
home-manager.extraSpecialArgs = { inherit inputs system; };
}
self.homeManagerModules
];
};
mkNixos = { system, modules, specialArgs ? {}}: nixpkgs.lib.nixosSystem {

View file

@ -34,4 +34,11 @@
thunderbird
remmina
];
# custom-hm = {
# fish = { enable = true; };
# git = { enable = true; };
# neovim = { enable = true; };
# zellij = { enable = true; };
# };
}

View file

@ -1,10 +1,5 @@
{ pkgs, ... }: {
imports = [
./fish.nix
./git.nix
./zellij.nix
./vim.nix
];
{ inputs, pkgs, ... }: {
imports = [ ];
home.packages = with pkgs; [
dig

View file

@ -1,37 +0,0 @@
{ pkgs, ... }: {
programs.fish = {
enable = true;
plugins = with pkgs; [
{
name = "pisces";
src = fishPlugins.pisces.src;
}
{
name = "done";
src = fishPlugins.done.src;
}
{
name = "hydro";
src = fishPlugins.hydro.src;
}
];
interactiveShellInit = ''
fish_config theme choose 'ayu Dark'
fish_config prompt choose arrow
${pkgs.nix-your-shell}/bin/nix-your-shell fish | source
function fish_right_prompt
if test -n "$IN_NIX_SHELL"
echo -n "<nix-shell>"
else if test $SHLVL -ge 3
echo -n "<🚀lv$SHLVL>"
end
end
function fish_command_not_found
${pkgs.comma}/bin/comma $argv
end
'';
functions = {
gitignore = "curl -sL https://www.gitignore.io/api/$argv";
};
};
}

View file

@ -1,13 +0,0 @@
{
programs.git = {
enable = true;
delta.enable = true;
userName = "Xinyang Li";
userEmail = "lixinyang411@gmail.com";
aliases = {
graph = "log --all --oneline --graph --decorate";
s = "status";
d = "diff";
};
};
}

View file

@ -1,32 +0,0 @@
{ pkgs, ... }: {
programs.neovim = {
enable = true;
vimAlias = true;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; [
nvim-treesitter.withAllGrammars
dracula-nvim
];
extraConfig = ''
set nocompatible
syntax on
set number
set relativenumber
set shortmess+=I
set laststatus=2
set ignorecase
set smartcase
set list
set listchars=tab:·
set tabstop=4
set shiftwidth=4
set expandtab
set mouse+=a
colorscheme dracula
'';
};
}

View file

@ -1,28 +0,0 @@
{
programs.zellij = {
enable = true;
settings = {
default_shell = "fish";
keybinds = {
unbind = [
"Ctrl p"
"Ctrl n"
];
};
theme = "dracula";
themes.dracula = {
fg = [ 248 248 242 ];
bg = [ 40 42 54 ];
black = [ 0 0 0 ];
red = [ 255 85 85 ];
green = [ 80 250 123 ];
yellow = [ 241 250 140 ];
blue = [ 98 114 164 ];
magenta = [ 255 121 198 ];
cyan = [ 139 233 253 ];
white = [ 255 255 255 ];
orange = [ 255 184 108 ];
};
};
};
}

View file

@ -189,7 +189,6 @@
gnomeExtensions.paperwm
gnomeExtensions.search-light
gnomeExtensions.tray-icons-reloaded
gnomeExtensions.gsconnect
gnome.gnome-tweaks
gthumb

View file

@ -1,3 +1,10 @@
{ config, pkgs, ... }:
{
imports = [
./fish.nix
./git.nix
./tmux.nix
./vim.nix
./zellij.nix
];
}

View file

@ -0,0 +1,72 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.custom-hm.fish;
in
{
options = {
enable = mkEnableOption "fish";
plugins = mkOption {
type = types.listOf types.str;
default = [ "pisces" "done" "hydro" ];
};
functions = {
enable = mkOption {
type = types.bool;
default = true;
};
};
alias = {
enable = mkOption {
type = types.bool;
default = true;
};
};
};
config = {
programs.fish = mkIf cfg.enable {
enable = true;
plugins = with pkgs; filter (
e: hasAttr e.name builtins.listToAttrs # { "xxx" = true; }
(map (p: { name = p; value = true; }) cfg.plugins) # { name = "xxx"; value = true; }
) [
{
name = "pisces";
src = fishPlugins.pisces.src;
}
{
name = "done";
src = fishPlugins.done.src;
}
{
name = "hydro";
src = fishPlugins.hydro.src;
}
];
interactiveShellInit = let
extraInit = if cfg.functions.enable then ''
${pkgs.nix-your-shell}/bin/nix-your-shell fish | source
function fish_right_prompt
if test -n "$IN_NIX_SHELL"
echo -n "<nix-shell>"
else if test $SHLVL -ge 3
echo -n "<🚀lv$SHLVL>"
end
end
function fish_command_not_found
${pkgs.comma}/bin/comma $argv
end
'' else "";
in ''
fish_config theme choose 'ayu Dark'
fish_config prompt choose arrow
'' + extraInit;
functions = mkIf cfg.functions.enable {
gitignore = "curl -sL https://www.gitignore.io/api/$argv";
};
};
};
}

View file

@ -0,0 +1,26 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.custom-hm.git;
in
{
options = {
enable = mkEnableOption "Enable git configuration";
};
config = {
programs.git = {
enable = true;
delta.enable = true;
userName = "Xinyang Li";
userEmail = "lixinyang411@gmail.com";
aliases = {
graph = "log --all --oneline --graph --decorate";
a = "add";
d = "diff";
s = "status";
};
};
};
}

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,43 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.custom-hm.neovim;
in
{
options = {
enable = mkEnableOption "neovim configurations";
};
config = mkIf cfg.enable {
programs.neovim = {
enable = true;
vimAlias = true;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; [
catppuccin-nvim
];
extraConfig = ''
set nocompatible
syntax on
set number
set relativenumber
set shortmess+=I
set laststatus=2
set ignorecase
set smartcase
set list
set listchars=tab:·
set tabstop=4
set shiftwidth=4
set expandtab
set mouse+=a
colorscheme catppuccin-macchiato
'';
};
};
}

View file

@ -0,0 +1,40 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.custom-hm.zellij;
in
{
options = {
enable = mkEnableOption "zellij configurations";
};
config = {
programs.zellij = mkIf cfg.enable {
enable = true;
settings = {
default_shell = "fish";
keybinds = {
unbind = [
"Ctrl p"
"Ctrl n"
];
};
theme = "catppuccin-macchiato";
themes.dracula = {
fg = [ 248 248 242 ];
bg = [ 40 42 54 ];
black = [ 0 0 0 ];
red = [ 255 85 85 ];
green = [ 80 250 123 ];
yellow = [ 241 250 140 ];
blue = [ 98 114 164 ];
magenta = [ 255 121 198 ];
cyan = [ 139 233 253 ];
white = [ 255 255 255 ];
orange = [ 255 184 108 ];
};
};
};
};
}