Big reorg based on malob

work
Matthew Ess 2022-09-15 17:17:21 -04:00
parent 859d5488e5
commit a79991d5c9
18 changed files with 217 additions and 271 deletions

View File

@ -6,7 +6,7 @@ spiritually a fork of https://github.com/malob/nixpkgs, but using a repo i alrea
## installation
```shell
$ nix build .#darwinConfigurations.matbook.system
$ nix build .#configurations.matbook.system
$ ./result/sw/bin/darwin-rebuild switch --flake .
```

View File

@ -1,40 +0,0 @@
syntax on
filetype plugin indent on
set cursorline "highlight current line
set showmatch "highlight matching [{()}]
set tabstop=2 "number of visual spaces per TAB when reading
set softtabstop=2 "number of spaces per TAB when editing
set expandtab "tabs are spaces
set shiftwidth=2 "indents
set ww=<,>,[,] "wrap
set splitbelow "split underneath
set splitright "split to the right
command Mks NERDTreeClose | mksession!
command Term split | term
command Vterm vsplit | term
"save readonly
cmap w!! w !sudo tee >/dev/null %
"terminal exit
tnoremap <Esc> <C-\><C-n><CR>
"nohl
nnoremap <silent> ,<space> :nohlsearch<CR>
colorscheme tokyonight
let g:lightline = {'colorscheme': 'tokyonight'}
"cursor saving
autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
"nerdtree
"show hidden files
let NERDTreeShowHidden=1
"open on vim open
"autocmd vimenter * NERDTree
"switch to editing window
"autocmd vimenter * wincmd p
"close if only nerdtree is left
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"show/hide nerdtree
nnoremap <silent> <c-b> :NERDTreeToggle<CR>

View File

@ -1,7 +0,0 @@
{ system ? builtins.currentSystem
, nixpkgs ? ./nixpkgs.nix
, pkgs ? import nixpkgs { inherit system; }
, lib ? pkgs.lib
, ...
}@args:
import (import ./default.nix).inputs.darwin args

View File

@ -2,36 +2,40 @@
{
# Nix configuration ------------------------------------------------------------------------------
nix.settings.trusted-substituters = [
"https://cache.nixos.org/"
"https://hydra.iohk.io"
"https://cache.iog.io"
"https://nix-community.cachix.org"
"https://mat.cachix.org"
];
nix.settings.trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"mat.cachix.org-1:AHqv9SoBEPKlJX2DDZQnjaMcvBAgpH1j8rw5USYDZno="
];
nix.settings.trusted-users = [
"@admin"
];
nix.settings = {
trusted-substituters = [
"https://cache.nixos.org/"
"https://hydra.iohk.io"
"https://cache.iog.io"
"https://nix-community.cachix.org"
"https://mat.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"mat.cachix.org-1:AHqv9SoBEPKlJX2DDZQnjaMcvBAgpH1j8rw5USYDZno="
];
trusted-users = [
"@admin"
];
auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ];
extra-platforms = lib.mkIf (pkgs.system == "aarch64-darwin") [ "x86_64-darwin" "aarch64-darwin" ];
};
nix.configureBuildUsers = true;
# Enable experimental nix command and flakes
nix.extraOptions = ''
auto-optimise-store = true
experimental-features = nix-command flakes
'' + lib.optionalString (pkgs.system == "aarch64-darwin") ''
extra-platforms = x86_64-darwin aarch64-darwin
'';
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# Make Fish the default shell
environment.shells = with pkgs; [
bashInteractive
fish
zsh
];
programs.fish.enable = true;
programs.fish.useBabelfish = true;
programs.fish.babelfishPackage = pkgs.babelfish;

View File

@ -0,0 +1,21 @@
{
# dark-mode-notify configuration
# {{{
launchd.enable = true;
launchd.agents.dark-mode-notify = {
enable = true;
config = {
Label = "ke.bou.dark-mode-notify";
KeepAlive = true;
StandardErrorPath = null;
StandardOutPath = null;
ProgramArguments = [
"${pkgs.dark-mode-notify}/bin/dark-mode-notify"
"${pkgs.fish}/bin/fish"
"-c"
"set-background-to-env DARKMODE"
];
};
};
# }}}
}

View File

