diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b3110d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +.history/ + +*.vsix + +.direnv +result +__pycache__ +**.pyc + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c3f8536 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690084763, + "narHash": "sha256-Nw680m/pyVoosSgXZW415Z657mfVM2BxaxDPjEk48Z0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "fb03fa5516d4e86059d24ab35a611ffa3a359547", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1690083312, + "narHash": "sha256-I3egwgNXavad1eIjWu1kYyi0u73di/sMmlnQIuzQASk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "af8cd5ded7735ca1df1a1174864daab75feeb64a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c02ecd9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,26 @@ +{ + description = "A Very Flakey Home Manager"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = {nixpkgs, home-manager, ...}: + let + system = "x86_64-linux"; + in { + defaultPackage.${system} = home-manager.defaultPackage.${system}; + + homeConfigurations = { + "john" = home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { system = "${system}"; }; + + modules = [ ./nix/common/home.nix ]; + }; + }; + }; + } diff --git a/nix/common/home.nix b/nix/common/home.nix new file mode 100644 index 0000000..a278d07 --- /dev/null +++ b/nix/common/home.nix @@ -0,0 +1,86 @@ +{ pkgs, lib, config, ... }: { + imports = [ + ../lib/tmux.nix + ../lib/vim.nix + ]; + # home-manager config + home.username = "john"; + home.homeDirectory = "/home/john"; + home.stateVersion = "23.05"; # Please read the comment before changing. + programs.home-manager.enable = true; + nixpkgs.config.allowUnfree = true; + targets.genericLinux.enable = true; + + # home files + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; +# ".vimrc".source = .dotfiles/vim/.vimrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # env vars + home.sessionVariables = { + EDITOR = "vim"; + }; + + # packages + home.packages = with pkgs; [ + babelfish + fish + htop + hugo + libvirt + packer + terraform + tldr + vagrant + vault + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # Fish shell settings + programs.fish = { + enable = true; + shellInit = "source ${config.home.homeDirectory}/.nix-profile/etc/profile.d/nix.fish"; + functions = { + switch-home = "home-manager switch -b backup --flake ${config.home.homeDirectory}/.dotfiles"; + }; + }; + + # git settings + programs.git = { + enable = true; + delta.enable = true; + userEmail = "john@bowdre.net"; + userName = "John Bowdre"; + extraConfig = { + pull.ff = "only"; + init.defaultBranch = "main"; + }; + }; + + # XDG settings + xdg.enable = true; + xdg.mime.enable = true; + +} diff --git a/nix/lib/tmux.nix b/nix/lib/tmux.nix new file mode 100644 index 0000000..d6372ff --- /dev/null +++ b/nix/lib/tmux.nix @@ -0,0 +1,63 @@ +{ pkgs, lib, ...}: { + programs.tmux = { + enable = true; + baseIndex = 1; + clock24 = true; + mouse = true; + historyLimit = 100000; + keyMode = "vi"; + escapeTime = 50; + plugins = with pkgs.tmuxPlugins; [ ]; + extraConfig = '' + # navigating panes with Ctrl+{hjkl} + bind -n C-h select-pane -L + bind -n C-j select-pane -D + bind -n C-k select-pane -U + bind -n C-l select-pane -R + + # synchronize panes with S + bind S set-window-option synchronize-panes \; display-message 'Synchronize-panes #{?pane_synchronized,on,off}' + + # swap panes with <> + bind > swap-pane -D + bind < swap-pane -U + + # window operations + unbind n + unbind w + bind n command-prompt "rename-window '%%'" + bind w new-window -c "#{pane_current_path}" + bind -n M-j previous-window # alt+j + bind -n M-k next-window # alt+k + + # default statusbar colors + set-option -g status-style fg=yellow,bg=black + + # default window title colors + set-window-option -g window-status-style fg=brightblue,bg=default + #set-window-option -g window-status-style dim + + # active window title colors + set-window-option -g window-status-current-style fg=brightred,bg=default + #set-window-options -g window-status-current-style bright + + # pane border + set-option -g pane-border-style fg=black + set-option -g pane-active-border-style fg=brightgreen + + # message text + set-option -g message-style fg=brightred,bg=black + + # pane number display + set-option -g display-panes-active-colour blue + set-option -g display-panes-colour brightred + + # clock + set-window-option -g clock-mode-colour brightgreen + + # bell + set-window-option -g window-status-bell-style fg=black,bg=red + ''; + }; +} + diff --git a/nix/lib/vim.nix b/nix/lib/vim.nix new file mode 100644 index 0000000..2a069e5 --- /dev/null +++ b/nix/lib/vim.nix @@ -0,0 +1,65 @@ +{ pkgs, lib, ... }: { + programs.vim = { + enable = true; + defaultEditor = true; + settings = { + background = "dark"; + expandtab = true; + number = true; + shiftwidth = 2; + tabstop = 2; + }; + plugins = with pkgs.vimPlugins; [ + vim-trailing-whitespace + nerdcommenter + vim-go + vim-sensible + ]; + extraConfig = '' + " Tmux integration to switch panes with Ctrl+{hkjl} + if exists('$TMUX') + function! TmuxOrSplitSwitch(wincmd, tmuxdir) + let previous_winnr = winnr() + silent! execute "wincmd " . a:wincmd + if previous_winnr == winnr() + call system("tmux select-pane -" . a:tmuxdir) + redraw! + endif + endfunction + + let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', "", "") + let &t_ti = "\2;vim\\\" . &t_ti + let &t_te = "\2;". previous_title . "\\\" . &t_te + + nnoremap :call TmuxOrSplitSwitch('h', 'L') + nnoremap :call TmuxOrSplitSwitch('j', 'D') + nnoremap :call TmuxOrSplitSwitch('k', 'U') + nnoremap :call TmuxOrSplitSwitch('l', 'R') + else + map h + map j + map k + map l + endif + + " coding preference + filetype off + filetype plugin indent on + + syntax on + set backspace=indent,eol,start + set noautoindent + set noswapfile + set ruler + set showmatch + set smarttab + set sts=2 + let g:NERDSpaceDelims=1 + + let mapleader="," + if has("autocmd") + autocmd FileType go set ts=2 sw=2 sts=2 noet nolist autowrite + endif + ''; + }; +}