-
-
Save crasm/59938f3364d2df6319604a5f3fb927fb to your computer and use it in GitHub Desktop.
230627 home.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
{ config, pkgs, lib, ... }: | |
let | |
isLinux = pkgs.stdenv.hostPlatform.isLinux; | |
isDarwin = pkgs.stdenv.hostPlatform.isDarwin; | |
unsupported = builtins.abort "Unsupported platform"; | |
homeDir = "${config.home.homeDirectory}"; | |
stuffDir = | |
if isLinux then "/stuff" else | |
if isDarwin then "${homeDir}/stuff" else unsupported; | |
hmDir = "${stuffDir}/nix/home-manager"; | |
in | |
{ | |
imports = [ | |
./fonts.nix | |
./neovim.nix | |
]; | |
home.username = "vczf"; | |
home.homeDirectory = | |
if isLinux then "/home/vczf" else | |
if isDarwin then "/Users/vczf" else unsupported; | |
home.stateVersion = "23.05"; # Don't change this | |
programs.home-manager.enable = true; | |
home.packages = with pkgs; ([ | |
# Common packages | |
any-nix-shell | |
bat | |
htop | |
mosh | |
nixpkgs-fmt | |
stow | |
tree | |
zsh-vi-mode | |
] ++ lib.optionals isLinux [ | |
# GNU/Linux packages | |
nmon | |
trashy | |
xfsprogs | |
xsel | |
] | |
++ lib.optionals isDarwin [ | |
# macOS packages | |
gnused | |
]); | |
home.shellAliases = { | |
h = "cd ${hmDir}"; | |
he = "cd ${hmDir}; home-manager edit"; | |
hs = "home-manager switch --impure"; | |
userctl = "systemctl --user"; | |
open = | |
if isLinux then "xdg-open" else | |
if isDarwin then "open" else unsupported; | |
}; | |
home.sessionVariables = { }; | |
xdg.configFile = { | |
"nixpkgs/config.nix".text = "{ allowUnfree = true; }"; # There may be a better way to do this directly in the flake | |
"paru/paru.conf" = { | |
enable = isLinux; | |
text = '' | |
[options] | |
CloneDir = "${stuffDir}/aur" | |
''; | |
}; | |
}; | |
programs.ssh = { | |
enable = true; | |
package = pkgs.openssh; | |
matchBlocks = { | |
"yoga" = { | |
user = "vczf"; | |
identityFile = "~/.ssh/keys/yoga"; | |
}; | |
"github.com" = { | |
user = "git"; | |
identityFile = "~/.ssh/keys/gh"; | |
}; | |
}; | |
extraOptionOverrides = { | |
"AddKeysToAgent" = "yes"; | |
}; | |
}; | |
home.file = with config.lib.file; { | |
# I can't link .ssh/ directly because it .ssh/config is generated by nix | |
# ``` | |
# error: builder for [...] failed with exit code 1; | |
# last 1 log lines: | |
# > Error installing file '.ssh/config' outside $HOME | |
# ``` | |
# ".ssh/" = { | |
# source = mkOutOfStoreSymlink "${hmDir}/ssh"; | |
# recursive = true; | |
# }; | |
".ssh/keys" = { | |
source = mkOutOfStoreSymlink "${hmDir}/ssh/keys"; | |
recursive = true; | |
}; | |
".ssh/authorized_keys".source = mkOutOfStoreSymlink "${hmDir}/ssh/authorized_keys"; | |
".ssh/known_hosts".source = mkOutOfStoreSymlink "${hmDir}/ssh/known_hosts"; | |
}; | |
programs.zsh = { | |
enable = true; | |
enableAutosuggestions = true; | |
enableSyntaxHighlighting = true; | |
enableVteIntegration = true; | |
autocd = true; | |
# historySubstringSearch = { enable = true; }; | |
plugins = [ | |
# { | |
# name = "zsh-nix-shell"; | |
# file = "nix-shell.plugin.zsh"; | |
# src = pkgs.fetchFromGitHub { | |
# owner = "chisui"; | |
# repo = "zsh-nix-shell"; | |
# rev = "v0.7.0"; | |
# sha256 = "0za4aiwwrlawnia4f29msk822rj9bgcygw6a8a6iikiwzjjz0g91"; | |
# }; | |
# } | |
]; | |
oh-my-zsh = { | |
enable = true; | |
theme = "bira"; | |
# theme = "simple"; | |
# theme = "pure"; | |
plugins = [ | |
"ssh-agent" | |
]; | |
}; | |
initExtra = builtins.concatStringsSep "\n" [ | |
(builtins.readFile "${hmDir}/zsh/nnn.sh") | |
'' | |
chpwd () { | |
ls | |
} | |
any-nix-shell zsh --info-right | source /dev/stdin | |
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh | |
'' | |
]; | |
}; | |
programs.git = { | |
enable = true; | |
lfs.enable = true; | |
lfs.skipSmudge = true; | |
includes = [{ | |
contents.user.name = "crasm"; | |
contents.user.email = "crasm@git.vczf.us"; | |
}]; | |
}; | |
programs.nnn = { | |
enable = true; | |
bookmarks = { | |
h = "~"; | |
s = | |
if isLinux then "/stuff" else | |
if isDarwin then "~/stuff" else unsupported; | |
}; | |
}; | |
programs.tmux = { | |
enable = true; | |
keyMode = "vi"; | |
extraConfig = '' | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
''; | |
}; | |
programs.direnv.enable = true; | |
programs.direnv.nix-direnv.enable = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment