dotfiles/nix-conf/home-manager/home.nix

196 lines
6.3 KiB
Nix
Raw Normal View History

# myHome is injected from extraSpecialArgs in flake.nix
2022-11-09 11:35:28 +00:00
{ config
, pkgs # This is by default just ``= import <nixpkgs>{}`
2022-11-09 11:35:28 +00:00
, myHome
, ...
}:
2022-12-03 06:43:44 +00:00
let
nvim_pkgs = [
# Yes, I desperately want neovim to work out-of-the-box without flake.nix for now
# I want at least python LSP to work everywhere because it's basically
# an alternative to bash script when I move to OpenColo
pkgs.gccStdenv
pkgs.gcc
pkgs.tree-sitter
pkgs.ripgrep
pkgs.fzf
# pkgs.sumneko-lua-language-server
pkgs.ripgrep
pkgs.zk
pkgs.fd
pkgs.stdenv.cc.cc.lib
# Python3 as alternative to bash scripts :^)
# (pkgs.python310Full.withPackages (pypkgs: [
# # python-lsp-server's dependencies is absolutely astronomous
# # pypkgs.python-lsp-server # python-lsp. Now we'll have to tell mason to look for this
# pypkgs.pynvim # nvim provider
2022-12-03 10:08:54 +00:00
# pypkgs.ujson # pylsp seems to rely on this. satisfy it lol
2022-12-03 06:43:44 +00:00
# ]))
];
proj_root = builtins.toString ./../..;
# TODO: put this in a seperate library
# callPackage supports both PATH and function as first param!
# TODO: support yaml string with writeTextFile (provided by callPackge)
2022-12-06 04:29:26 +00:00
yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage ({ runCommand }:
# runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33
2022-12-06 04:29:26 +00:00
runCommand outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
# run yq which outputs '.' (no filter) on file at yamlPath
# note that $out is passed onto the bash/sh script for execution
2022-12-06 04:29:26 +00:00
''
echo "$yamlContent" | yq >$out
'') { };
# fromYamlPath = yamlPath: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlPath "any-output.json"));
fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json"));
2022-12-03 06:43:44 +00:00
in
2022-11-06 20:23:10 +00:00
{
home = {
username = myHome.username;
homeDirectory = myHome.homeDirectory;
stateVersion = myHome.stateVersion or "22.05";
};
home.packages = pkgs.lib.unique ([
2022-12-01 02:17:06 +00:00
pkgs.ncdu
2022-11-09 11:35:28 +00:00
pkgs.htop
pkgs.ripgrep
pkgs.unzip
pkgs.rust-bin.nightly.latest.default # Needed for alacritty?
2022-11-25 23:45:08 +00:00
# pkgs.nodejs-18_x
# pkgs.rust-analyzer # This should be very specific to env
# cool utilities
pkgs.yq # Yaml adaptor for jq (only pretty print, little query)
pkgs.xorg.xclock # TODO: only include if have GL # For testing GL installation
pkgs.logseq # TODO: only include if have GL # Obsidian alt
pkgs.mosh # Parsec for SSH
pkgs.nixops_unstable # nixops v2
pkgs.lynx # Web browser at your local terminal
# pkgs.tailscale # VPC;; This should be installed in system-nix
2022-12-01 02:17:06 +00:00
pkgs.python310 # dev packages should be in jk
2022-11-09 15:35:44 +00:00
# pkgs.python310.numpy
# pkgs.python310Packages.tensorflow
# pkgs.python310Packages.scikit-learn
] ++ (myHome.packages or [ ]) ++ nvim_pkgs);
2022-11-06 20:23:10 +00:00
2022-11-06 22:22:09 +00:00
## Configs ##
xdg.configFile."nvim/init.lua".source = "${proj_root}//neovim/init.lua";
xdg.configFile."starship.toml".source = "${proj_root}//starship/starship.toml";
xdg.configFile."zk/config.toml".source = "${proj_root}//zk/config.toml";
2022-11-06 22:22:09 +00:00
## Programs ##
2022-11-09 13:00:23 +00:00
programs.jq = {
enable = true;
};
programs.alacritty = myHome.programs.alacritty or {
2022-11-07 15:23:25 +00:00
enable = true;
2022-12-03 06:43:44 +00:00
# settings = myLib.fromYaml (builtins.readFile "${proj_root}/alacritty/alacritty.yml");
2022-12-06 04:29:26 +00:00
settings = fromYaml (builtins.readFile "${proj_root}//alacritty/alacritty.yml");
2022-11-07 15:23:25 +00:00
};
# nix: Propagates the environment with packages and vars when enter (children of)
# a directory with shell.nix-compatible and .envrc
programs.direnv = {
enable = true;
nix-direnv.enable = true;
2022-11-28 02:04:38 +00:00
# nix-direnv.enableFlakes = true; # must remove. this will always be supported.
};
# z <path> as smarter cd
2022-11-06 22:22:09 +00:00
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
programs.tmux = {
enable = true;
2022-12-03 06:43:44 +00:00
extraConfig = builtins.readFile "${proj_root}/tmux/tmux.conf";
2022-11-06 22:22:09 +00:00
};
programs.exa = {
enable = true;
enableAliases = true;
};
programs.starship = {
enable = true;
enableZshIntegration = true;
};
2022-11-06 20:23:10 +00:00
programs.home-manager.enable = true;
programs.fzf.enable = true;
2022-12-01 02:17:06 +00:00
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
withPython3 = true;
withNodeJs = true;
2022-12-03 10:08:54 +00:00
extraPackages = nvim_pkgs;
2022-12-01 08:18:39 +00:00
# extraPython3Packages = (pypkgs: [
2022-12-03 10:08:54 +00:00
# # pypkgs.python-lsp-server
2022-12-01 08:18:39 +00:00
# pypkgs.ujson
# ]);
2022-12-01 02:17:06 +00:00
# I use vim-plug, so I probably don't require packaging
# extraConfig actually writes to init-home-manager.vim (not lua)
# https://github.com/nix-community/home-manager/pull/3287
2022-12-03 06:43:44 +00:00
# extraConfig = builtins.readFile "${proj_root}/neovim/init.lua";
2022-12-01 02:17:06 +00:00
};
2022-11-10 18:42:35 +00:00
programs.bash = {
enable = true;
enableCompletion = true;
initExtra = myHome.shellInitExtra or "";
};
2022-11-06 20:23:10 +00:00
programs.zsh = {
enable = true;
enableCompletion = true;
enableAutosuggestions = true;
shellAliases = {
nix-rebuild = "sudo nixos-rebuild switch";
2022-11-06 22:22:09 +00:00
hm-switch = "home-manager switch --flake";
2022-11-09 11:35:28 +00:00
} // (myHome.shellAliases or { });
2022-11-06 20:23:10 +00:00
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
};
oh-my-zsh = {
enable = true;
plugins = [ "git" "sudo" "command-not-found" "gitignore" "ripgrep" "rust" ];
};
2022-11-10 18:42:35 +00:00
initExtra = myHome.shellInitExtra or "";
2022-11-06 20:23:10 +00:00
};
programs.git = {
enable = true;
lfs.enable = true;
aliases = {
2022-11-09 11:35:28 +00:00
a = "add";
c = "commit";
2022-12-02 23:42:48 +00:00
ca = "commit --amend";
2022-11-09 11:35:28 +00:00
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
2022-12-02 23:42:48 +00:00
co = "checkout";
b = "branch";
2022-11-06 20:23:10 +00:00
};
# No idea why this is not appearing in home-manager search
# It's in source code, though
userName = "pegasust";
userEmail = "pegasucksgg@gmail.com";
2022-11-06 20:23:10 +00:00
extraConfig = {
2022-11-09 11:35:28 +00:00
merge = { tool = "vimdiff"; conflictstyle = "diff3"; };
2022-11-06 20:23:10 +00:00
};
2022-11-22 01:24:38 +00:00
ignores = [
# vscode-related settings
".vscode"
# envrc cached outputs
".direnv"
];
extraConfig = {
# cache credential for 50 minutes (a pomodoro session)
credential.helper = "cache --timeout=3000";
2022-11-22 01:24:38 +00:00
};
2022-11-06 20:23:10 +00:00
# why is this no longer valid?
# pull = { rebase=true; };
};
programs.ssh = {
enable = true;
forwardAgent = true;
2022-12-03 06:43:44 +00:00
extraConfig = builtins.readFile "${proj_root}/ssh/config";
};
2022-11-06 20:23:10 +00:00
}