move nix-darwin config to dotfiles

This commit is contained in:
sloane 2024-03-29 20:49:45 -04:00
parent f750f8fbb4
commit 553cbfa969
No known key found for this signature in database
10 changed files with 937 additions and 0 deletions

1
.config/nix-darwin/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/result

View file

@ -0,0 +1,48 @@
# sloanelybutsurely/nix-darwin
machine configuration via nix, nix-darwin, and home-manager
## installation
### install nix
i've used the [Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer)
```sh
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```
### clone this repo
```sh
mkdir -p ~/.config
git clone git@github.com:sloanelybutsurely/nix-darwin.git ~/.config/nix-darwin
```
### build and activate flake
since `darwin-rebuild` isn't available yet, use `nix run ...`
```sh
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
```
this might take a while the first time. once it is done **restart the shell.**
### clone remaining dotfiles
_`yadm` should be available after switching for the first time._
```sh
yadm clone git@github.com:sloanelybutsurely/dotfiles.git
```
**note:** you might need to use `chsh -s` to set the nix managed fish shell as your default shell.
## making changes
if you make changes to `~/.config/nix-darwin` make sure all files are tracked by git and run `darwin-rebuild`
```sh
darwin-rebuild switch --flake ~/.config/nix-darwin
```

View file

@ -0,0 +1,327 @@
{
"nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1710717205,
"narHash": "sha256-Wf3gHh5uV6W1TV/A8X8QJf99a5ypDSugY4sNtdJDe0A=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "bcc8afd06e237df060c85bad6af7128e05fd61a3",
"type": "github"
},
"original": {
"owner": "LnL7",
"repo": "nix-darwin",
"type": "github"
}
},
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1711099426,
"narHash": "sha256-HzpgM/wc3aqpnHJJ2oDqPBkNsqWbW0WfWUO8lKu8nGk=",
"owner": "numtide",
"repo": "devshell",
"rev": "2d45b54ca4a183f2fdcf4b19c895b64fbf620ee8",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709336216,
"narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"nixvim",
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1711133180,
"narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"home-manager_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1711133180,
"narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1710717205,
"narHash": "sha256-Wf3gHh5uV6W1TV/A8X8QJf99a5ypDSugY4sNtdJDe0A=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "bcc8afd06e237df060c85bad6af7128e05fd61a3",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1711231723,
"narHash": "sha256-dARJQ8AJOv6U+sdRePkbcVyVbXJTi1tReCrkkOeusiA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e1d501922fd7351da4200e1275dfcf5faaad1220",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"home-manager": "home-manager_2",
"nix-darwin": "nix-darwin",
"nixpkgs": [
"nixpkgs"
],
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1711284540,
"narHash": "sha256-DTzi4ujZoxM3ZXStCwD6Lph3FdGtkBlvfYsDCRITjfA=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "e7a3461fefd983ae3443e9aa849e9d1566ab47e4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1710923068,
"narHash": "sha256-6hOpUiuxuwpXXc/xfJsBUJeqqgGI+JMJuLo45aG3cKc=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "e611897ddfdde3ed3eaac4758635d7177ff78673",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"darwin": "darwin",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,63 @@
{
description = "Sloane's Darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
darwin.url = "github:LnL7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixvim.url = "github:nix-community/nixvim";
nixvim.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, darwin, nixpkgs, home-manager, nixvim }:
let
globalModules = [
{ system.configurationRevision = self.rev or self.dirtyRev or null; }
];
globalDarwinModules = globalModules ++ [
./modules/darwin/global.nix
nixvim.nixDarwinModules.nixvim
home-manager.darwinModules.home-manager
./modules/darwin/nixvim.nix
];
in {
# Build darwin flake using:
# $ darwin-rebuild build --flake .#Sloanes-MacBook-Air
darwinConfigurations."Sloanes-MacBook-Air" = darwin.lib.darwinSystem {
modules = globalDarwinModules ++ [
./hosts/Sloanes-MacBook-Air/default.nix
{
users.users.sloane.home = "/Users/sloane";
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.sloane = import ./users/sloane/default.nix;
};
}
];
};
darwinConfigurations."Sloanes-MacBook-Pro" = darwin.lib.darwinSystem {
# Set Git commit hash for darwin-version.
system.configurationRevision = self.rev or self.dirtyRev or null;
modules = globalDarwinModules ++ [
./hosts/Sloanes-MacBook-Pro/default.nix
{
users.users.sloane.home = "/Users/sloane";
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.sloane = import ./users/sloane/default.nix;
};
}
];
};
# Expose the package set, including overlays, for convenience.
# darwinPackages = self.darwinConfigurations."Sloanes-MacBook-Air".pkgs;
};
}

View file

