Dev environment setup
This commit is contained in:
parent
e1afafff33
commit
36ca746b47
11 changed files with 260 additions and 166 deletions
|
@ -40,18 +40,16 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users.charlotte.extraGroups = [ "networkmanager" "video" "input" ];
|
virtualisation.docker.enable = true;
|
||||||
|
|
||||||
|
users.users.charlotte.extraGroups = [ "docker" "video" "input" ];
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [ eid-mw ];
|
environment.systemPackages = with pkgs; [ eid-mw ];
|
||||||
|
|
||||||
system.autoUpgrade.enable = true;
|
system.autoUpgrade.enable = true;
|
||||||
|
|
||||||
home-manager.users.charlotte = { pkgs, ... }: {
|
home-manager.users.charlotte = { pkgs, ... }: {
|
||||||
nixpkgs = {
|
nixpkgs.config.allowUnfree = true;
|
||||||
config = {
|
|
||||||
allowUnfree = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
home = {
|
home = {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
chromium
|
chromium
|
||||||
|
|
9
programs/direnv/README.md
Normal file
9
programs/direnv/README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Setting up a new dev environment
|
||||||
|
|
||||||
|
* Create a new `*.nix` file in the shells directory that describes the environment (this is the hard part).
|
||||||
|
|
||||||
|
* Execute `lorri init` in the base directory of your project. This will create a `.envrc` file and `shell.nix` file.
|
||||||
|
|
||||||
|
* Edit the `shell.nix` file to just `import /home/charlotte/.local/share/nix-shells/your-new-file.nix`
|
||||||
|
|
||||||
|
* Execute `direnv allow` to load the `.envrc` file which in turn uses `lorri` to load your `shell.nix` file.
|
|
@ -12,5 +12,6 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.lorri.enable = true;
|
services.lorri.enable = true;
|
||||||
|
xdg.dataFile.nix-shells.source = ./shells;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
33
programs/direnv/shells/dodona.nix
Normal file
33
programs/direnv/shells/dodona.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
let
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
ruby
|
||||||
|
yarn
|
||||||
|
nodejs-12_x
|
||||||
|
libmysqlclient
|
||||||
|
zlib
|
||||||
|
(pkgs.writeScriptBin "start-db" ''
|
||||||
|
#!${pkgs.zsh}/bin/zsh
|
||||||
|
|
||||||
|
_sighandler() {
|
||||||
|
docker stop dodona-db
|
||||||
|
}
|
||||||
|
|
||||||
|
trap _sighandler SIGINT
|
||||||
|
trap _sighandler SIGTERM
|
||||||
|
trap _sighandler SIGHUP
|
||||||
|
|
||||||
|
docker run --name dodona-db -p 3306:3306 --rm -v $(git rev-parse --show-toplevel)/tmp/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=dodona mariadb:latest &
|
||||||
|
|
||||||
|
child=$!
|
||||||
|
wait $child
|
||||||
|
# We wait two times, because the first wait exits when the process receives a signal. The process might have finished though, so we ignore errors.
|
||||||
|
wait $child 2>/dev/null
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
shellHook = ''
|
||||||
|
export DATABASE_URL="mysql2://root:dodona@127.0.0.1:3306/dodona"
|
||||||
|
'';
|
||||||
|
}
|
14
programs/direnv/shells/ledger.nix
Normal file
14
programs/direnv/shells/ledger.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
let
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
baseVimConfig = import ./vim-base.nix { inherit pkgs; };
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
(neovim.override {
|
||||||
|
configure = {
|
||||||
|
customRC = baseVimConfig.customRC;
|
||||||
|
vam.pluginDictionaries = (baseVimConfig.vam.pluginDictionaries or []) ++ [ { name = "vim-ledger"; } ];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
13
programs/direnv/shells/nix.nix
Normal file
13
programs/direnv/shells/nix.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
let
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
(neovim.override {
|
||||||
|
configure = {
|
||||||
|
customRC = baseVimConfig.customRC;
|
||||||
|
vam.pluginDictionaries = (baseVimConfig.vam.pluginDictionaries or []);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
116
programs/direnv/shells/vim-base.nix
Normal file
116
programs/direnv/shells/vim-base.nix
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
customRC = ''
|
||||||
|
set autoread
|
||||||
|
"" Theming
|
||||||
|
|
||||||
|
set background=light
|
||||||
|
|
||||||
|
"" General settings
|
||||||
|
|
||||||
|
" Undo over sessions
|
||||||
|
set undofile
|
||||||
|
set undodir=~/.cache/nvimundo
|
||||||
|
|
||||||
|
" Automatically save sessions on exit and load them on start
|
||||||
|
function! MakeSession()
|
||||||
|
let b:sessiondir = $HOME . "/.config/nvim/sessions" . getcwd()
|
||||||
|
if (filewritable(b:sessiondir) != 2)
|
||||||
|
exe 'silent !mkdir -p ' b:sessiondir
|
||||||
|
redraw!
|
||||||
|
endif
|
||||||
|
let b:filename = b:sessiondir . '/session.vim'
|
||||||
|
exe "mksession! " . b:filename
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! LoadSession()
|
||||||
|
let b:sessiondir = $HOME . "/.config/nvim/sessions" . getcwd()
|
||||||
|
let b:sessionfile = b:sessiondir . "/session.vim"
|
||||||
|
if (filereadable(b:sessionfile))
|
||||||
|
exe 'source ' b:sessionfile
|
||||||
|
else
|
||||||
|
echo "No session loaded."
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
if(argc() == 0)
|
||||||
|
au VimEnter * nested :call LoadSession()
|
||||||
|
endif
|
||||||
|
au VimLeave * :call MakeSession()
|
||||||
|
|
||||||
|
"" Filetype configuration
|
||||||
|
|
||||||
|
" Base settings for all files
|
||||||
|
|
||||||
|
syntax enable
|
||||||
|
set number
|
||||||
|
set showcmd
|
||||||
|
set scrolloff=8
|
||||||
|
set expandtab
|
||||||
|
set tabstop=4
|
||||||
|
set shiftwidth=4
|
||||||
|
set linebreak
|
||||||
|
|
||||||
|
set list
|
||||||
|
set listchars=tab:·\ ,trail:·
|
||||||
|
set inccommand=split
|
||||||
|
set clipboard=unnamedplus
|
||||||
|
|
||||||
|
filetype plugin indent on
|
||||||
|
|
||||||
|
"" Plugin configuration
|
||||||
|
|
||||||
|
function! s:completedFiles(winid, filename, ...) abort
|
||||||
|
bdelete!
|
||||||
|
call win_gotoid(a:winid)
|
||||||
|
if filereadable(a:filename)
|
||||||
|
let lines = readfile(a:filename)
|
||||||
|
if !empty(lines)
|
||||||
|
exe ':e ' . lines[0]
|
||||||
|
endif
|
||||||
|
call delete(a:filename)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FzyFiles()
|
||||||
|
let file = tempname()
|
||||||
|
let winid = win_getid()
|
||||||
|
let cmd = split(&shell) + split(&shellcmdflag) + ["${pkgs.ripgrep.out}/bin/rg --files --hidden -g '!/.git' --smart-case | ${pkgs.fzy.out}/bin/fzy > " . file]
|
||||||
|
let F = function('s:completedFiles', [winid, file])
|
||||||
|
botright 10 new
|
||||||
|
call termopen(cmd, {'on_exit': F})
|
||||||
|
startinsert
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:completedGrep(winid, filename, ...) abort
|
||||||
|
bdelete!
|
||||||
|
call win_gotoid(a:winid)
|
||||||
|
if filereadable(a:filename)
|
||||||
|
let lines = readfile(a:filename)
|
||||||
|
if !empty(lines)
|
||||||
|
let list = split(lines[0], ':')
|
||||||
|
let file = list[0]
|
||||||
|
let line = list[1]
|
||||||
|
exe ':e ' . file
|
||||||
|
exe line
|
||||||
|
endif
|
||||||
|
call delete(a:filename)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FzyGrep()
|
||||||
|
let file = tempname()
|
||||||
|
let winid = win_getid()
|
||||||
|
let cmd = split(&shell) + split(&shellcmdflag) + ["${pkgs.ripgrep.out}/bin/rg --vimgrep --hidden -g '!/.git' '^' | ${pkgs.fzy.out}/bin/fzy > " . file]
|
||||||
|
let F = function('s:completedGrep', [winid, file])
|
||||||
|
botright 10 new
|
||||||
|
call termopen(cmd, {'on_exit': F})
|
||||||
|
startinsert
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
nnoremap <C-f> :call FzyFiles()<CR>
|
||||||
|
nnoremap <C-g> :call FzyGrep()<CR>
|
||||||
|
'';
|
||||||
|
vam.knownPlugins = pkgs.vimPlugins;
|
||||||
|
vam.pluginDictionaries = [ { name = "vim-nix"; } ];
|
||||||
|
}
|
|
@ -1,160 +1,14 @@
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
let
|
{
|
||||||
neovim = pkgs.neovim.override {
|
home-manager.users.charlotte = { pkgs, ... }: {
|
||||||
configure = {
|
nixpkgs.overlays = [
|
||||||
customRC = ''
|
(self: super: {
|
||||||
set autoread
|
neovim = super.neovim.override {
|
||||||
"" Theming
|
configure = (import ../direnv/shells/vim-base.nix { pkgs = self; }) ;
|
||||||
|
|
||||||
set background=light
|
|
||||||
|
|
||||||
"" General settings
|
|
||||||
|
|
||||||
" Undo over sessions
|
|
||||||
set undofile
|
|
||||||
set undodir=~/.cache/nvimundo
|
|
||||||
|
|
||||||
" Automatically save sessions on exit and load them on start
|
|
||||||
function! MakeSession()
|
|
||||||
let b:sessiondir = $HOME . "/.config/nvim/sessions" . getcwd()
|
|
||||||
if (filewritable(b:sessiondir) != 2)
|
|
||||||
exe 'silent !mkdir -p ' b:sessiondir
|
|
||||||
redraw!
|
|
||||||
endif
|
|
||||||
let b:filename = b:sessiondir . '/session.vim'
|
|
||||||
exe "mksession! " . b:filename
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LoadSession()
|
|
||||||
let b:sessiondir = $HOME . "/.config/nvim/sessions" . getcwd()
|
|
||||||
let b:sessionfile = b:sessiondir . "/session.vim"
|
|
||||||
if (filereadable(b:sessionfile))
|
|
||||||
exe 'source ' b:sessionfile
|
|
||||||
else
|
|
||||||
echo "No session loaded."
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
if(argc() == 0)
|
|
||||||
au VimEnter * nested :call LoadSession()
|
|
||||||
endif
|
|
||||||
au VimLeave * :call MakeSession()
|
|
||||||
|
|
||||||
"" Filetype configuration
|
|
||||||
|
|
||||||
" Base settings for all files
|
|
||||||
|
|
||||||
syntax enable
|
|
||||||
set number
|
|
||||||
set showcmd
|
|
||||||
set scrolloff=8
|
|
||||||
set expandtab
|
|
||||||
set tabstop=4
|
|
||||||
set shiftwidth=4
|
|
||||||
set linebreak
|
|
||||||
|
|
||||||
set list
|
|
||||||
set listchars=tab:·\ ,trail:·
|
|
||||||
set inccommand=split
|
|
||||||
set clipboard=unnamedplus
|
|
||||||
|
|
||||||
filetype plugin indent on
|
|
||||||
|
|
||||||
" Filetype specific settings
|
|
||||||
|
|
||||||
autocmd FileType javascript call TwoSpaces()
|
|
||||||
autocmd FileType less call TwoSpaces()
|
|
||||||
autocmd FileType css call TwoSpaces()
|
|
||||||
autocmd FileType scss call TwoSpaces()
|
|
||||||
autocmd FileType html call TwoSpaces()
|
|
||||||
autocmd FileType ruby call TwoSpaces()
|
|
||||||
autocmd FileType yaml call TwoSpaces()
|
|
||||||
autocmd FileType eruby call TwoSpaces()
|
|
||||||
autocmd FileType haskell call TwoSpaces()
|
|
||||||
autocmd FileType json call TwoSpaces()
|
|
||||||
autocmd FileType typescript call TwoSpaces()
|
|
||||||
|
|
||||||
function TwoSpaces()
|
|
||||||
setlocal tabstop=2
|
|
||||||
setlocal shiftwidth=2
|
|
||||||
setlocal softtabstop=2
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"" Plugin configuration
|
|
||||||
|
|
||||||
function! s:completedFiles(winid, filename, ...) abort
|
|
||||||
bdelete!
|
|
||||||
call win_gotoid(a:winid)
|
|
||||||
if filereadable(a:filename)
|
|
||||||
let lines = readfile(a:filename)
|
|
||||||
if !empty(lines)
|
|
||||||
exe ':e ' . lines[0]
|
|
||||||
endif
|
|
||||||
call delete(a:filename)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! FzyFiles()
|
|
||||||
let file = tempname()
|
|
||||||
let winid = win_getid()
|
|
||||||
let cmd = split(&shell) + split(&shellcmdflag) + ["${pkgs.ripgrep.out}/bin/rg --files --hidden -g '!/.git' --smart-case | ${pkgs.fzy.out}/bin/fzy > " . file]
|
|
||||||
let F = function('s:completedFiles', [winid, file])
|
|
||||||
botright 10 new
|
|
||||||
call termopen(cmd, {'on_exit': F})
|
|
||||||
startinsert
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:completedGrep(winid, filename, ...) abort
|
|
||||||
bdelete!
|
|
||||||
call win_gotoid(a:winid)
|
|
||||||
if filereadable(a:filename)
|
|
||||||
let lines = readfile(a:filename)
|
|
||||||
if !empty(lines)
|
|
||||||
let list = split(lines[0], ':')
|
|
||||||
let file = list[0]
|
|
||||||
let line = list[1]
|
|
||||||
exe ':e ' . file
|
|
||||||
exe line
|
|
||||||
endif
|
|
||||||
call delete(a:filename)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! FzyGrep()
|
|
||||||
let file = tempname()
|
|
||||||
let winid = win_getid()
|
|
||||||
let cmd = split(&shell) + split(&shellcmdflag) + ["${pkgs.ripgrep.out}/bin/rg --vimgrep --hidden -g '!/.git' '^' | ${pkgs.fzy.out}/bin/fzy > " . file]
|
|
||||||
let F = function('s:completedGrep', [winid, file])
|
|
||||||
botright 10 new
|
|
||||||
call termopen(cmd, {'on_exit': F})
|
|
||||||
startinsert
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
nnoremap <C-f> :call FzyFiles()<CR>
|
|
||||||
nnoremap <C-g> :call FzyGrep()<CR>
|
|
||||||
'';
|
|
||||||
|
|
||||||
vam.knownPlugins = pkgs.vimPlugins;
|
|
||||||
vam.pluginDictionaries = [
|
|
||||||
{
|
|
||||||
names = [
|
|
||||||
"vim-ledger"
|
|
||||||
"vim-nix"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
home-manager.users.charlotte = { pkgs, ... }: {
|
|
||||||
nixpkgs = {
|
|
||||||
config = {
|
|
||||||
packageOverrides = pkgs: {
|
|
||||||
neovim = neovim;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
})
|
||||||
home.packages = [ pkgs.neovim ];
|
];
|
||||||
};
|
home.packages = [ pkgs.neovim ];
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -207,9 +207,9 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
home-manager.users.charlotte = { pkgs, ... }: {
|
home-manager.users.charlotte = { pkgs, ... }: {
|
||||||
nixpkgs.config.packageOverrides = pkgs: {
|
nixpkgs.overlays = [
|
||||||
waybar = pkgs.waybar.override { pulseSupport = true; mpdSupport = false; };
|
(self: super: { waybar = super.waybar.override { pulseSupport = true; mpdSupport = false; }; })
|
||||||
};
|
];
|
||||||
home.packages = [ color-picker ];
|
home.packages = [ color-picker ];
|
||||||
xdg.configFile."sway/config".text = ''
|
xdg.configFile."sway/config".text = ''
|
||||||
# Config for sway
|
# Config for sway
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
};
|
};
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
"tmuxinator/accentor.yml".source = ./accentor.yml;
|
"tmuxinator/accentor.yml".source = ./accentor.yml;
|
||||||
|
"tmuxinator/dodona.yml".source = ./dodona.yml;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
55
programs/tmux/dodona.yml
Normal file
55
programs/tmux/dodona.yml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# /home/charlotte/.config/tmuxinator/dodona.yml
|
||||||
|
|
||||||
|
name: dodona
|
||||||
|
root: ~/repos/dodona/dodona
|
||||||
|
|
||||||
|
# Optional tmux socket
|
||||||
|
# socket_name: foo
|
||||||
|
|
||||||
|
# Note that the pre and post options have been deprecated and will be replaced by
|
||||||
|
# project hooks.
|
||||||
|
|
||||||
|
# Project hooks
|
||||||
|
# Runs on project start, always
|
||||||
|
# on_project_start: command
|
||||||
|
# Run on project start, the first time
|
||||||
|
# on_project_first_start: command
|
||||||
|
# Run on project start, after the first time
|
||||||
|
# on_project_restart: command
|
||||||
|
# Run on project exit ( detaching from tmux session )
|
||||||
|
# on_project_exit: command
|
||||||
|
# Run on project stop
|
||||||
|
# on_project_stop: command
|
||||||
|
|
||||||
|
# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions.
|
||||||
|
# pre_window: rbenv shell 2.0.0-p247
|
||||||
|
|
||||||
|
# Pass command line options to tmux. Useful for specifying a different tmux.conf.
|
||||||
|
# tmux_options: -f ~/.tmux.mac.conf
|
||||||
|
|
||||||
|
# Change the command to call tmux. This can be used by derivatives/wrappers like byobu.
|
||||||
|
# tmux_command: byobu
|
||||||
|
|
||||||
|
# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used.
|
||||||
|
# startup_window: editor
|
||||||
|
|
||||||
|
# Specifies (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used.
|
||||||
|
# startup_pane: 1
|
||||||
|
|
||||||
|
# Controls whether the tmux session should be attached to automatically. Defaults to true.
|
||||||
|
# attach: false
|
||||||
|
|
||||||
|
windows:
|
||||||
|
- editor:
|
||||||
|
layout: main-vertical
|
||||||
|
panes:
|
||||||
|
- nvim
|
||||||
|
- git status
|
||||||
|
- server:
|
||||||
|
layout: even-horizontal
|
||||||
|
panes:
|
||||||
|
- bundle exec rails s
|
||||||
|
- bundle exec rails jobs:work
|
||||||
|
- ./bin/webpack-dev-server
|
||||||
|
- logs: tail -f log/development.log
|
||||||
|
- db: start-db
|
Loading…
Add table
Add a link
Reference in a new issue