Skip to content

Instantly share code, notes, and snippets.

@will
Created April 11, 2023 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save will/357b7e43da67cda76c6d09fbd2d82355 to your computer and use it in GitHub Desktop.
Save will/357b7e43da67cda76c6d09fbd2d82355 to your computer and use it in GitHub Desktop.
home manager 2023-04-11
# switch with `nix run . switch -- --flake .`
# https://www.chrisportela.com/posts/home-manager-flake/
{
description = "My Home Manager Flake";
inputs = {
nixpkgs.url = "nixpkgs";
unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
unstable_nvim.url = "github:GaetanLepage/nixpkgs/neovim";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
oblique = {
url = "github:will/oblique";
inputs.nixpkgs.follows = "nixpkgs";
};
crystal = {
url = "github:will/nixpkgs-crystal";
inputs.nixpkgs.follows = "nixpkgs";
};
neovim = {
url = "github:neovim/neovim?dir=contrib";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
supportedSystems = [ "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
# overlays = import ./overlays;
legacyPackages = forAllSystems (system: import inputs.nixpkgs {
inherit system;
#overlays = builtins.attrValues overlays;
config.allowUnfree = true;
});
packages.aarch64-darwin.default = home-manager.defaultPackage.aarch64-darwin;
homeConfigurations = {
will = home-manager.lib.homeManagerConfiguration {
pkgs = inputs.nixpkgs.legacyPackages.aarch64-darwin;
extraSpecialArgs = {
unstablePkgs = inputs.unstable.legacyPackages.aarch64-darwin;
inherit inputs;
};
modules = [ ./home.nix ];
};
};
};
}
{ config, pkgs, unstablePkgs, inputs, ... }:
# https://mipmip.github.io/home-manager-option-search/
let
# {{{
asYaml = (pkgs.formats.yaml { }).generate;
unstable = unstablePkgs.pkgs;
in
{
# }}}
# meta {{{
# manual.manpages.enable = false;
home = {
stateVersion = "22.05"; # To figure this out (in-case it changes) you can comment out the line and see what version it expected.
username = "will";
homeDirectory = "/Users/will";
sessionVariables = { EDITOR = "nvim"; };
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
# }}}
# global packages {{{
home.packages = with pkgs; [
nil # nix lsp 2023-01-04 is this needed with the new nix lsp thing?
inputs.unstable_nvim.legacyPackages.aarch64-darwin.neovim
nixpkgs-fmt
stylua
ripgrep
lazygit
fd
fzf
gh
unstable.yt-dlp
ffmpeg
(unstable.nerdfonts.override { fonts = [ "FiraCode" ]; })
# trying new tools
curlie
fx
# my stuff
#(callPackage buildFromFlake { repo = "github:will/oblique?ref=cafe445"; })
inputs.oblique.packages.${system}.default
inputs.crystal.packages.${system}.default
# whatever
# cargo
]; # }}}
# direnv {{{
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
# }}}
# lsd {{{
programs.lsd = { enable = true; enableAliases = true; settings.color.theme = "custom.yaml"; };
xdg.configFile."lsd/themes/custom.yaml".source = asYaml "lsd-theme.yaml" {
user = "cyan";
group = "green";
permission = {
read = "dark_green";
write = "dark_yellow";
exec = "dark_red";
exec-sticky = 5;
no-access = 245;
octal = 6;
acl = "dark_cyan";
context = "cyan";
};
date = { hour-old = "magenta"; day-old = "green"; older = "blue"; };
size = { none = "black"; small = "yellow"; medium = "cyan"; large = "red"; };
inode = { valid = 13; invalid = 245; };
links = { valid = 13; invalid = 245; };
tree-edge = 245;
};
# }}}
# git {{{
programs.git = {
enable = true;
userName = "Will Leinweber";
userEmail = "will@bitfission.com";
diff-so-fancy.enable = true;
ignores = [
".DS_Store"
"*~"
"*.swp"
"*.swo"
".crystal"
"'"
".direnv"
];
aliases = {
b = "for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) (%(color:green)%(committerdate:relative)%(color:reset)) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) %(color:bold blue)<%(authorname)>%(color:reset)'";
ci = "commit";
co = "checkout";
ff = "merge --ff-only";
fixup = "commit --amend -C head";
l = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %f %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative main..";
lg = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %f %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all";
logl = "log --pretty=oneline --abbrev-commit --decorate";
ls = "!git ls-files -m | xargs ls -la";
unadd = "update-index --force-remove";
vain = "!/Users/will/code/git-vain/git-vain";
};
extraConfig = {
init = { defaultBranch = "main"; };
pull = { ff = "only"; };
push = { default = "tracking"; autoSetupRemote = true; };
rebase = { autoStash = true; updateRefs = true; };
rerere = { enabled = true; };
vain = { default = "cafe"; };
};
}; # }}}
# shell stuff {{{
programs.fish = {
# fish {{{
enable = true;
shellInit = ''
if test -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish
end
set -gx ATUIN_NOBIND "true"
'';
interactiveShellInit = ''
set -U Z_CMD "j"
set -U Z_OWNER "will"
set -gx DIRENV_LOG_FORMAT ""
abbr --add dotdot --regex '^\.\.+$' --function multicd
abbr -a !! --position anywhere --function last_history_item
'';
shellAliases = {
gco = "git checkout";
gd = "git diff";
gs = "git status";
gr = "git rebase";
ghco = "gh pr list | cut -f1,2,3 | fzf --ansi --preview 'GH_FORCE_TTY=100% gh pr view {1}' --preview-window down --color 'preview-bg:#191724' | cut -f1 | xargs gh pr checkout";
h = "heroku";
hr = "heroku run -s performance-l";
vim = "nvim";
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
cat = "bat";
curl = "curlie";
};
shellAbbrs = {
v = "nvim";
hme = "home-manager edit";
hms = "home-manager switch";
};
functions = {
fish_greeting = "oblique";
multicd = "echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../)";
last_history_item = "echo $history[1]";
};
plugins = [
{
name = "z";
src = pkgs.fetchFromGitHub {
owner = "jethrokuan";
repo = "z";
rev = "85f863f20f24faf675827fb00f3a4e15c7838d76";
hash = "sha256-+FUBM7CodtZrYKqU542fQD+ZDGrd2438trKM0tIESs0=";
};
}
];
};
xdg.configFile."fish/completions/nix.fish".source = "${pkgs.nix}/share/fish/vendor_completions.d/nix.fish";
# }}}
programs.starship = {
# starship {{{
enable = true;
settings = {
format = "[](a)$status[](fg:a bg:b)$directory[](fg:b bg:c)$git_branch$git_status$git_state[](fg:c bg:d)$nix_shell[](fg:d bg:e)[](fg:e bg:f)$cmd_duration[ ](fg:f)";
# a
status = {
style = "fg:text bg:a";
format = "[ $symbol$status ]($style)";
disabled = false;
};
# b
directory = {
style = "fg:text bg:b";
format = "[ $path$read_only ]($style)";
truncation_length = 3;
truncation_symbol = "…/";
read_only = " ";
substitutions = {
owl = " ";
nvim = " ";
".config" = " ";
Documents = " ";
Downloads = " ";
Music = " ";
Pictures = " ";
};
};
# c
git_branch.format = "[  $branch ](fg:text bg:c)";
git_state.format = "[$state( $progress_current/$progress_total)](fg:text bg:c)";
git_status = {
format = "[$all_status$ahead_behind ](fg:text bg:c)";
conflicted = "";
deleted = "﫧";
modified = "";
stashed = "";
staged = "";
renamed = "";
untracked = "";
};
# d
nix_shell.format = "[  ](fg:text bg:d)";
# e
# f
cmd_duration.format = "[ $duration ](fg:text bg:f)";
# palette
palette = "rosepine";
palettes.rosepine = {
text = "black";
a = "red";
b = "purple";
c = "blue";
d = "green";
e = "cyan";
f = "yellow";
};
};
}; # }}}
# }}}
# misc: btop, bat {{{
programs.btop = {
enable = true;
settings = { color_theme = "TTY"; vim_keys = true; };
};
programs.bat = { enable = true; config.theme = "base16"; };
# }}}
# neovim nightly {{{
# nixpkgs.overlays = [
# (import (builtins.fetchTarball {
# url = "https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz";
# }))
# ];
# programs.neovim = {
# enable = true;
# package = unstable.neovim-nightly;
#};
# }}}
}
# vim: foldlevel=0 foldmethod=marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment