-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start using home-manager and nix-darwin
* Created Makefile to manage install/uninstall * Created my first flake containing basics Installed the basics from Nix pkgs and linked their configs out of the `files` directory, one day to be replaced with something more Nix-native: * zsh * tmux * neovim Signed-off-by: Stephen Hoekstra <[email protected]>
- Loading branch information
Showing
19 changed files
with
332 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.bundle/ | ||
result | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
NIXPKGS_DIR := $(HOME)/.config/nixpkgs | ||
|
||
.PHONY: default install switch uninstall help | ||
|
||
default: help | ||
|
||
install: install-homebrew ## Install Homebrew and Nix and activate this configuration | ||
@sh -c "'$(CURDIR)/scripts/install.sh'" | ||
|
||
install-homebrew: | ||
@sh -c "'$(CURDIR)/scripts/install_homebrew.sh'" | ||
|
||
switch: ## Activate latest changes | ||
@sh -c "./result/sw/bin/darwin-rebuild switch --flake ./nix" | ||
|
||
uninstall: ## Uninstall Nix | ||
@sh -c "'$(CURDIR)/scripts/uninstall.sh'" | ||
|
||
uninstall-homebrew: | ||
@sh -c "'$(CURDIR)/scripts/uninstall_homebrew.sh'" | ||
|
||
help: ## Display this help screen | ||
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Setup fzf | ||
# --------- | ||
if [[ ! "$PATH" == */usr/local/opt/fzf/bin* ]]; then | ||
export PATH="${PATH:+${PATH}:}/usr/local/opt/fzf/bin" | ||
fi | ||
|
||
# Auto-completion | ||
# --------------- | ||
[[ $- == *i* ]] && source "/usr/local/opt/fzf/shell/completion.zsh" 2> /dev/null | ||
|
||
# Key bindings | ||
# ------------ | ||
source "/usr/local/opt/fzf/shell/key-bindings.zsh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
description = "My first flake"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
|
||
home-manager.url = "github:nix-community/home-manager"; | ||
home-manager.inputs.nixpkgs.follows = "nixpkgs"; | ||
|
||
darwin.url = "github:lnl7/nix-darwin"; | ||
darwin.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, home-manager, darwin }: { | ||
darwinConfigurations."sbpltt6cllvdl" = darwin.lib.darwinSystem { | ||
system = "x86_64-darwin"; | ||
|
||
modules = [ | ||
home-manager.darwinModules.home-manager | ||
./hosts/sbpltt6cllvdl/default.nix | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ pkgs, ... }: | ||
|
||
{ | ||
# Make sure the nix daemon always runs | ||
services.nix-daemon.enable = true; | ||
|
||
# If you use zsh you'll need to enable this so nix-darwin creates a zshrc sourcing needed environment changes | ||
programs.zsh.enable = true; | ||
|
||
homebrew.enable = true; | ||
homebrew.casks = [ | ||
]; | ||
|
||
home-manager.useGlobalPkgs = true; | ||
home-manager.useUserPackages = true; | ||
home-manager.users."shoekstra" = import ./home.nix; | ||
|
||
# This needs to be to set for things to work (see https://github.com/LnL7/nix-darwin/issues/423) | ||
users.users."shoekstra" = { | ||
home = "/Users/shoekstra"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ config, pkgs, ... }: | ||
|
||
let | ||
imports = [ | ||
./nvim.nix | ||
./tmux.nix | ||
./zsh.nix | ||
]; | ||
|
||
in { | ||
|
||
inherit imports; | ||
|
||
# You cannot install or search for an unfree package unless explicitly enabling | ||
# it with the following: | ||
nixpkgs.config.allowUnfree = true; | ||
|
||
# Home Manager needs a bit of information about you and the paths it should | ||
# manage. | ||
home.username = "shoekstra"; | ||
home.homeDirectory = "/Users/shoekstra"; | ||
|
||
# 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 = "22.11"; # Please read the comment before changing. | ||
|
||
home.sessionVariables = { | ||
}; | ||
|
||
# Let Home Manager install and manage itself. | ||
programs.home-manager.enable = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ config, pkgs, ... }: | ||
|
||
{ | ||
home.packages = with pkgs; [ | ||
neovim | ||
(python3.withPackages(ps: with ps; [ pynvim ])) | ||
]; | ||
|
||
home.file = { | ||
".config/nvim".source = ../../../files/neovim; | ||
".config/nvim".recursive = true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ config, pkgs, ... }: | ||
|
||
{ | ||
home.packages = with pkgs; [ | ||
reattach-to-user-namespace | ||
tmux | ||
]; | ||
|
||
home.file = { | ||
".tmux".source = pkgs.fetchFromGitHub { | ||
owner = "gpakosz"; | ||
repo = ".tmux"; | ||
rev = "7706ab724f3811479a358c6f9ea6aeb6decece5f"; | ||
sha256 = "sha256-o126SathIT49Mj9EZDhlYF5i3EgRe2HFZkoGXTVQBbw="; | ||
}; | ||
|
||
".tmux.conf".source = config.lib.file.mkOutOfStoreSymlink "/Users/shoekstra/.tmux/.tmux.conf"; | ||
".tmux.conf.local".source = ../../../files/tmux/tmux.conf.local; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ config, pkgs, ... }: | ||
|
||
{ | ||
|
||
# Use existing dotfiles until moving to a nix native way of managing zsh. | ||
home.file = { | ||
".fzf.zsh".source = ../../../files/zsh/fzf.zsh; | ||
".p10k.zsh".source = ../../../files/zsh/p10k.zsh; | ||
".zaliases".source = ../../../files/zsh/zaliases; | ||
".zfunctions".source = ../../../files/zsh/zfunctions; | ||
".zimrc".source = ../../../files/zsh/zimrc; | ||
".zsh-dircolors.config".source = ../../../files/zsh/zsh-dircolors.config; | ||
".zshenv".source = ../../../files/zsh/zshenv; | ||
".zshrc".source = ../../../files/zsh/zshrc; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "==> Installing Nix..." | ||
|
||
for file in /etc/*.backup-before-nix; do | ||
[ -e "${file}" ] && sudo rm -v ${file} | ||
done | ||
|
||
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install | ||
|
||
echo "==> Running first build..." | ||
|
||
# Initial build | ||
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh | ||
nix build "./nix#darwinConfigurations.$(hostname).system" --extra-experimental-features "nix-command flakes" | ||
|
||
# Manual steps for nix-darwin to work with flakes | ||
grep -q "private/var/run" /etc/synthetic.conf || printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf | ||
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t | ||
|
||
for file in /etc/bashrc /etc/nix/nix.conf /etc/zshrc; do | ||
[ -e "${file}" ] && sudo mv ${file} ${file}.before-nix-darwin | ||
done | ||
|
||
echo "==> Running first switch..." | ||
|
||
./result/sw/bin/darwin-rebuild switch --flake ./nix | ||
|
||
grep -q "/etc/static/zshrc" /etc/zshrc || echo 'if test -e /etc/static/zshrc; then . /etc/static/zshrc; fi' | sudo tee -a /etc/zshrc | ||
|
||
echo "==> Setup complete!" | ||
echo "Run \"darwin-rebuild switch --flake ./nix\" to rebuild your configuration after any changes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "==> Installing homebrew..." | ||
|
||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
Oops, something went wrong.