Skip to content

Instantly share code, notes, and snippets.

@nickrttn
Last active November 29, 2023 14:58
Show Gist options
  • Save nickrttn/28acb67356c77b838493f31a6286fc03 to your computer and use it in GitHub Desktop.
Save nickrttn/28acb67356c77b838493f31a6286fc03 to your computer and use it in GitHub Desktop.
dotfiles

Get up and running

  1. Install Nix:
# Install Nix
sh <(curl -L https://nixos.org/nix/install)
# Follow unstable channel
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
# Update packages store
nix-channel --update
  1. Install Home Manager (standalone installation):
# Add Home Manager channel
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
# Update packages store
nix-channel --update
# Install Home Manager and create the first generation
nix-shell '<home-manager>' -A install
  1. Add sandbox = true to ~/.config/nix/nix.conf
  2. Copy contents of home.nix into ~/.config/home-manager/home.nix
  3. Run home-manager switch
  4. Done

Updating

The following commands update your environment to the latest packages:

First, update Nix packages:

nix-channel --update

Then apply them with Home Manager:

home-manager switch

Garbage collection

Run this every so often to clear out previous versions of packages. This removes your ability to roll back to a previous generation, so make sure your environment is stable before running it.

nix-collect-garbage -d
{ config, lib, pkgs, ... }:
{
nixpkgs.config = {
allowUnfree = true;
input-fonts.acceptLicense = true;
};
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "nick";
home.homeDirectory = "/Users/nick";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "22.11";
home.sessionVariables = {
EDITOR = "code --wait";
NODE_PATH = "$HOME/.npm-packages/lib/node_modules";
PATH = "$HOME/.npm-packages/bin:$HOME/.config/composer/vendor/bin:$PATH";
SSH_AUTH_SOCK="~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock";
TERM = "xterm-kitty";
ZSH_AUTOSUGGEST_USE_ASYNC = 1;
};
home.packages = [
pkgs._1password
# pkgs.awscli2
pkgs.bottom
pkgs.btop
pkgs.curl
pkgs.eza
pkgs.flyctl
pkgs.input-fonts
pkgs.jq
pkgs.mononoki
pkgs.newt
pkgs.ngrok
pkgs.nodejs_20
pkgs.nodePackages.npm-check-updates
pkgs.php
pkgs.php81Packages.phpcbf
pkgs.php81Packages.phpcs
pkgs.ruby
pkgs.sentry-cli
pkgs.wget
];
# Let Home Manager install and manage itself.
programs.home-manager = {
enable = true;
};
programs.kitty = {
enable = true;
font = {
name = "mononoki";
size = 16;
};
extraConfig = lib.concatMapStrings (x: x + "\n") [
"text_composition_strategy platform"
"macos_titlebar_color system"
"map cmd+enter launch --cwd=current"
"include current-theme.conf"
];
};
programs.zsh = {
enable = true;
enableAutosuggestions = true;
enableVteIntegration = true;
autocd = true;
shellAliases = {
ls = "eza";
yarn = "corepack yarn";
pnpm = "corepack pnpm";
gbsc = "git branch --sort=-committerdate";
};
initExtraFirst = lib.concatMapStrings (x: x + "\n") [
"eval $(thefuck --alias)"
];
initExtra = lib.concatMapStrings (x: x + "\n") [
"source /Users/nick/.config/op/plugins.sh"
"function precmd() {"
" # Add node_modules/.bin to path"
" path=(\${path[@]:#\*node_modules*})"
" local p=\"$(pwd)\""
" while [[ \"$p\" != '/' ]]; do"
" if [[ -d \"$p/node_modules/.bin\" ]]; then"
" path+=(\"$p/node_modules/.bin\")"
" fi"
" p=\"$(dirname \"$p\")\""
" done"
" typeset -U path"
"}"
];
historySubstringSearch = {
enable = true;
};
plugins = [
{
name = "zsh-saneopt";
file = "saneopt.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "willghatch";
repo = "zsh-saneopt";
rev = "8ec7ce0387309dcdb72b71ac85edc8799aa42792";
sha256 = "sha256-g0hLvvmoPWjX9GW4f+xbFCVHN7TtOCUxDfD8oLEuNy4=";
};
}
{
name = "fast-syntax-highlighting";
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
src = pkgs.zsh-fast-syntax-highlighting;
}
{
name = "zephyr/directory";
file = "plugins/directory/directory.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "mattmc3";
repo = "zephyr";
rev = "325789d10e5243038d7b25ce6a27f782d130f5a4";
sha256 = "sha256-gDCn9m3XEltpyTG/7tlJxtfgaRYpBSUYDXP54AqzmuI=";
};
}
{
name = "zephyr/environment";
file = "plugins/environment/environment.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "mattmc3";
repo = "zephyr";
rev = "325789d10e5243038d7b25ce6a27f782d130f5a4";
sha256 = "sha256-gDCn9m3XEltpyTG/7tlJxtfgaRYpBSUYDXP54AqzmuI=";
};
}
{
name = "zephyr/history";
file = "plugins/history/history.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "mattmc3";
repo = "zephyr";
rev = "325789d10e5243038d7b25ce6a27f782d130f5a4";
sha256 = "sha256-gDCn9m3XEltpyTG/7tlJxtfgaRYpBSUYDXP54AqzmuI=";
};
}
{
name = "zephyr/utility";
file = "plugins/utility/utility.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "mattmc3";
repo = "zephyr";
rev = "325789d10e5243038d7b25ce6a27f782d130f5a4";
sha256 = "sha256-gDCn9m3XEltpyTG/7tlJxtfgaRYpBSUYDXP54AqzmuI=";
};
}
{
name = "zephyr/completion";
file = "plugins/completion/completion.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "mattmc3";
repo = "zephyr";
rev = "325789d10e5243038d7b25ce6a27f782d130f5a4";
sha256 = "sha256-gDCn9m3XEltpyTG/7tlJxtfgaRYpBSUYDXP54AqzmuI=";
};
}
{
name = "prezto";
file = "share/zsh-prezto/modules/git/alias.zsh";
src = pkgs.zsh-prezto;
}
{
name = "zsh-safe-rm";
src = pkgs.fetchFromGitHub {
owner = "mattmc3";
repo = "zsh-safe-rm";
rev = "9463e7def5932e8c1958f8c023621bbddcfa2a58";
sha256 = "sha256-dIAt1HYOY5MF5hCRm4YW2VXr/a2g3GEFq/Xa/IpPqgU=";
fetchSubmodules = true;
};
}
{
name = "zsh-you-should-use";
src = pkgs.zsh-you-should-use;
file = "share/zsh/plugins/you-should-use/you-should-use.plugin.zsh";
}
];
};
programs.z-lua = {
enable = true;
enableAliases = true;
enableZshIntegration = true;
options = [
"enhanced"
"once"
"fzf"
];
};
programs.starship = {
enable = true;
enableZshIntegration = true;
settings = {
format = "$character";
command_timeout = 2000;
right_format = lib.concatStrings [
"$git_branch"
"$git_commit"
"$git_state"
"$git_status"
"$directory"
"$hostname"
"$line_break"
"$status"
];
character = {
success_symbol = "[λ](bold green)";
error_symbol = "[λ](bold red)";
};
directory = {
truncation_length = 2;
style = "fg:242";
};
git_branch = {
format = "[$symbol$branch]($style) ";
symbol = " ";
style = "green";
};
};
};
programs.gh = {
enable = true;
gitCredentialHelper = {
enable = true;
};
settings = {
editor = "code-insiders --wait";
aliases = {
co = "pr checkout";
pv = "pr view";
};
};
};
programs.git = {
enable = true;
userName = "Nick Rutten";
userEmail = "2504906+nickrttn@users.noreply.github.com";
signing = {
key = "D206224E62BA642E";
signByDefault = true;
};
difftastic = {
enable = true;
};
extraConfig = {
core = {
editor = "code-insiders --wait";
};
init = {
defaultBranch = "main";
};
push = {
autoSetupRemote = true;
};
commit = {
gpgsign = true;
};
color = {
ui = true;
};
};
lfs = {
enable = true;
};
};
programs.gpg = {
enable = true;
settings = {
auto-key-retrieve = true;
no-emit-version = true;
default-key = "8076DC1A752E9DCC9CB6DA51D206224E62BA642E";
};
};
programs.thefuck = {
enable = true;
enableBashIntegration = false;
enableZshIntegration = true;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment