Skip to content

Instantly share code, notes, and snippets.

@webframp
Created October 9, 2020 02:10
Show Gist options
  • Select an option

  • Save webframp/38a0d67f3ef082f8e3dc85e7501b01e0 to your computer and use it in GitHub Desktop.

Select an option

Save webframp/38a0d67f3ef082f8e3dc85e7501b01e0 to your computer and use it in GitHub Desktop.

Revisions

  1. webframp created this gist Oct 9, 2020.
    239 changes: 239 additions & 0 deletions darwin-configuration.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,239 @@
    { 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;

    # 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

    # rust cli tools
    bandwhich bat exa fd ripgrep tokei xsv

    # development
    amp curl git go golangci-lint hadolint hugo jq shellcheck #yq

    # git extras
    gitAndTools.hub gitAndTools.lab

    # 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 serverless jsonlint
    # textlint textlint-rule-terminology textlint-rule-stop-words textlint-rule-write-good
    # TODO: (need derivations or switch tools)
    # markdown-spellcheck markdownlint-cli

    # shell
    antibody nix-zsh-completions direnv fzf tmux urlview whois zsh
    (pass.withExtensions (ext: with ext; [ pass-otp ]))

    # operations
    awscli bash-my-aws conftest k9s pulumi-bin openssh terraform tfsec vault
    # vault-token-helper ?

    # system info
    htop neofetch

    # utils
    nmap pandoc parallel enchant

    #darwin-zsh-completions
    #cachix
    # https://github.com/mlvzk/manix
    ];

    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";

    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
    ];
    };

    # Auto upgrade nix package and the daemon service.
    services.nix-daemon.enable = true;
    nix.package = pkgs.nix;

    # 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

    nixpkgs.config.allowUnfree = true;

    # Enable NUR
    nixpkgs.config.packageOverrides = pkgs: {
    nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
    inherit pkgs;
    };
    };

    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
    '';
    };
    };

    # User specific setup
    # home-manager.users.sme = { pkgs, ... }: {
    # home.packages = with pkgs; [
    # parallel
    # ];
    # };

    # home-manager.users.sme.programs.firefox.extensions =
    # with pkgs.nur.repos.rycee.firefox-addons; [
    # ublock-origin browserpass vimium
    # ];

    # 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;
    }