@ -0,0 +1,19 @@
{ pkgs, ... }:
{
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin";
environment.systemPackages = with pkgs; [
rustup
];
homebrew = {
casks = [
"discord"
"postgres-unofficial"
"postico"
"syncthing"
"tailscale"
];
};
}

View file

@ -0,0 +1,10 @@
{ self, pkgs, ... }:
{
nixpkgs.hostPlatform = "aarch64-darwin";
homebrew = {
casks = [
"slack"
];
};
}

View file

@ -0,0 +1,75 @@
{ self, pkgs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [
fish
git
curl
tmux
];
environment.shells = [ pkgs.fish ];
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# nix.package = pkgs.nix;
nix.settings = {
# Necessary for using flakes on this system.
experimental-features = "nix-command flakes";
substituters = [
"https://nix-community.cachix.org"
"https://cache.nixos.org"
];
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
trusted-users = ["root" "sloane"];
};
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
programs.fish.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
system.defaults = {
dock = {
orientation = "bottom";
autohide = true;
autohide-delay = 0.1;
show-recents = false;
};
};
homebrew = {
enable = true;
onActivation = {
autoUpdate = true;
upgrade = true;
};
brews = [ "openssl" ];
taps = [ "homebrew/cask-fonts" ];
casks = [
"1password"
"alfred"
"dash"
"fantastical"
"firefox"
"karabiner-elements"
"keepingyouawake"
"kitty"
"obsidian"
"unnaturalscrollwheels"
"font-cousine-nerd-font"
];
masApps = {
"Things 3" = 904280696;
};
};
}

View file

@ -0,0 +1,207 @@
{ pkgs, ... }:
{
programs.nixvim = {
enable = true;
options = {
number = true;
relativenumber = true;
tabstop = 2;
shiftwidth = 2;
expandtab = true;
};
colorschemes.catppuccin = {
enable = true;
flavour = "frappe";
};
extraPlugins = with pkgs.vimPlugins; [
vim-abolish
vim-dispatch
vim-repeat
vim-sensible
vim-rhubarb
vim-sort-motion
vim-textobj-user
nerdtree
];
plugins = {
surround.enable = true;
commentary.enable = true;
fugitive.enable = true;
tmux-navigator.enable = true;
nvim-autopairs = {
enable = true;
};
lsp = {
enable = true;
servers = {
elixirls.enable = true;
tsserver.enable = true;
nil_ls.enable = true;
};
};
telescope = {
enable = true;
defaults = { preview = false; };
extensions.fzf-native.enable = true;
};
cmp = {
enable = true;
autoEnableSources = true;
settings = {
mapping.__raw = "cmp.mapping.preset.insert({})";
sources = [
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "buffer"; }
];
};
cmdline = {
":" = {
mapping = { __raw = "cmp.mapping.preset.cmdline()"; };
sources = [
{ name = "path"; }
{ name = "cmdline"; }
];
};
};
};
treesitter = {
enable = true;
indent = true;
};
# rust
rustaceanvim = {
enable = true;
};
};
plugins.which-key = {
enable = true;
keyLabels = {
"<space>" = "SPC";
"<cr>" = "RET";
"<tab>" = "TAB";
};
registrations = {
"<leader>g" = "Git";
"<leader>f" = "Files";
};
};
globals.mapleader = " ";
keymaps = [
{ key = ";"; action = ":"; }
{ key = "q;"; action = "q:"; }
{ key = "<leader>y"; action = "\"+y"; }
{ key = "<leader>Y"; action = "\"+Y"; }
{ key = "<leader>p"; action = "\"+p"; }
{ key = "<leader>P"; action = "\"+P"; }
{ key = "<leader>w"; action = "<cmd>w<cr>"; }
{ key = "<leader>q"; action = "<cmd>q<cr>"; }
{ key = "<esc>"; action = "<cmd>nohlsearch<cr>"; mode = "n"; }
# root level leader commands
{
key = "<leader><space>";
action = "<cmd>Telescope find_files<cr>";
options = { desc = "Find files in project"; };
}
{
key = "<leader>/";
action = "<cmd>Telescope live_grep<cr>";
options = { desc = "Search project"; };
}
{
key = "<leader><tab>";
action = "<cmd>NERDTreeToggle<cr>";
options = { desc = "Toggle NERDTree"; };
}
# file commands
{
key = "<leader>fl";
action = "<cmd>NERDTreeFind<cr>";
options = { desc = "Locate file"; };
}
# git
{
key = "<leader>gs";
action = "<cmd>Git<cr>";
options = { desc = "Status"; };
}
{
key = "<leader>gp";
action = "<cmd>Git push<cr>";
options = { desc = "Push"; };
}
{
key = "<leader>gP";
action = "<cmd>Git push --force-with-lease<cr>";
options = { desc = "Push (force with lease)"; };
}
{
key = "<leader>gf";
action = "<cmd>Git fetch<cr>";
options = { desc = "Fetch"; };
}
# git rebase
{
key = "<leader>gro";
action = "<cmd>Git rebase origin/main<cr>";
options = { desc = "origin/main"; };
}
{
key = "<leader>grO";
action = "<cmd>Git rebase --interactive origin/main<cr>";
options = { desc = "-i origin/main"; };
}
{
key = "<leader>grm";
action = "<cmd>Git rebase origin/master<cr>";
options = { desc = "origin/master"; };
}
{
key = "<leader>grM";
action = "<cmd>Git rebase --interactive origin/master<cr>";
options = { desc = "-i origin/master"; };
}
];
# TODO: move this into Nix
extraConfigLuaPost = ''
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
end,
})
'';
};
}

