Merge pull request #14 from DannyDannyDanny/feat/darwin-home-manager

Darwin + Nix w/ home manager
This commit is contained in:
Daniel Thoren 2025-09-09 21:58:13 +02:00 committed by GitHub
commit 47a69c10fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 215 additions and 31 deletions

81
nixos/flake.lock generated
View file

@ -3,11 +3,11 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1733328505, "lastModified": 1747046372,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -34,17 +34,58 @@
"type": "github" "type": "github"
} }
}, },
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1757443987,
"narHash": "sha256-T7E4CIsZBUzrUcPRyTG9FA2xd48MtbQ/HpIaaCfwZwc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "d587e11cef9caa9484ed090eddc55f4c56908342",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1757430124,
"narHash": "sha256-MhDltfXesGH8VkGv3hmJ1QEKl1ChTIj9wmGAFfWj/Wk=",
"owner": "nix-darwin",
"repo": "nix-darwin",
"rev": "830b3f0b50045cf0bcfd4dab65fad05bf882e196",
"type": "github"
},
"original": {
"owner": "nix-darwin",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"nixos-wsl": { "nixos-wsl": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1736095716, "lastModified": 1757427959,
"narHash": "sha256-csysw/Szu98QDiA2lhWk9seYOyCebeVEWL89zh1cduM=", "narHash": "sha256-p0i07rLfAMzJWYfsjFOXEtIWeS1EGVxJaCi9gfyCwRE=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NixOS-WSL", "repo": "NixOS-WSL",
"rev": "63c3b4ed1712a3a0621002cd59bfdc80875ecbb0", "rev": "785f1b67b6c53de088f640f2a7da50ca4b2d7161",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -56,32 +97,32 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1733384649, "lastModified": 1757068644,
"narHash": "sha256-K5DJ2LpPqht7K76bsxetI+YHhGGRyVteTPRQaIIKJpw=", "narHash": "sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "190c31a89e5eec80dd6604d7f9e5af3802a58a13", "rev": "8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-24.05", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1737062831, "lastModified": 1757034884,
"narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=", "narHash": "sha256-PgLSZDBEWUHpfTRfFyklmiiLBE1i1aGCtz4eRA3POao=",
"owner": "nixos", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c", "rev": "ca77296380960cd497a765102eeb1356eb80fed0",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -102,6 +143,8 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixos-wsl": "nixos-wsl", "nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"vscode-server": "vscode-server" "vscode-server": "vscode-server"
@ -128,11 +171,11 @@
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1729422940, "lastModified": 1753541826,
"narHash": "sha256-DlvJv33ml5UTKgu4b0HauOfFIoDx6QXtbqUF3vWeRCY=", "narHash": "sha256-foGgZu8+bCNIGeuDqQ84jNbmKZpd+JvnrL2WlyU4tuU=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixos-vscode-server", "repo": "nixos-vscode-server",
"rev": "8b6db451de46ecf9b4ab3d01ef76e59957ff549f", "rev": "6d5f074e4811d143d44169ba4af09b20ddb6937d",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -1,17 +1,17 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
vscode-server.url = "github:nix-community/nixos-vscode-server"; vscode-server.url = "github:nix-community/nixos-vscode-server";
# nix-darwin for macOS
# (follows nixpkgs so both use the same channel)
nix-darwin.url = "github:nix-darwin/nix-darwin/master"; nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
# for later home-manager.url = "github:nix-community/home-manager";
# home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
# home-manager.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { outputs = {
@ -20,7 +20,7 @@
vscode-server, vscode-server,
nix-darwin, nix-darwin,
self, self,
# home-manager, home-manager,
... ...
}: { }: {
nixosConfigurations = { nixosConfigurations = {
@ -57,11 +57,21 @@
darwinConfigurations."Daniel-Macbook-Air" = nix-darwin.lib.darwinSystem { darwinConfigurations."Daniel-Macbook-Air" = nix-darwin.lib.darwinSystem {
modules = [ modules = [
./hosts/macos.nix ./hosts/macos.nix
# TODO: nix-darwin lacks tmux options; move to Home Manager.x
# ./tmux.nix
# TODO: add neovim via homemanager, that should work the same for NixOS as Nix-Darwin
# ./neovim.nix # NOTE: Option only exists on NixOS.
./fish.nix ./fish.nix
# Home Manager on macOS
home-manager.darwinModules.home-manager
({ lib, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.danny = { ... }: {
# Force an absolute path even if another module sets a bad value.
home.username = "danny";
home.homeDirectory = lib.mkForce "/Users/danny";
imports = [ ./home/danny/home.nix ];
};
})
]; ];
}; };
}; };

132
nixos/home/danny/home.nix Normal file
View file

@ -0,0 +1,132 @@
{ pkgs, ... }:
{
# TODO: remove next two lines from here or from flake.nix
# home.username = "danny";
# home.homeDirectory = "/Users/danny";
programs.home-manager.enable = true;
# Neovim (user-level, works great on macOS)
programs.neovim = {
enable = true;
defaultEditor = true;
# extraLuaConfig is also available; well keep your Vimscript as-is:
extraConfig = ''
set title
set go=a
set mouse=a
set nohlsearch
set number
let mapleader=","
lua << EOF
local config_file = os.getenv("HOME")..'/.local/share/nvim_color_scheme'
local f = io.open(config_file, "r")
if f ~= nil then
local system_theme = f:read()
io.close(f)
if system_theme == 'dark' then
vim.cmd("set bg=dark")
elseif system_theme == 'light' then
vim.cmd("set bg=light")
else
print('warning: expected value "light" or "dark"')
print(' got:', system_theme)
print(' expected path:', config_file)
end
else
print('warning: nvim color scheme not found')
print(' expected path:', config_file)
end
EOF
colorscheme catppuccin " catppuccin-latte, catppuccin-frappe, catppuccin-macchiato, catppuccin-mocha
" netrw (dir listing) settings
let g:netrw_liststyle = 3
let g:netrw_banner = 0
let g:netrw_browse_split = 3
let g:netrw_winsize = 25 " % of page
set listchars=tab:\ ,space:·,nbsp:,trail:,eol:,precedes:«,extends:»
set clipboard+=unnamedplus
" Replace-all is aliased to S.
nnoremap S :%s//g<Left><Left>
" save file with ,w
map <leader>w :w<cr><Space>
" spellcheck
set spell spelllang=en_us
setlocal spell! spelllang=en_us
'';
plugins = with pkgs.vimPlugins; [
vim-surround
vim-gitgutter
vim-nix
vimtex
fzf-vim
nerdtree
rainbow
catppuccin-nvim
goyo-vim
limelight-vim
];
};
# tmux (user-level; same config on macOS and NixOS if you reuse this file)
programs.tmux = {
enable = true;
# Keep portable things in extraConfig:
extraConfig = ''
# remap prefix from ^B to Alt-f
unbind C-b
set -g prefix M-f
bind M-f send-prefix
# nvim 'checkhealth' advice
set -g focus-events on
set -sa terminal-overrides ',xterm-256color:RGB'
set -g default-terminal "screen-256color"
# indices
set -g base-index 1
set -g pane-base-index 1
# sensible defaults
set -g mouse on
setw -g mode-keys vi
set -g history-limit 100000
set -g escape-time 20
# pane movement shortcuts
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# window selection
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# split with dash and vbar
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
'';
plugins = with pkgs.tmuxPlugins; [
catppuccin
tmux-fzf
extrakto
];
};
# TODO: Put user-installed binaries here if you want HM to own them (optional)
# home.packages = with pkgs; [
# ];
# First HM version for this user config; bump only if you understand the migration notes.
home.stateVersion = "24.11";
}

View file

@ -64,7 +64,6 @@
fzf fzf
cowsay cowsay
lolcat lolcat
neovim
]; ];
# Keep for darwin as well (tracks defaults across upgrades) # Keep for darwin as well (tracks defaults across upgrades)