Migrate to nix flakes
This commit is contained in:
parent
e88bd7593f
commit
e237c5dd4b
8 changed files with 326 additions and 201 deletions
23
README.md
23
README.md
|
@ -1,14 +1,19 @@
|
|||
# Spotlight's dotfiles
|
||||
On devices I consider personal, I like having a similar style within zsh. I heavily utilize macOS, BSD and various Linux, so it's important that these dotfiles work consistently across them all.
|
||||
I heavily utilize macOS, BSD and various Linux distributions, so it's important that these dotfiles work consistently across them all.
|
||||
|
||||
I make heavy usage of Git submodules. Occasionally, these are updated. Please ensure when pulling my dotfiles that you also `git submodule update`.
|
||||
As such, I utilize [Nix](https://nixos.org) with [home-manager](https://github.com/nix-community/home-manager).
|
||||
|
||||
|
||||
## Expectations
|
||||
Please don't consider this a great basis for your own configuration - it works well for me!
|
||||
As such, some things may make assumptions you would not as well :)
|
||||
|
||||
## Installation
|
||||
```
|
||||
git clone --recursive https://git.joscomputing.space/spotlight/dotfiles ~/.dotfiles
|
||||
cp ~/.dotfiles/dotfilesrc ~/.dotfilesrc
|
||||
pip3 install dotfiles
|
||||
dotfiles --sync --force
|
||||
```
|
||||
This may require things to be adapted based on the platform.
|
||||
|
||||
This creates a symbolic link from any file or directory within `~/.dotfiles/` to their respective place in `~/`. I prefer the `.dotfilesrc` to be managed as well.
|
||||
```
|
||||
git clone https://git.joscomputing.space/spotlight/dotfiles ~/.config/home-manager
|
||||
# Or as otherwise described for flake usage within the Home Manager manual:
|
||||
# https://nix-community.github.io/home-manager/index.html#sec-flakes-standalone
|
||||
nix run home-manager/master -- init --switch
|
||||
```
|
||||
|
|
48
flake.lock
generated
Normal file
48
flake.lock
generated
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"nodes": {
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688409282,
|
||||
"narHash": "sha256-nnVCN5QiZ5+DEc70PRQLEcxqlxtsmeBU1BnpsRPUJlA=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "c24deeca64538dcbc589ed8da9146e4ca9eb85b7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1688231357,
|
||||
"narHash": "sha256-ZOn16X5jZ6X5ror58gOJAxPfFLAQhZJ6nOUeS4tfFwo=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "645ff62e09d294a30de823cb568e9c6d68e92606",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"home-manager": "home-manager",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
51
flake.nix
Normal file
51
flake.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
description = "Spotlight's dotfiles";
|
||||
|
||||
inputs = {
|
||||
# Specify the source of Home Manager and Nixpkgs.
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, home-manager, ... }:
|
||||
let
|
||||
homeManager = { system, specialArgs ? {
|
||||
dotfilesOnly = false;
|
||||
} }:
|
||||
home-manager.lib.homeManagerConfiguration {
|
||||
modules = [
|
||||
./home/home.nix
|
||||
];
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
extraSpecialArgs = specialArgs;
|
||||
};
|
||||
in {
|
||||
packages = {
|
||||
# We currently assume that all x86_64-linux devices only
|
||||
# require dotfiles. For now, this is mostly true :)
|
||||
x86_64-linux.homeConfigurations.spotlight = homeManager {
|
||||
system = "x86_64-linux";
|
||||
specialArgs.dotfilesOnly = true;
|
||||
};
|
||||
|
||||
# Similarly (as of writing), all aarch64 Linux devices are headless
|
||||
# and primarily managed by other distro package managers.
|
||||
# This should likely be dealt with in the future!
|
||||
aarch64-linux.homeConfigurations.spotlight = homeManager {
|
||||
system = "aarch64-linux";
|
||||
specialArgs.dotfilesOnly = true;
|
||||
};
|
||||
|
||||
# For all architecture variants of Darwin, we don't want only dotfiles.
|
||||
aarch64-darwin.homeConfigurations.spot = homeManager {
|
||||
system = "aarch64-darwin";
|
||||
};
|
||||
x86_64-darwin.homeConfigurations.spot = homeManager {
|
||||
system = "x86_64-darwin";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
192
home.nix
192
home.nix
|
@ -1,192 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
# In order to allow reuse of the iTerm2 shell integrations repo
|
||||
# for both its utility symlinks and zsh initialization plugin,
|
||||
# we define how to fetch it here.
|
||||
let
|
||||
iterm2_shell_integration = pkgs.fetchFromGitHub {
|
||||
owner = "gnachman";
|
||||
repo = "iTerm2-shell-integration";
|
||||
rev = "6554045b1184b213fdc9d731a45e8a75858291de";
|
||||
sha256 = "yhgowvJfxVdJE1yVYPWnJYvzhMsPc+HgkmDa++CcTDo=";
|
||||
};
|
||||
in {
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
# TODO(spotlightishere): Is there a cleaner approach?
|
||||
home.username = if pkgs.stdenv.isDarwin then
|
||||
"spot"
|
||||
else
|
||||
"spotlight";
|
||||
|
||||
home.homeDirectory = if pkgs.stdenv.isDarwin then
|
||||
"/Users/spot"
|
||||
else
|
||||
"/home/spotlight";
|
||||
|
||||
home.packages = with pkgs; [
|
||||
cloc
|
||||
croc
|
||||
exiftool
|
||||
ffmpeg
|
||||
go
|
||||
google-cloud-sdk
|
||||
gradle
|
||||
htop
|
||||
imagemagick
|
||||
jadx
|
||||
jdk
|
||||
jq
|
||||
mtr
|
||||
ncdu
|
||||
nixopsUnstable
|
||||
p7zip
|
||||
pngcrush
|
||||
pry
|
||||
protobuf
|
||||
pwgen
|
||||
rustup
|
||||
tmux
|
||||
unar
|
||||
virt-manager
|
||||
watch
|
||||
wget
|
||||
yt-dlp
|
||||
];
|
||||
|
||||
# Git
|
||||
programs.git = {
|
||||
enable = true;
|
||||
lfs.enable = true;
|
||||
|
||||
userName = "Spotlight";
|
||||
userEmail = "spotlight@joscomputing.space";
|
||||
signing = {
|
||||
key = "6EF6CBB6420B81DA3CCACFEA874AA355B3209BDC";
|
||||
signByDefault = true;
|
||||
};
|
||||
extraConfig = {
|
||||
color.ui = "auto";
|
||||
pull.rebase = true;
|
||||
init.defaultBranch = "main";
|
||||
};
|
||||
};
|
||||
|
||||
# GPG
|
||||
programs.gpg.enable = true;
|
||||
home.file.".gnupg/gpg-agent.conf" = lib.mkIf pkgs.stdenv.isDarwin {
|
||||
text = ''
|
||||
pinentry-program "${pkgs.pinentry_mac}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac"
|
||||
'';
|
||||
};
|
||||
|
||||
# password-store
|
||||
programs.password-store = {
|
||||
enable = true;
|
||||
package = pkgs.pass.withExtensions (exts: [exts.pass-otp]);
|
||||
settings = {
|
||||
PASSWORD_STORE_DIR = "${config.home.homeDirectory}/.password-store";
|
||||
};
|
||||
};
|
||||
|
||||
# Very opinionated :)
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
|
||||
# We want several options:
|
||||
autocd = true;
|
||||
history = {
|
||||
ignoreDups = true;
|
||||
ignoreSpace = true;
|
||||
};
|
||||
|
||||
# Common plugins.
|
||||
enableAutosuggestions = true;
|
||||
enableCompletion = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
plugins = with pkgs; [
|
||||
{
|
||||
name = "expand-multiple-dots";
|
||||
src = ./zsh/expand-multiple-dots;
|
||||
file = "expand-multiple-dots.zsh";
|
||||
}
|
||||
{
|
||||
name = "iterm2-shell-integration";
|
||||
src = iterm2_shell_integration;
|
||||
file = "shell_integration/zsh";
|
||||
}
|
||||
{
|
||||
# Our zsh-powerlevel10k configuration file.
|
||||
name = "p10k";
|
||||
src = ./zsh/p10k;
|
||||
file = "p10k.zsh";
|
||||
}
|
||||
];
|
||||
|
||||
# We use powerlevel10k as our ZSH theme.
|
||||
# By using the derivation in nixpkgs, we also get gitstatusd.
|
||||
# The .p10k.zsh config is beneath.
|
||||
initExtraBeforeCompInit = "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
|
||||
};
|
||||
|
||||
programs.vim = {
|
||||
enable = true;
|
||||
# Let's not grab _all_ of Vim.
|
||||
packageConfigurable = pkgs.vim;
|
||||
plugins = with pkgs; [
|
||||
pkgs.vimPlugins.vim-airline
|
||||
pkgs.vimPlugins.vim-airline-themes
|
||||
pkgs.vimPlugins.vim-go
|
||||
];
|
||||
|
||||
settings = {
|
||||
number = true;
|
||||
|
||||
# Two-spaced tabs
|
||||
shiftwidth = 2;
|
||||
tabstop = 2;
|
||||
expandtab = true;
|
||||
};
|
||||
extraConfig = ''
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
set backspace=indent,eol,start
|
||||
|
||||
" assistance with space-oriented tabs
|
||||
set softtabstop=2
|
||||
set smarttab
|
||||
|
||||
" custom filetypes
|
||||
autocmd BufNewFile,BufRead *.plist set syntax=xml
|
||||
|
||||
" vim-airline
|
||||
let g:airline_powerline_fonts = 1
|
||||
'';
|
||||
};
|
||||
|
||||
# We'd like to have the iTerm2 shell integration utilities in ~/.iterm2.
|
||||
home.file.".iterm2".source = "${iterm2_shell_integration}/utilities";
|
||||
|
||||
programs.zsh.initExtra = ''
|
||||
# pushd
|
||||
setopt AUTO_PUSHD
|
||||
|
||||
# History search, but from beginning
|
||||
bindkey "^[[A" history-beginning-search-backward
|
||||
bindkey "^[[B" history-beginning-search-forward
|
||||
'';
|
||||
|
||||
# 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";
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
|
51
home/desktop.nix
Normal file
51
home/desktop.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Commonly used packages.
|
||||
home.packages = with pkgs; [
|
||||
cloc
|
||||
croc
|
||||
exiftool
|
||||
ffmpeg
|
||||
go
|
||||
google-cloud-sdk
|
||||
gradle
|
||||
htop
|
||||
imagemagick
|
||||
jadx
|
||||
jdk
|
||||
jq
|
||||
mtr
|
||||
ncdu
|
||||
nixopsUnstable
|
||||
p7zip
|
||||
pngcrush
|
||||
pry
|
||||
protobuf
|
||||
pwgen
|
||||
rustup
|
||||
tmux
|
||||
unar
|
||||
virt-manager
|
||||
watch
|
||||
wget
|
||||
yt-dlp
|
||||
];
|
||||
|
||||
# GPG
|
||||
programs.gpg.enable = true;
|
||||
home.file.".gnupg/gpg-agent.conf" = lib.mkIf pkgs.stdenv.isDarwin {
|
||||
text = ''
|
||||
pinentry-program "${pkgs.pinentry_mac}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac"
|
||||
'';
|
||||
};
|
||||
|
||||
# password-store
|
||||
programs.password-store = {
|
||||
enable = true;
|
||||
package = pkgs.pass.withExtensions (exts: [exts.pass-otp]);
|
||||
settings = {
|
||||
PASSWORD_STORE_DIR = "${config.home.homeDirectory}/.password-store";
|
||||
};
|
||||
};
|
||||
}
|
37
home/editor.nix
Normal file
37
home/editor.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.vim = {
|
||||
enable = true;
|
||||
# Let's not grab _all_ of Vim.
|
||||
packageConfigurable = pkgs.vim;
|
||||
plugins = with pkgs; [
|
||||
pkgs.vimPlugins.vim-airline
|
||||
pkgs.vimPlugins.vim-airline-themes
|
||||
];
|
||||
|
||||
settings = {
|
||||
number = true;
|
||||
|
||||
# Two-spaced tabs
|
||||
shiftwidth = 2;
|
||||
tabstop = 2;
|
||||
expandtab = true;
|
||||
};
|
||||
extraConfig = ''
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
set backspace=indent,eol,start
|
||||
|
||||
" assistance with space-oriented tabs
|
||||
set softtabstop=2
|
||||
set smarttab
|
||||
|
||||
" custom filetypes
|
||||
autocmd BufNewFile,BufRead *.plist set syntax=xml
|
||||
|
||||
" vim-airline
|
||||
let g:airline_powerline_fonts = 1
|
||||
'';
|
||||
};
|
||||
}
|
60
home/home.nix
Normal file
60
home/home.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{ config, lib, pkgs, specialArgs, ... }:
|
||||
|
||||
let
|
||||
dotfilesOnly = specialArgs.dotfilesOnly;
|
||||
in {
|
||||
# It's standard convention that Darwin has the username
|
||||
# "spot" - "spotlight" was reserved by the system at some point.
|
||||
# (Sigh... the downsides of sharing a namesake.)
|
||||
home.username = if pkgs.stdenv.isDarwin then
|
||||
"spot"
|
||||
else
|
||||
"spotlight";
|
||||
|
||||
home.homeDirectory = if pkgs.stdenv.isDarwin then
|
||||
"/Users/spot"
|
||||
else
|
||||
"/home/spotlight";
|
||||
|
||||
# Git
|
||||
programs.git = {
|
||||
enable = true;
|
||||
lfs.enable = true;
|
||||
|
||||
userName = "Spotlight";
|
||||
userEmail = "spotlight@joscomputing.space";
|
||||
# Only specify signing if GPG is otherwise being pulled in;
|
||||
# i.e. not in a dotfiles only configuration.
|
||||
signing = lib.mkIf dotfilesOnly {
|
||||
key = "6EF6CBB6420B81DA3CCACFEA874AA355B3209BDC";
|
||||
signByDefault = true;
|
||||
};
|
||||
extraConfig = {
|
||||
color.ui = "auto";
|
||||
pull.rebase = true;
|
||||
init.defaultBranch = "main";
|
||||
};
|
||||
};
|
||||
|
||||
# Only include the desktop configuration if not dotfiles only.
|
||||
imports = [
|
||||
# zsh, etc
|
||||
./editor.nix
|
||||
# vim, etc
|
||||
./prompt.nix
|
||||
] ++ (lib.optional (!dotfilesOnly) ./desktop.nix);
|
||||
|
||||
# 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";
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
|
65
home/prompt.nix
Normal file
65
home/prompt.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
# In order to allow reuse of the iTerm2 shell integrations repo
|
||||
# for both its utility symlinks and zsh initialization plugin,
|
||||
# we define how to fetch it here.
|
||||
iterm2_shell_integration = pkgs.fetchFromGitHub {
|
||||
owner = "gnachman";
|
||||
repo = "iTerm2-shell-integration";
|
||||
rev = "6554045b1184b213fdc9d731a45e8a75858291de";
|
||||
sha256 = "yhgowvJfxVdJE1yVYPWnJYvzhMsPc+HgkmDa++CcTDo=";
|
||||
};
|
||||
in {
|
||||
# Very opinionated :)
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
|
||||
# We want several options:
|
||||
autocd = true;
|
||||
history = {
|
||||
ignoreDups = true;
|
||||
ignoreSpace = true;
|
||||
};
|
||||
|
||||
# Common plugins.
|
||||
enableAutosuggestions = true;
|
||||
enableCompletion = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
plugins = with pkgs; [
|
||||
{
|
||||
name = "expand-multiple-dots";
|
||||
src = ../zsh/expand-multiple-dots;
|
||||
file = "expand-multiple-dots.zsh";
|
||||
}
|
||||
{
|
||||
name = "iterm2-shell-integration";
|
||||
src = iterm2_shell_integration;
|
||||
file = "shell_integration/zsh";
|
||||
}
|
||||
{
|
||||
# Our zsh-powerlevel10k configuration file.
|
||||
name = "p10k";
|
||||
src = ../zsh/p10k;
|
||||
file = "p10k.zsh";
|
||||
}
|
||||
];
|
||||
|
||||
# We use powerlevel10k as our ZSH theme.
|
||||
# By using the derivation in nixpkgs, we also get gitstatusd.
|
||||
# The .p10k.zsh config is beneath.
|
||||
initExtraBeforeCompInit = "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
|
||||
|
||||
# Some custom configurations:
|
||||
initExtra = ''
|
||||
# pushd
|
||||
setopt AUTO_PUSHD
|
||||
|
||||
# History search, but from beginning
|
||||
bindkey "^[[A" history-beginning-search-backward
|
||||
bindkey "^[[B" history-beginning-search-forward
|
||||
'';
|
||||
};
|
||||
|
||||
# We'd like to have the iTerm2 shell integration utilities in ~/.iterm2.
|
||||
home.file.".iterm2".source = "${iterm2_shell_integration}/utilities";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue