Skip to content

Instantly share code, notes, and snippets.

@nickrttn
Last active July 16, 2024 15:25
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 extra-experimental-features = nix-command flakes 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
{ 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 should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.11"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = [
pkgs._1password
pkgs.bottom
pkgs.bun
pkgs.curl
pkgs.devenv
pkgs.eza
pkgs.git
pkgs.graphviz
pkgs.input-fonts
pkgs.jq
pkgs.monaspace
pkgs.mononoki
pkgs.ngrok
pkgs.nixd
pkgs.nodejs_20
pkgs.railway
pkgs.rustup
pkgs.silver-searcher
pkgs.wget
];
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. If you don't want to manage your shell through Home
# Manager then you have to manually source 'hm-session-vars.sh' located at
# either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/nick/etc/profile.d/hm-session-vars.sh
#
home.sessionVariables = {
EDITOR = "code --wait";
NODE_PATH = "$HOME/.npm-packages/lib/node_modules";
PATH = "$HOME/.local/share/pnpm:$HOME/.npm-packages/bin:$PATH";
PNPM_HOME = "$HOME/.local/share/pnpm";
SSH_AUTH_SOCK="~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock";
TERM = "xterm-kitty";
ZSH_AUTOSUGGEST_USE_ASYNC = 1;
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true;
};
programs.kitty = {
enable = true;
font = {
name = "Monaspace Neon Light";
size = 16.0;
};
extraConfig = lib.concatMapStrings (x: x + "\n") [
"bold_font Monaspace Neon Var SemiBold"
"bold_italic_font Monaspace Radon Var Bold Italic"
"font_features MonaspaceNeonVar-Light +calt +ss04 +ss06 +ss07 +ss08 +ss09 +liga"
"italic_font Monaspace Radon Var Light Italic"
"macos_titlebar_color system"
"map cmd+enter launch --cwd=current"
"scrollback_lines 10000"
"text_composition_strategy platform"
"include kanagawa.conf"
];
};
programs.zsh = {
enable = true;
enableVteIntegration = true;
autocd = true;
autosuggestion = {
enable = true;
};
shellAliases = {
gbsc = "git branch --sort=-committerdate";
hm = "home-manager";
ls = "eza";
pnpm = "corepack pnpm";
};
historySubstringSearch = {
enable = true;
};
plugins = [
{
name = "fast-syntax-highlighting";
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
src = pkgs.zsh-fast-syntax-highlighting;
}
{
name = "zsh-you-should-use";
src = pkgs.zsh-you-should-use;
file = "share/zsh/plugins/you-should-use/you-should-use.plugin.zsh";
}
{
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;
};
}
] ++ builtins.map(x: {
name = "zephyr/" + x;
file = "plugins/" + x + "/" + x + ".plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "mattmc3";
repo = "zephyr";
rev = "81193c9683c6a212efbcc4c07b62c9e62317fc93";
sha256 = "sha256-lMufBaJiTixQZQTH9MWE+0LteIBLQAKuIo2tWsnbwNE=";
};
}) [
"environment"
"history"
"directory"
"color"
"utility"
"completion"
];
};
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
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 = "[λ](green)";
error_symbol = "[λ](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 --wait";
aliases = {
co = "pr checkout";
pv = "pr view";
};
};
};
programs.git = {
enable = true;
userName = "Nick Rutten";
userEmail = "2504906+nickrttn@users.noreply.github.com";
signing = {
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOS0QW/DM0KBNXXe3spOqeWZm6rErsyayYSh4jSUnIX7";
signByDefault = true;
};
difftastic = {
enable = true;
};
extraConfig = {
core = {
editor = "code --wait";
};
init = {
defaultBranch = "main";
};
push = {
autoSetupRemote = true;
};
commit = {
gpgsign = true;
};
gpg = {
format = "ssh";
ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
};
color = {
ui = true;
};
};
lfs = {
enable = true;
};
};
programs.gpg = {
enable = true;
settings = {
auto-key-retrieve = true;
no-emit-version = true;
default-key = "8076DC1A752E9DCC9CB6DA51D206224E62BA642E";
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment