Skip to content

Instantly share code, notes, and snippets.

@webframp
Created November 9, 2020 20:48
Show Gist options
  • Save webframp/621842ba12134d5bed016e912bbeac22 to your computer and use it in GitHub Desktop.
Save webframp/621842ba12134d5bed016e912bbeac22 to your computer and use it in GitHub Desktop.
nix-darwin experiments
{ config, lib, pkgs, ... }:
{
# Enable User Setup
# https://rycee.gitlab.io/home-manager/index.html#sec-install-nix-darwin-module
imports = [ <home-manager/nix-darwin> ];
home-manager.useGlobalPkgs = true;
networking.hostName = "megatron";
# System settings
# Explained: https://gist.github.com/MatthewEppelsheimer/2269385
system.defaults = {
NSGlobalDomain = {
AppleKeyboardUIMode = 3;
ApplePressAndHoldEnabled = false;
InitialKeyRepeat = 12; # Default: 15
KeyRepeat = 1; # Default: 2
NSAutomaticCapitalizationEnabled = false;
NSAutomaticDashSubstitutionEnabled = false;
NSAutomaticPeriodSubstitutionEnabled = false;
NSAutomaticQuoteSubstitutionEnabled = false;
NSAutomaticSpellingCorrectionEnabled = false;
NSNavPanelExpandedStateForSaveMode = true;
NSNavPanelExpandedStateForSaveMode2 = true;
_HIHideMenuBar = true;
};
dock = {
autohide = true;
mru-spaces = false;
# orientation = "left";
showhidden = true;
};
finder.AppleShowAllExtensions = true;
finder.FXEnableExtensionChangeWarning = false;
trackpad.Clicking = true;
trackpad.TrackpadThreeFingerDrag = true;
};
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; with pkgs.nodePackages; [
config.programs.vim.package
# nix helpers
cachix nixfmt
# https://github.com/mlvzk/manix
# rust cli tools
bandwhich bat exa fd ripgrep tokei xsv
# development
amp cmake curl git git-lfs go golangci-lint hadolint hugo jq libtool mkcert
shellcheck travis #yq
# git extras
gitAndTools.hub gitAndTools.lab git-lfs
# nodePackages
# npm ls -g --depth=0
yaml-language-server bash-language-server typescript-language-server vscode-json-languageserver-bin
dockerfile-language-server-nodejs js-beautify prettier jsonlint # serverless (broken)
markdown-link-check
# textlint textlint-rule-terminology textlint-rule-stop-words textlint-rule-write-good
# TODO: (need derivations or switch tools)
# markdown-spellcheck markdownlint-cli
aspell aspellDicts.en languagetool
# shell
antibody nix-zsh-completions chezmoi direnv fpp fzf reattach-to-user-namespace tmux
urlview whois zsh
(pass.withExtensions (ext: with ext; [ pass-otp ])) browserpass
# operations
awscli azure-cli bash-my-aws conftest mr mtr pulumi-bin openssh s3cmd terraform tfsec vault
consul consul-template
# vault-token-helper ?
# kubernetes
aws-iam-authenticator k9s kind kubectl kustomize open-policy-agent yamllint
# https://github.com/ahmetb/kubectx/issues/211
# kubectx # install with brew for now
# system info
htop neofetch pstree
# utils
coreutils dos2unix nmap neo-cowsay pandoc parallel editorconfig-core-c enchant fpp ffmpeg-full
gifsicle gnupg gnutar gpgme graphviz-nox unixtools.watch vale wget youtube-dl zbar
# darwin-zsh-completions
# python38Packages.binwalk python38Packages.flake8
pinentry pinentry_mac wireguard-tools
# Try out gcc emacs from overlay
emacsGcc
];
environment.variables.LANG = "en_US.UTF-8";
# environment.systemPath = [
# "/Applications/Docker.app/Contents/Resources/bin"
# ];
environment.shells = with pkgs; [
bashInteractive zsh
];
environment.shellAliases = {
vim = "nvim";
nixre = "darwin-rebuild switch";
nixgc = "nix-collect-garbage -d";
nixup = "nix-env -u";
nixinfo = "nix run nixpkgs.nix-info -c nix-info -m";
};
services.yabai = {
enable = true;
package = pkgs.yabai;
enableScriptingAddition = true;
};
services.skhd.enable = true;
services.spacebar = {
enable = true;
package = pkgs.spacebar;
config = {
position = "top";
text_font = ''"Helvetica Neue:Bold:12.0"'';
icon_font = ''"FontAwesome:Regular:12.0"'';
background_color = "0xff202020";
foreground_color = "0xffa8a8a8";
space_icon_strip = "α β γ δ ε ζ η θ ι";
power_icon_strip = " ";
space_icon = "";
clock_icon = "";
dnd_icon = "";
clock_format = "%R";
# debug_output = "off";
};
};
# launchd.user.agents.spacebar.serviceConfig.StandardErrorPath = "/tmp/spacebar.err.log";
# launchd.user.agents.spacebar.serviceConfig.StandardOutPath = "/tmp/spacebar.out.log";
# Recreate /run/current-system symlink after boot
services.activate-system.enable = true;
# TODO Fonts ?
fonts = {
enableFontDir = true;
fonts = with pkgs; [
(nerdfonts.override {
fonts = ["Hack" "Iosevka" "FiraCode"
"JetBrainsMono" "Meslo" "RobotoMono" "SourceCodePro"];
})
noto-fonts
open-sans
etBook
];
};
# Allow suggestions and quick searches with nix-index
programs.nix-index.enable = true;
# Create /etc/bashrc that loads the nix-darwin environment.
programs.bash.enable = true;
programs.zsh.enable = true; # default shell on catalina
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix.package = pkgs.nix;
nixpkgs.config.allowUnfree = true;
# Enable NUR
nixpkgs.config.packageOverrides = pkgs: rec {
nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
};
};
nixpkgs.overlays = [
(import (builtins.fetchTarball {
url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
}))
];
nix.useSandbox = true;
nix.sandboxPaths = [ "/System/Library/Frameworks" "/System/Library/PrivateFrameworks" "/usr/lib" "/private/tmp" "/private/var/tmp" "/usr/bin/env" ];
nix.trustedUsers = [ "@admin" ];
programs.vim.package = pkgs.neovim.override {
vimAlias = true;
configure = {
packages.darwin.start = with pkgs.vimPlugins; [
vim-airline vim-airline-themes vim-sensible vim-surround vim-fugitive
ReplaceWithRegister polyglot fzfWrapper ale deoplete-nvim vim-nix
awesome-vim-colorschemes
];
customRC = ''
set encoding=utf-8
set hlsearch
set list
set number
set visualbell
set showcmd
set splitright
set ttyfast
" last line
set showmode
set showcmd
cnoremap %% <C-r>=expand('%:h') . '/'<CR>
nnoremap // :nohlsearch<CR>
let mapleader = ' '
" fzf
nnoremap <Leader>p :FZF<CR>
" vim-surround
vmap s S
" ale
nnoremap <Leader>d :ALEGoToDefinition<CR>
nnoremap <Leader>D :ALEGoToDefinitionInVSplit<CR>
nnoremap <Leader>k :ALESignature<CR>
nnoremap <Leader>K :ALEHover<CR>
nnoremap [a :ALEPreviousWrap<CR>
nnoremap ]a :ALENextWrap<CR>
" deoplete
inoremap <expr><C-g> deoplete#undo_completion()
inoremap <expr><C-l> deoplete#refresh()
inoremap <silent><expr><C-Tab> deoplete#mappings#manual_complete()
inoremap <silent><expr><Tab> pumvisible() ? "\<C-n>" : "\<TAB>"
let g:deoplete#enable_at_startup = 1
" theme
set t_Co=256
set background=dark
let g:airline_theme='base16'
let g:airline_powerline_fonts = 1
colorscheme nord
'';
};
};
# Use a custom configuration.nix location.
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
# environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment