Skip to content

Commit

Permalink
feat(nix): add some docs and refactor and tools
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamHsieh committed Jan 22, 2025
1 parent 2433eac commit b57b888
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
37 changes: 30 additions & 7 deletions home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ let

glow-without-completion = pkgs.glow.overrideAttrs
(oldAttrs: {
# glow with completion can't complete file path
# solution: remove the completion file
postFixup = ''
# Remove the completion file
rm $out/share/zsh/site-functions/_glow
'';
});

# NOTE: impure
# isWSL = lib.strings.hasInfix "Microsoft" (builtins.readFile /proc/version);
in
{
imports = [
Expand Down Expand Up @@ -110,6 +114,7 @@ in
glow-without-completion
csvlens
litecli
nix-tree

# misc
nix-search-cli
Expand All @@ -123,6 +128,8 @@ in

sessionVariables = rec {
COLORTERM = "truecolor";
# FIX: should i change both of these to C.UTF-8?
# feels like it's causing p10k to not display correctly
LANG = "en_US.UTF-8";
LC_CTYPE = "en_US.UTF-8";
EDITOR = "${pkgs.unstable.neovim}/bin/nvim";
Expand All @@ -134,6 +141,16 @@ in
# LIBRARY_PATH = "${pkgs.iconv}/lib";
LIBRARY_PATH = "${config.home.profileDirectory}/lib";
};

activation = {
updateNeovimPlugins = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
PATH="${config.home.path}/bin:$PATH" run --quiet nvim --headless "+Lazy! restore | qa"
'';

linkHomeManagerPath = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
ln -sfn ${config.home-files} ${config.home.homeDirectory}/.local/share/home-files
'';
};
};

xdg.enable = true;
Expand All @@ -146,12 +163,6 @@ in
"vim".source = link "vim";
};

home.activation = {
updateNeovimPlugins = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
PATH="${config.home.path}/bin:$PATH" run --quiet nvim --headless "+Lazy! restore | qa"
'';
};

programs.home-manager.enable = true;

programs.dircolors.enable = true;
Expand Down Expand Up @@ -214,5 +225,17 @@ in

catppuccin.glamour.enable = true;

# for fast-syntax-highlighting
programs.man.generateCaches = true;

systemd.user.startServices = "sd-switch";

services.pueue = {
enable = true;
settings = {
daemon = {
default_parallel_tasks = 1;
};
};
};
}
7 changes: 6 additions & 1 deletion home/git.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, config, dotfiles, ... }:
{ pkgs, dotfiles, ... }:
{
home.packages = with pkgs; [
glab
Expand All @@ -14,12 +14,17 @@
pushf = "push --force-with-lease";
review = /* bash */ ''!f() { nvim +"DiffviewFileHistory --range=''${1:-master}.."; }; f'';
};

# FIX: zsh completion still not working
# consider overwriting scss completion or prioritize user nix profile over root profile
delta = {
enable = true;
options = {
true-color = "always";
line-numbers = true;
diff-so-fancy = true;
# NOTE: toggle side-by-side view: `export DELTA_FEATURES="side-by-side"`
# ref: https://github.com/dandavison/delta/issues/359#issuecomment-751447333
};
};
ignores = [
Expand Down
8 changes: 7 additions & 1 deletion home/zsh.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ inputs, pkgs, config, lib, dotfiles, isSystemConfig, ... }:
{ pkgs, config, dotfiles, isSystemConfig, ... }:
let
dotDir = "${config.home.homeDirectory}/${dotfiles.home.dotDir}";
aliases = {
Expand All @@ -15,6 +15,7 @@ let
mv = "mv -i";
cp = "cp -i";
rm = "trash";
diff = "delta";

sudo = ''sudo -E env "PATH=$PATH" '';
pythonServer = "python3 -m http.server";
Expand Down Expand Up @@ -68,6 +69,7 @@ in
echo ""
${sourceIfExists "${instantPrompt}"}
# TODO: is this necessary? isn't the same thing already done in /etc/zshrc?
# source nix profile
${sourceIfExists "${nixProfile}"}
'';
Expand Down Expand Up @@ -113,11 +115,15 @@ in
'';
};

# TODO: fix abbr completion and man page
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/shells/zsh/zsh-abbr/default.nix
# https://github.com/olets/zsh-abbr
xdg.configFile = {
"zsh/abbreviations".text = /* bash */ ''
abbr "s"="sudo"
abbr "b"="bat"
abbr "n"="nvim"
abbr "p"="python3"
abbr "g"="git"
abbr "gf"="git forgit"
abbr -g "-h"="--help"
Expand Down
10 changes: 10 additions & 0 deletions nix/shell/venv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ pkgs.mkShell {
unset SOURCE_DATE_EPOCH
# pip install -r requirements.txt
'';

# NOTE: zsh-nix-shell is messing with env variable, run the following command for venv to behave properly
# source ${venvDir}/bin/activate
# https://github.com/chisui/zsh-nix-shell/issues/19
# NOTE: use direnv solve this currently, or find out where PATH is set
}

# NOTE: the poetry route: requirements -> poetry.toml -> poetry2nix
# https://github.com/python-poetry/poetry/issues/663#issuecomment-471060279
# https://github.com/nix-community/poetry2nix
# (I like this approach more, it's more nix way, but also more problematic)

0 comments on commit b57b888

Please sign in to comment.