Skip to content

Commit

Permalink
misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanshelly committed Nov 29, 2020
1 parent 9438448 commit e71df5f
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 124 deletions.
1 change: 0 additions & 1 deletion gui/apps/karabiner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ brew install "yqrashawn/goku/goku"
Finally run the following command from anywhere to apply the config:

```console
~/.files on goku
GOKU_EDN_CONFIG_FILE="$DOTFILES/gui/apps/karabiner/karabiner.edn" goku
Done!
```
Expand Down
1 change: 1 addition & 0 deletions infra/setup/bin/setup_zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source "$DOTFILES/infra/scripts/prompts.sh"

info "Setting up zsh"

# TODO: move this setup into nix-darwin config
# add `zsh` to allowed shells if not already added
function maybe_add_active_zsh_to_allowed_shells() {
local active_zsh_path
Expand Down
115 changes: 50 additions & 65 deletions nix/darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,63 @@
# configuration for `nix-darwin` - https://github.com/lnl7/nix-darwin
let
USER = "${builtins.getEnv "USER"}";
SHOULD_INSTALL_NATHAN_SPECIFIC_CONFIG = builtins.pathExists
"${builtins.getEnv "HOME"}/.nathan";
in
{
# TODO: add keyboard shortcuts - https://github.com/LnL7/nix-darwin/pull/189

# TODO: - package & install natasha-codes font
# https://daiderd.com/nix-darwin/manual/index.html#opt-fonts.enableFontDir

# TODO: maybe set up nix-index for command not found helper?
# - https://github.com/bennofs/nix-index
# - https://daiderd.com/nix-darwin/manual/index.html#opt-programs.nix-index.enable

# TODO: tmux/vim/zsh - maybe in home-manager instead? any way to use both?
# - https://daiderd.com/nix-darwin/manual/index.html#opt-programs.tmux.enable

# use a custom config location
# ref - https://github.com/lnl7/nix-darwin/wiki/Changing-the-configuration.nix-location
# TODO: remove w/ flakes
environment = {
# use a custom config location
# ref - https://github.com/lnl7/nix-darwin/wiki/Changing-the-configuration.nix-location
# TODO: remove w/ flakes
darwinConfig = "$HOME/.files/nix/darwin.nix";

# TODO
# refs:
# - https://discourse.nixos.org/t/using-nix-to-install-login-shell-on-non-nixos-platform/2807/2
# - https://github.com/rycee/home-manager/issues/1226
# environment.systemPackages = [ pkgs.zsh ];
# shells = [
# # TODO: figure out how to reference user packages
# # config.users.users.nathan.packages.zsh
# ];

# TODO: understand how this is possibly supposed to work
# check existence of `$HOME/.nathan` file?
# figure out how to spread attribute sets
# TODO: figure out how to add user-profile `zsh`
shells = [ pkgs.zsh ];

# ref - https://daiderd.com/nix-darwin/manual/index.html#opt-environment.systemPath
# environment.systemPath = import ./work.nix
# systemPath = [] ++ (
# if builtins.pathExists "${builtins.getEnv "HOME"}/work"
# then (import ./work.nix).darwin.environment.systemPath
# else []
# );
systemPath = [] ++ (
if builtins.pathExists "${builtins.getEnv "HOME"}/work"
then (import ./work.nix).darwin.environment.systemPath
else []
);
};


# user environment management via home-manager
# - https://rycee.gitlab.io/home-manager/index.html#sec-install-nix-darwin-module
# imports = [ inputs.home-manager.darwinModules.home-manager ];
# # TODO: remove when switching to flake-based nix-darwin installer
imports = [ <home-manager/nix-darwin> ];
# imports = [ <home-manager/nix-darwin> ];
home-manager.users."${USER}" = import ./home.nix;
home-manager.useUserPackages = true;

# protect `nix-direnv` dev environments from being garbage collected
# ref - https://github.com/nix-community/nix-direnv#via-home-manager
#
# manual - https://daiderd.com/nix-darwin/manual/index.html#opt-nix.extraOptions
nix.extraOptions = ''
keep-derivations = true
keep-outputs = true
# enable flakes - https://zimbatm.com/NixFlakes/#other-systems
experimental-features = nix-command flakes ca-references
'';

# enable flakes, an experimental Nix feature
# https://zimbatm.com/NixFlakes/#other-systems
# TODO: confirm I don't also need this in user packages below
nix.package = pkgs.nixFlakes;

nix.trustedUsers = [ USER ];

# create /etc/zshrc that loads the nix-darwin environment
# TODO: test if this is necessary
nix = {
# https://daiderd.com/nix-darwin/manual/index.html#opt-nix.extraOptions
extraOptions = ''
# enable flakes - https://zimbatm.com/NixFlakes/#other-systems
experimental-features = nix-command flakes ca-references
# protect `nix-direnv` dev environments from being garbage collected
# ref - https://github.com/nix-community/nix-direnv#via-home-manager
keep-derivations = true
keep-outputs = true
'';

# enable flakes, an experimental Nix feature
# https://zimbatm.com/NixFlakes/#other-systems
package = pkgs.nixFlakes;

trustedUsers = [ USER ];
};

# create /etc/zshrc that activates the nix-darwin environment on shell load
programs.zsh.enable = true;

# auto upgrade nix package and the daemon service
Expand All @@ -93,32 +79,30 @@ in

NSGlobalDomain._HIHideMenuBar = true;

# TODO: use below defaults once upgraded
# https://daiderd.com/nix-darwin/manual/index.html#opt-system.defaults.NSGlobalDomain.com.apple.trackpad.scaling
# system.defaults.NSGlobalDomain.com.apple.sound.beep.volume = 0;
# system.defaults.NSGlobalDomain.com.apple.trackpad.scaling = 3; # max speed
# system.defaults.NSGlobalDomain.com.apple.trackpad.scaling = 3;
# TODO understand why I can't seem to set these
# NSGlobalDomain."com.apple.sound.beep.volume" = null;
# NSGlobalDomain."com.apple.trackpad.scaling" = 3; # max speed

NSGlobalDomain.NSAutomaticCapitalizationEnabled = false;
NSGlobalDomain.NSNavPanelExpandedStateForSaveMode = true;
screencapture.location = "$HOME/Downloads";
};



users.users."${USER}" = {
# home key here requed for home-manager config to apply
home = "/Users/${USER}";
description = "Current user";
packages = with pkgs; [
alacritty
asciinema
bat
bazel
darwin.trash # TODO: understand behavior on non-Darwin system
darwin.trash
dust
exa
exiftool
fd
ffmpeg-full
gitAndTools.delta
gitAndTools.gh
gitAndTools.tig
gnumake
Expand All @@ -132,7 +116,6 @@ in
nodejs
python3
ripgrep
rnix-lsp
rsync
shellcheck
shfmt
Expand All @@ -145,15 +128,17 @@ in
watchexec
yarn
];
# TODO: understand how to get this to work
# shell = pkgs.zsh;
};

users.users.test = {
home = "/Users/test";
description = "Test User";
shell = pkgs.zsh;
};
# TODO: extend nix-darwin to allow shell setting w/o user recreation
# users = if SHOULD_INSTALL_NATHAN_SPECIFIC_CONFIG
# then {
# knownUsers = [ USER ];
# "${USER}" = {
# shell = pkgs.zsh;
# uid = 501;
# };
# } else {};

# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
Expand Down
11 changes: 5 additions & 6 deletions nix/editor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ in

extraConfig = builtins.readFile "${DOTFILES}/neovim/init.vim";

# TODO: test this
# TODO: figure out what's not working here
extraPython3Packages = ps: with ps; [ black ];

# TODO: move neovim-specific packages here form ./darwin.nix after upgrading
# home-manager version
# extraPackages = with pkgs; [
# rnix-lsp
# ];
# packages used only for nvim, these are not added to $PATH
extraPackages = with pkgs; [
rnix-lsp
];

plugins = with pkgs.vimPlugins; [
# fuzzy finder
Expand Down
2 changes: 2 additions & 0 deletions nix/git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
enable = true;

delta = {
# TODO: figure out why this config still needs `delta` in the user packages
# but only when in a tmux session
enable = true;
# https://github.com/dandavison/delta#configuration
options = {
Expand Down
36 changes: 3 additions & 33 deletions nix/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,16 @@ let
SHOULD_INSTALL_NATHAN_SPECIFIC_CONFIG = builtins.pathExists "${HOME}/.nathan";
in
{
# TODO: create issue to look into gpg signing
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.git.signing

# TODO: test exactly what path this affects - path to home-manager config?
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.home-manager.path

# TODO: manage fonts via fontconfig?
# fonts.fontconfig.enable = true

# TODO: figure out how to conditionally apply personal overrides
# check existence of `$HOME/.nathan` file?
# figure out how to spread attribute sets - "import ./nathan.nix"

# TODO: conditionally spread work zsh config
home.sessionVariables = if builtins.pathExists "${HOME}/work"
then (import ./work.nix).home.sessionVariables
else {};

# TODO: conditionally apply gui config
# figure out how to spread attribute sets - "import ./gui.nix"

# creates symlinks to immutable copies of the source file in /nix/store
# form: "<target>".source = "<source>"
home.file = {
# TODO: experiment with `tmux` module
".tmux.conf".source = "${DOTFILES}/tmux/tmux.conf";

# manage nix configuration
# "${config.xdg.configHome}/nix/nix.conf".text = ''
# # enable flakes - https://zimbatm.com/NixFlakes/#other-systems
# experimental-features = nix-command flakes
# '';
##### neovim #####
# extra configuration for `coc.nvim` plugin
"${config.xdg.configHome}/nvim/coc-settings.json".source = "${DOTFILES}/neovim/coc-settings.jsonc";
Expand All @@ -59,24 +37,20 @@ in
else {}
);

# avoid errors building man pages by disabling them
# similar previous bug - https://github.com/nix-community/home-manager/issues/254
# TODO: test if manpages have been fixed on unstable and remove this
manual.manpages.enable = false;

# configures shell hook to initialize direnv for zsh + nix-direnv integration
# refs:
# - https://rycee.gitlab.io/home-manager/options.html#opt-programs.direnv.enable
# - direnv - https://direnv.net/
programs.direnv = {
enable = true;
# TODO: confirm that this is unnecessary
enableZshIntegration = true;

# configure $HOME/.config/direnv/direnvrc to source nix-direnv initialization
# ref - https://github.com/nix-community/nix-direnv#via-home-manager
enableNixDirenvIntegration = true;

stdlib = ''
# add experimental flake integration
# ref - https://zimbatm.com/NixFlakes/#direnv-integration
use_flake() {
watch_file flake.nix
watch_file flake.lock
Expand All @@ -85,10 +59,6 @@ in
'';
};

# TODO: understand exactly what this does
# ref - https://rycee.gitlab.io/home-manager/options.html#opt-programs.dircolors.enable
programs.dircolors.enable = true;

# sources completions and key-bindings in interactive zsh sessions
# ref - https://rycee.gitlab.io/home-manager/options.html#opt-programs.fzf.enable
programs.fzf.enable = true;
Expand Down
21 changes: 2 additions & 19 deletions zsh/path.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,11 @@
# to prepend new entry - `path=(<new-addition> $path)`
# to append new entry - `path+=<new-addition>` (`()` required to add >1 entry)
modify_path() {
# poetry (python dependency manager) executables
[[ -d "$HOME/.poetry/bin" ]] && path=("$HOME/.poetry/bin" $path)

# `pip install --user` executables
[[ -d "$HOME/.local/bin" ]] && path=("$HOME/.local/bin" $path)

# cargo executables
[[ -d "$HOME/.cargo/bin" ]] && path=("$HOME/.cargo/bin" $path) # rust packages


# put nix profile first on path
# TODO: update nix-darwin systempath setting to apply in zshrc vs zshenv then
# remove this
[[ -d "/etc/profiles/per-user/$USER/bin" ]] && {
path=("/etc/profiles/per-user/$USER/bin" $path)
}
}
modify_path

# TODO: remove w/ flakes
modify_nix_path() {
# make frameworks managed via channels (nix-darwin, home-manager) available
export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
# make nix-darwin use the config in this repo
export NIX_PATH=darwin-config=$DOTFILES/nix/darwin.nix${NIX_PATH:+:}$NIX_PATH
}
modify_nix_path
2 changes: 2 additions & 0 deletions zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ setopt hist_ignore_space hist_ignore_all_dups hist_reduce_blanks share_history

# any last local overrides, gitignored to avoid checking in
[ -f "$DOTFILES/zsh/local.zsh" ] && source "$DOTFILES/zsh/local.zsh"

############################ END OF BESPOKE ZSHRC ##############################

0 comments on commit e71df5f

Please sign in to comment.