@ -2,10 +2,7 @@
{
system.defaults.NSGlobalDomain = {
# "com.apple.trackpad.scaling" = "3.0";
# AppleInterfaceStyleSwitchesAutomatically = false;
# InitialKeyRepeat = 15;
# KeyRepeat = 2;
AppleInterfaceStyleSwitchesAutomatically = true;
NSAutomaticCapitalizationEnabled = false;
_HIHideMenuBar = false;
};

View File

@ -1,30 +1,13 @@
{ config, pkgs, lib, ... }:
{
imports = [
./bootstrap.nix
./homebrew.nix
./macos-defaults.nix
];
# Apps
# `home-manager` currently has issues adding them to `~/Applications`
# Issue: https://github.com/nix-community/home-manager/issues/1341
# See workaround at ../home/copyApplications.nix
environment.systemPackages = with pkgs; [
discord-ptb
element-desktop
# firefox *
kitty
lagrange
# mullvad-vpn *
obsidian
# signal-desktop *
slack
# steam *
terminal-notifier
# zoom-us *
# *no nixpkgs darwin support T.T
];
# https://github.com/nix-community/home-manager/issues/423
@ -33,11 +16,6 @@
};
programs.nix-index.enable = true;
environment.shells = with pkgs; [
bashInteractive
fish
zsh
];
# Fonts
fonts.fontDir.enable = true;
fonts.fonts = with pkgs; [

View File

@ -61,17 +61,22 @@ in
"alfred"
"bartender"
# "cursorcerer"
"discord"
"element"
"firefox"
"jitsi-meet"
"knockknock"
"lagrange"
"logitech-options"
"lulu"
"macsvg"
"miniforge"
# "mullvadvpn"
"obsidian"
"rectangle"
"secretive"
"signal"
"slack"
"stay"
"transmission"
# "twitch"
@ -87,7 +92,7 @@ in
# Configuration related to casks
environment.variables.SSH_AUTH_SOCK = mkIfCaskPresent "secretive"
"/Users/${config.users.primaryUser}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
"/Users/${config.users.primaryUser.username}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
# For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be
# installed in `../home/default.nix` whenever possible.

134
flake.nix
View File

@ -59,43 +59,44 @@
attrValues
genAttrs
makeOverridable
optional
optionalAttrs
singleton;
optionalAttrs;
# Configuration for `nixpkgs`
nixpkgsConfig = {
config = { allowUnfree = true; };
overlays = attrValues self.overlays ++ singleton (
final: prev:
let
pkgs = import ./pkgs {
inherit inputs genAttrs;
inherit (final) callPackage;
inherit (final.stdenv) system;
};
in
pkgs // optionalAttrs (prev.stdenv.system == "aarch64-darwin")
{
# Sub in x86 version of packages that don't build on Apple Silicon yet
inherit (final.pkgs-x86);
}
);
overlays = attrValues self.overlays ++ [
(final: prev:
import ./pkgs {
inherit inputs genAttrs;
inherit (final) callPackage;
inherit (final.stdenv) system;
})
(final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin")
{
# Sub in x86 version of packages that don't build on Apple Silicon yet
inherit (final.pkgs-x86);
})
];
};
# Shared home-manager configs
homeManagerStateVersion = "22.05";
homeManagerCommonConfig = {
imports = attrValues self.homeManagerModules ++ [
./home
{ home.stateVersion = homeManagerStateVersion; }
];
primaryUserInfo = {
username = "mat";
fullName = "mat ess";
email = "mat@mat.services";
nixConfigDirectory = "/Users/mat/dotfiles.nix";
};
workUserInfo = {
username = "mess";
fullName = "Matthew Ess";
email = "mess@yelp.com";
nixConfigDirectory = "/Users/mess/dotfiles.nix";
};
# Modules shared by most `nix-darwin` personal configurations.
nixDarwinCommonModules = attrValues self.darwinModules ++ [
# Main `nix-darwin` config
./darwin
# `home-manager` module
home-manager.darwinModules.home-manager
(
@ -105,15 +106,20 @@
in
{
nixpkgs = nixpkgsConfig;
# Hack to support legacy worklows that use `<nixpkgs>` etc.
# Hack to support legacy worklows that use `<nixpkgs>`, darwin-option, etc.
nix.nixPath = {
nixpkgs = "$HOME/dotfiles.nix/nixpkgs.nix";
darwin = "$HOME/dotfiles.nix/darwin.nix";
nixpkgs = "${inputs.nixpkgs-unstable}";
darwin = "${inputs.darwin}";
};
# `home-manager` config
users.users.${primaryUser}.home = "/Users/${primaryUser}";
users.users.${primaryUser.username}.home = "/Users/${primaryUser.username}";
home-manager.useGlobalPkgs = true;
home-manager.users.${primaryUser} = homeManagerCommonConfig;
home-manager.users.${primaryUser.username} = {
imports = attrValues self.homeManagerModules;
home.stateVersion = homeManagerStateVersion;
home.primaryUser = primaryUser;
home.enableNixpkgsReleaseCheck = true;
};
# Add a registry entry for this flake
nix.registry.my.flake = self;
}
@ -135,7 +141,7 @@
system = "aarch64-darwin";
modules = nixDarwinCommonModules ++ [
({ pkgs, ... }: {
users.primaryUser = "mat";
users.primaryUser = primaryUserInfo;
networking.computerName = "matbook pro m1";
networking.hostName = "matbook";
networking.knownNetworkServices = [
@ -153,8 +159,6 @@
programs.fish.shellAliases = {
code = "${pkgs.vscodium}/bin/codium";
};
programs.git.userEmail = "mat@mat.services";
programs.git.userName = "mat ess";
programs.ssh.matchBlocks.remarkable = {
hostname = "10.11.99.1";
user = "root";
@ -170,7 +174,7 @@
system = "aarch64-darwin";
modules = nixDarwinCommonModules ++ [
({ pkgs, ... }: {
users.primaryUser = "mess";
users.primaryUser = workUserInfo;
networking.knownNetworkServices = [
"Wi-Fi"
];
@ -184,8 +188,6 @@
];
homebrew.casks = [ "itsycal" ];
home-manager.sharedModules = [{
programs.git.userEmail = "mess@yelp.com";
programs.git.userName = "Matthew Ess";
programs.ssh.matchBlocks.devbox = {
hostname = "amp1";
forwardAgent = true;
@ -204,22 +206,35 @@
system = "x86_64-darwin";
modules = nixDarwinCommonModules ++ [
({ lib, ... }: {
users.primaryUser = "runner";
users.primaryUser = primaryUserInfo // {
username = "runner";
nixConfigDirectory = "/Users/runner/work/nixpkgs/nixpkgs";
};
homebrew.enable = lib.mkForce false;
})
];
};
# Build and activate with `nix build .#cloudVM.activationPackage; ./result/activate`
};
# Build and activate on new system with:
# `nix build .#homeConfigurations.<name>.activationPackage; ./result/activate`
homeConfigurations = rec {
cloudVM = home-manager.lib.homeManagerConfiguration {
system = "x86_64-linux";
stateVersion = homeManagerStateVersion;
homeDirectory = "/home/mat";
username = "mat";
configuration = {
imports = [ homeManagerCommonConfig ];
nixpkgs = nixpkgsConfig;
pkgs = import inputs.nixpkgs-unstable {
system = "x86_64-linux";
inherit (nixpkgsConfig) config overlays;
};
modules = attrValues self.homeManagerModules ++ [
({ config, ... }: {
home.username = config.home.primaryUser.username;
home.homeDirectory = "/home/${config.home.username}";
home.stateVersion = homeManagerStateVersion;
home.primaryUser = primaryUserInfo // {
nixConfigDirectory = "${config.home.homeDirectory}/dotfiles.nix";
};
})
];
};
};
@ -270,21 +285,38 @@
};
};
# `nix-darwin` modules (some are pending upstream acceptance)
# `nix-darwin` configs and modules
darwinModules = {
# configs
bootstrap = import ./darwin/bootstrap.nix;
defaults = import ./darwin/defaults.nix;
general = import ./darwin/general.nix;
homebrew = import ./darwin/homebrew.nix;
# modules
games = import ./modules/darwin/games.nix;
programs-nix-index = import ./modules/darwin/programs/nix-index.nix;
security-pam = import ./modules/darwin/security/pam.nix;
users = import ./modules/darwin/users.nix;
primary-user = import ./modules/darwin/primary-user.nix;
};
# home manager configurations
homeManagerModules = {
# configs-git-aliases = import ./home/configs/git-aliases.nix;
# configs-gh-aliases = import ./home/configs/gh-aliases.nix;
# configs
configs-starship-symbols = import ./home/configs/starship-symbols.nix;
copyApplications = import ./home/copyApplications.nix;
files = import ./home/files.nix;
fish = import ./home/fish.nix;
git = import ./home/git.nix;
kakoune = import ./home/kakoune.nix;
kitty = import ./home/kitty.nix;
programs = import ./home/programs.nix;
starship = import ./home/starship.nix;
# modules
programs-kakoune-extras = import ./modules/home/programs/kakoune/extras.nix;
programs-kitty-extras = import ./modules/home/programs/kitty/extras.nix;
home-primary-user = { lib, ... }: {
options.home.primaryUser =
(self.darwinModules.primary-user { inherit lib; }).options.users.primaryUser;
};
};
} // flake-utils.lib.eachDefaultSystem (system: {

15
home/files.nix Normal file
View File

@ -0,0 +1,15 @@
{ config, ... }: {
# Misc configuration files --------------------------------------------------------------------{{{
xdg = {
enable = true;
};
home.file.".pijulconfig".text = ''
[author]
name = "mat"
full_name = "${config.programs.git.userName}"
email = "${config.programs.git.userEmail}"
'';
# }}}
}

View File

@ -162,6 +162,10 @@
from-nix kak $file
'';
};
fish_command_not_found.body = ''
command_not_found_handle $argv
'';
};
# }}}
@ -181,8 +185,8 @@
drsf = "from-nix darwin-rebuild switch --flake .";
# darwin-rebuild switch (no homebrew)
drs = "from-nix darwin-rebuild switch --flake . --override-input homebrew-enabled github:boolean-option/false";
# edit darwin-rebuild config in codium
drc = "codium ${nixConfigDir}";
# edit darwin-rebuild config in code/codium
drc = "code ${nixConfigDir}";
# edit darwin-rebuild config in vim
drv = "vim ${nixConfigDir}";
# edit darwin-rebuild config in kakoune
@ -199,7 +203,7 @@
# Other
".." = "cd ..";
":q" = "exit";
cat = "${bat}/bin/bat";
cat = "${bat}/bin/bat --style=plain";
du = "${du-dust}/bin/dust";
g = "${gitAndTools.git}/bin/git";
ls = "${exa}/bin/exa";
@ -210,6 +214,7 @@
top = "${bottom}/bin/btm";
htop = "${bottom}/bin/btm";
tb = "toggle-background";
} // lib.optionalAttrs stdenv.isDarwin {
sb = "set-background-to-macOS";
conda-init = "eval /opt/homebrew/Caskroom/miniforge/base/bin/conda 'shell.fish' 'hook' $argv | source";
};
@ -234,45 +239,4 @@
init-shell-colors
'';
# }}}
# Starship Prompt
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.starship.enable
programs.starship.enable = true;
# Starship settings -------------------------------------------------------------------------- {{{
programs.starship.settings = {
# See docs here: https://starship.rs/config/
# Symbols config configured in Flake.
battery.display = [
{ threshold = 25; } # display battery information if charge is <= 25%
];
directory.fish_style_pwd_dir_length = 1; # turn on fish directory truncation
directory.truncation_length = 2; # number of directories not to truncate
# hostname.style = "bold green"; # don't like the default
memory_usage.disabled = true; # because it includes cached memory it's reported as full a lot
# username.style_user = "bold blue"; # don't like the default
};
# }}}
# dark-mode-notify configuration
# {{{
launchd.enable = true;
launchd.agents.dark-mode-notify = {
enable = true;
config = {
Label = "ke.bou.dark-mode-notify";
KeepAlive = true;
StandardErrorPath = null;
StandardOutPath = null;
ProgramArguments = [
"${pkgs.dark-mode-notify}/bin/dark-mode-notify"
"${pkgs.fish}/bin/fish"
"-c"
"set-background-to-env DARKMODE"
];
};
};
# }}}
}

View File

@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ config, pkgs, lib, ... }:
{
# Git
@ -6,6 +6,9 @@
# Aliases config imported in flake.
programs.git.enable = true;
programs.git.userEmail = config.home.primaryUser.email;
programs.git.userName = config.home.primaryUser.fullName;
programs.git.extraConfig = {
core.editor = "kak";
diff.colorMoved = "default";

View File

@ -1,18 +1,7 @@
{ config, pkgs, lib, ... }:
{
# Import config broken out into files
imports = [
./copyApplications.nix
./git.nix
./kakoune.nix
./kitty.nix
./shells.nix
];
home.enableNixpkgsReleaseCheck = true;
# Packages with configuration --------------------------------------------------------------- {{{
# Programs + packages with configuration --------------------------------------------------------------- {{{
programs = {
# a nicer cat
@ -20,7 +9,7 @@
bat = {
enable = true;
config = {
style = "plain";
style = "auto";
};
};
# Direnv, load and unload environment variables depending on the current directory.
@ -52,24 +41,12 @@
helix = {
enable = true;
};
neovim = {
enable = true;
# viAlias = true;
# vimAlias = true;
# vimdiffAlias = true;
extraConfig = builtins.readFile ../configs/init.vim;
plugins = with pkgs.vimPlugins; [
neovim-sensible
tokyonight-nvim
lightline-vim
ctrlp
];
};
ssh = {
enable = true;
matchBlocks."*".extraOptions = {
UseKeychain = "yes";
AddKeysToAgent = "yes";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
# TODO: gate this behind a check if the cask is present
IdentityAgent = "~/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
};
@ -125,18 +102,4 @@
is-dark-mode # see /overlays/colors.nix
];
# }}}
# Misc configuration files --------------------------------------------------------------------{{{
xdg = {
enable = true;
};
home.file.".pijulconfig".text = ''
[author]
name = "mat"
full_name = "${config.programs.git.userName}"
email = "${config.programs.git.userEmail}"
'';
# }}}
}

22
home/starship.nix Normal file
View File

@ -0,0 +1,22 @@
{
# Starship Prompt
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.starship.enable
programs.starship.enable = true;
# Starship settings -------------------------------------------------------------------------- {{{
programs.starship.settings = {
# See docs here: https://starship.rs/config/
# Symbols config configured in Flake.
battery.display = [
{ threshold = 25; } # display battery information if charge is <= 25%
];
directory.fish_style_pwd_dir_length = 1; # turn on fish directory truncation
directory.truncation_length = 2; # number of directories not to truncate
# hostname.style = "bold green"; # don't like the default
memory_usage.disabled = true; # because it includes cached memory it's reported as full a lot
# username.style_user = "bold blue"; # don't like the default
};
# }}}
}

View File

@ -0,0 +1,26 @@
{ lib, ... }:
let
inherit (lib) mkOption types;
in
{
options.users.primaryUser = {
username = mkOption {
type = with types; nullOr string;
default = null;
};
fullName = mkOption {
type = with types; nullOr string;
default = null;
};
email = mkOption {
type = with types; nullOr string;
default = null;
};
nixConfigDirectory = mkOption {
type = with types; nullOr string;
default = null;
};
};
}

View File

@ -1,17 +0,0 @@
# Additional configuration for `nix-index` to enable `command-not-found` functionality with Fish.
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.programs.nix-index.enable {
programs.fish.interactiveShellInit = ''
function __fish_command_not_found_handler --on-event="fish_command_not_found"
${if config.programs.fish.useBabelfish then ''
command_not_found_handle $argv
'' else ''
${pkgs.bashInteractive}/bin/bash -c \
"source ${config.progams.nix-index.package}/etc/profile.d/command-not-found.sh; command_not_found_handle $argv"
''}
end
'';
};
}

View File

@ -1,14 +0,0 @@
{ lib, ... }:
let
inherit (lib) mkOption types;
in
{
options = {
users.primaryUser = mkOption {
type = with types; nullOr string;
default = null;
};
};
}

View File

@ -1,6 +0,0 @@
{ system ? builtins.currentSystem
, config ? { }
, overlays ? [ ]
, ...
}@args:
import (import ./default.nix).inputs.nixpkgs-unstable args