View file

@ -0,0 +1 @@
{ }

View file

@ -0,0 +1,186 @@
{ pkgs, ... }:
{
home = {
username = "sloane";
homeDirectory = "/Users/sloane";
stateVersion = "23.11";
packages = with pkgs; [
jq
zoxide
yadm
devenv
watchman
];
sessionVariables = {
EDITOR = "nvim";
KERL_CONFIGURE_OPTIONS="--with-ssl=/opt/homebrew/opt/openssl@3";
};
};
programs.fish = {
enable = true;
interactiveShellInit = ''
fish_vi_key_bindings
zoxide init fish | source
if not set -q TMUX
set -g TMUX tmux new-session -d -s default
eval $TMUX
tmux attach-session -d -t default
end
'';
shellInitLast = ''
if test -d /opt/homebrew
/opt/homebrew/bin/brew shellenv | source
end
mise activate fish | source
'';
plugins = [
{
name = "hydro";
src = pkgs.fetchFromGitHub {
owner = "jorgebucaran";
repo = "hydro";
rev = "41b46a05c84a15fe391b9d43ecb71c7a243b5703";
hash = "sha256-zmEa/GJ9jtjzeyJUWVNSz/wYrU2FtqhcHdgxzi6ANHg=";
};
}
];
shellAbbrs = {
vim = "nvim";
cat = "bat";
# git
g = "git";
ga = "git add";
gb = "git branch";
gc = "git commit";
gcb = "git checkout -b";
gco = "git checkout";
gd = "git diff";
gf = "git fetch";
gp = "git push";
gP = "git push --force-with-lease";
gpl = "git pull";
gplr = "git pull --rebase ";
gr = "git rebase";
grr = "git rebase --continue";
gst = "git status";
gca = "git commit -a";
};
};
programs.git = {
enable = true;
userName = "sloane";
userEmail = "1699281+sloanelybutsurely@users.noreply.github.com";
signing = {
signByDefault = true;
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0TH2GezEx8+zlKBqUb7rBsbmghnd1u4nX6YpQr28Zw";
};
extraConfig = {
init.defaultBranch = "main";
push.autoSetupRemote = true;
gpg = {
format = "ssh";
ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
};
};
};
programs.jujutsu = {
enable = true;
settings = {
core.fsmonitor = pkgs.watchman;
user = {
name = "sloane";
email = "1699281+sloanelybutsurely@users.noreply.github.com";
};
signing = {
sign-all = true;
backend = "ssh";
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0TH2GezEx8+zlKBqUb7rBsbmghnd1u4nX6YpQr28Zw";
backends.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
};
ui.paginate = "never";
};
};
programs.ssh = {
enable = true;
matchBlocks = {
"*" = {
extraOptions.IdentityAgent = ''"~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"'';
};
};
};
programs.tmux = {
enable = true;
keyMode = "vi";
shortcut = "a";
extraConfig = ''
# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
'';
plugins = with pkgs.tmuxPlugins; [
sensible
prefix-highlight
vim-tmux-navigator
{
plugin = catppuccin;
extraConfig = "set -g @catppuccin_flavour 'frappe'";
}
];
};
programs.home-manager.enable = true;
programs.mise = {
enable = true;
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.kitty = {
enable = true;
font = {
name = "Cousine Nerd Font Mono Regular";
size = 18;
};
settings = {
confirm_os_window_close = 0;
paste_actions = "quote-urls-at-prompt,confirm-if-large";
};
theme = "Catppuccin-Frappe";
};
programs.bat.enable = true;
programs.eza ={
enable = true;
git = true;
icons = true;
enableFishIntegration = true;
extraOptions = [
"--group-directories-first"
"--header"
];
};
programs.fzf.enable = true;
programs.gh = {
enable = true;
settings = {
git_protocol = "ssh";
};
};
programs.ripgrep = {
enable = true;
arguments = [];
};
}