Now with NixOS

This commit is contained in:
Pierre Martin
2018-10-26 15:08:46 +02:00
parent 7fda8eea32
commit 43b96c6b10
25 changed files with 111 additions and 1094 deletions

83
.zshrc
View File

@@ -1,83 +0,0 @@
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
ZSH_THEME="robbyrussell"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git git-flow capistrano docker fasd ssh-agent)
# User configuration
export PATH=$HOME/bin:/usr/local/bin:$PATH
# export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
export EDITOR='vim'
export WHALEBREW_INSTALL_PATH=$HOME/bin
# Convenient aliases
alias dc=docker-compose
alias dcr='docker-compose run --rm'
alias copy="xclip -selection c"
alias y=yarn
alias deploy='docker run -it --rm -v ~/.ssh:/root/.ssh -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v $(pwd):/source neolao/capistrano:3.4.0 bash'
alias bepo='setxkbmap -layout fr -variant bepo'
alias fr='setxkbmap -layout fr -variant oss'
alias m='make'
alias t='task'
drm() { docker rm $(docker ps -qa); }
drme() { docker rm $(docker ps -qa --filter 'status=exited'); }
dri() { docker rmi $(docker images -q --filter "dangling=true"); }
dgo() { docker exec -ti $@ bash }
dip() { docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@"; }
dcrefresh() {
dc stop -t0 $1 && dc rm -vf $1 && dc up -d $1
}
bundle() {
BUNDLE_CMD=$@
docker run -ti --rm --name bundle-${PWD##*/} \
-v $HOME/.ssh:/root/.ssh \
-v $(pwd):/app -w /app \
-e BUNDLE_APP_CONFIG=/app/.bundle \
ruby:2.2 bash -c "eval \`ssh-agent\` && ssh-add && bundle $BUNDLE_CMD";
}
mysql() { docker run -ti --user 1000:1000 --rm mysql:5.6 mysql $@; }
caddy() {
docker run -d --user 1000:1000 -v $(pwd):/srv --name caddy-${PWD##*/} -e VIRTUAL_PORT=2015 -e VIRTUAL_HOST=${PWD##*/}.test -P abiosoft/caddy
}
ngrok() {
docker run --rm -it --link "$1":http wernight/ngrok ngrok http http:"$2"
}
ctop() {
docker run -ti -v /var/run/docker.sock:/var/run/docker.sock quay.io/vektorlab/ctop:latest
}
jq() {
docker run -i pinterb/jq:latest $@
}
function genpass() {
< /dev/urandom tr -dc A-Za-z0-9 | head -c "${1:-32}"
}

View File

@@ -1,2 +1,3 @@
# dotfiles # dotfiles
My dotfiles, powered by Ansible
My dotfiles for NixOs, using home-manager.

View File

@@ -1,53 +0,0 @@
#!/bin/bash
# AUTHOR: (c) Rob W 2012, modified by MHC (http://askubuntu.com/users/81372/mhc)
# NAME: GIFRecord 0.1
# DESCRIPTION: A script to record GIF screencasts.
# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
# DEPENDENCIES: byzanz,gdialog,notify-send (install via sudo add-apt-repository ppa:fossfreedom/byzanz; sudo apt-get update && sudo apt-get install byzanz gdialog notify-osd)
# Time and date
TIME=$(date +"%Y-%m-%d_%H%M%S")
# Delay before starting
DELAY=5
# Standard screencast folder
FOLDER="$HOME/Pictures"
# Default recording duration
DEFDUR=10
# Sound notification to let one know when recording is about to start (and ends)
beep() {
paplay /usr/share/sounds/freedesktop/stereo/message-new-instant.oga &
}
# Custom recording duration as set by user
USERDUR=$(gdialog --title "Duration?" --inputbox "Please enter the screencast duration in seconds" 200 100 2>&1)
# Duration and output file
if [ $USERDUR -gt 0 ]; then
D=$USERDUR
else
D=$DEFDUR
fi
# Window geometry
XWININFO=$(xwininfo)
read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO")
read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO")
read W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO")
read H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO")
# Notify the user of recording time and delay
notify-send "GIFRecorder" "Recording duration set to $D seconds. Recording will start in $DELAY seconds."
#Actual recording
sleep $DELAY
beep
byzanz-record -c --verbose --delay=0 --duration=$D --x=$X --y=$Y --width=$W --height=$H "$FOLDER/GIFrecord_$TIME.gif"
beep
# Notify the user of end of recording.
notify-send "GIFRecorder" "Screencast saved to $FOLDER/GIFrecord_$TIME.gif"

View File

@@ -1,5 +0,0 @@
#!/bin/bash
while read LINE; do
curl -o /dev/null --silent --head --write-out '%{http_code}' "$LINE"
echo " $LINE"
done

View File

@@ -1,2 +0,0 @@
#!/bin/bash
docker run -ti --rm --name composer-${PWD##*/} -v $(pwd):$(pwd) -w $(pwd) -v ~/.composer:/composer composer/composer "$@"

View File

@@ -1,75 +0,0 @@
#!/bin/bash
#usage: sudo ./docker-cleanup-volumes.sh [--dry-run]
dockerdir=/var/lib/docker
volumesdir=${dockerdir}/volumes
vfsdir=${dockerdir}/vfs/dir
allvolumes=()
dryrun=false
function delete_volumes() {
targetdir=$1
echo
if [[ ! -d ${targetdir} ]]; then
echo "Directory ${targetdir} does not exist, skipping."
return
fi
echo "Delete unused volume directories from $targetdir"
for dir in $(ls -d ${targetdir}/* 2>/dev/null)
do
dir=$(basename $dir)
if [[ "${dir}" =~ [0-9a-f]{64} ]]; then
if [[ ${allvolumes[@]} =~ "${dir}" ]]; then
echo In use ${dir}
else
if [ "${dryrun}" = false ]; then
echo Deleting ${dir}
rm -rf ${targetdir}/${dir}
else
echo Would have deleted ${dir}
fi
fi
else
echo Not a volume ${dir}
fi
done
}
if [ $UID != 0 ]; then
echo "You need to be root to use this script."
exit 1
fi
docker_bin=$(which docker.io || which docker)
if [ -z "$docker_bin" ] ; then
echo "Please install docker. You can install docker by running \"wget -qO- https://get.docker.io/ | sh\"."
exit 1
fi
if [ "$1" = "--dry-run" ]; then
dryrun=true
else if [ -n "$1" ]; then
echo "Cleanup docker volumes: remove unused volumes."
echo "Usage: ${0##*/} [--dry-run]"
echo " --dry-run: dry run: display what would get removed."
exit 1
fi
fi
#All volumes from all containers
for container in `${docker_bin} ps -a -q --no-trunc`; do
#add container id to list of volumes, don't think these
#ever exists in the volumesdir but just to be safe
allvolumes+=${container}
#add all volumes from this container to the list of volumes
for vid in `${docker_bin} inspect --format='{{range $vol, $path := .Volumes}}{{$path}}{{"\n"}}{{end}}' ${container}`; do
if [[ "${vid##*/}" =~ [0-9a-f]{64} ]]; then
allvolumes+=("${vid##*/}")
fi
done
done
delete_volumes ${volumesdir}
delete_volumes ${vfsdir}

View File

@@ -1,59 +0,0 @@
#!/bin/bash -u
#
# Clean Docker containers and images.
#
# This script assumes that the docker images are tagged with a version (like a git sha1) and 'latest'.
#
# WARNING: only 'latest' Docker images for the given repo are kept after a cleanup!
#
# Example of how to tag a Docker image with a version and 'latest':
# $ docker build --rm -t $REPO/$NAME:$VERSION .
# $ docker tag -f $REPO/$NAME:$VERSION $(ORG)/$NAME:latest
#
# The repo to use to filter images to delete
REPO=$1
# Utils functions
countContainers() { docker ps -aq | wc -l; }
listStoppedContainers() { docker ps -a | grep Exit | awk '{print $1}'; }
countmages() { docker images | egrep -c "($REPO|none)"; }
listNotLatestImages() { docker images | grep $REPO | grep -v latest | awk '{printf "%s:%s\n", $1, $2}'; }
listUntaggedImages() { docker images -q -f dangling=true; }
log() { echo "[$(date +"%Y-%m-%dT%H:%M:%SZ")][docker-cleanup] $1"; }
totalContainers=$(countContainers)
totalImages=$(countmages)
log "Total containers: $totalContainers"
log "Total images: $totalImages"
# Delete all stopped containers
containerIds=$(listStoppedContainers)
if [[ "$containerIds" != "" ]]; then
log "Remove stopped containers..."
docker rm $containerIds
fi
# Delete not latest images
oldImages=$(listNotLatestImages)
if [[ "$oldImages" != "" ]]; then
log "Remove not latest images..."
docker rmi -f $oldImages
fi
# Delete all untagged images
untaggedImages=$(listUntaggedImages)
if [[ "$untaggedImages" != "" ]]; then
log "Remove untagged images..."
docker rmi $untaggedImages
fi
newTotalContainers=$(countContainers)
newTotalImages=$(countmages)
log "---"
log "Containers deleted: $(expr $totalContainers - $newTotalContainers)"
log "Images deleted: $(expr $totalImages - $newTotalImages)"
log "---"
log "Total containers: $newTotalContainers"
log "Total images: $newTotalImages"

View File

@@ -1,15 +0,0 @@
#!/bin/bash
SINK=`pactl list short sinks | grep RUNNING | cut -f1`
case "$1" in
"up")
pactl set-sink-volume $SINK +10% && pactl set-sink-mute $SINK 0
;;
"down")
pactl set-sink-volume $SINK -10% && pactl set-sink-mute $SINK 0
;;
"mute")
pactl set-sink-mute $SINK toggle
;;
esac

View File

@@ -1,2 +0,0 @@
#!/bin/bash
docker run -ti --rm --name node-${PWD##*/} -v -v $(pwd):$(pwd) -w $(pwd) -v ~/.npm:/root/.npm node:7.4-alpine node "$@"

View File

@@ -1,2 +0,0 @@
#!/bin/bash
docker run -ti --rm --name npm-${PWD##*/} -e NPM_CONFIG_PROGRESS=false -v $(pwd):$(pwd) -w $(pwd) -v ~/.npm:/root/.npm node:7.4-alpine npm "$@"

View File

@@ -1,2 +0,0 @@
#!/bin/bash
docker run -ti --rm --user 1000:1000 --name php-${PWD##*/} -v $(pwd):$(pwd) -w $(pwd) php:latest php "$@"

246
bin/tldr
View File

@@ -1,246 +0,0 @@
#!/bin/bash
# tldr client by Ray Lee, http://github.com/raylee/tldr
# a Sunday afternoon's project, I'm sure there's room for improvement. PRs welcome!
set -uf -o pipefail
# initialize globals, sanity check the environment, etc.
config() {
init_term_cmds
if [ -z $(which curl) ]; then
echo "${red}tldr requires \`curl\` installed in your path$reset"
exit 1
fi
configdir=~/.tldr
[ -d ~/.config ] && configdir=~/.config/tldr
platform=$(get_platform)
base_url="https://raw.githubusercontent.com/tldr-pages/tldr/master/pages"
index_url="http://tldr-pages.github.io/assets/index.json"
index="$configdir/index.json"
cache_days=14
force_update=''
#check if config folder exists, otherwise create it
[ -d "$configdir" ] || mkdir -p "$configdir"
[ ! -f $index ] && update_index
auto_update_index
}
update_index() {
curl -sf -o "$index" "$index_url"
res=$?
if [ $res -eq 22 ]; then
echo "Could not download index from $index_url"
exit 1
fi
}
# if the file exists and is more recent than $cache_days old
recent() {
exists=$(find "$1" -mtime -$cache_days 2>/dev/null)
[ -n "$exists" -a -z "$force_update" ]
}
auto_update_index() {
recent "$index" || update_index
}
# function contents via http://mywiki.wooledge.org/BashFAQ/037
init_term_cmds() {
# only set if we're on an interactive session
[[ -t 2 ]] && {
reset=$( tput sgr0 || tput me ) # Reset cursor
bold=$( tput bold || tput md ) # Start bold
under=$( tput smul || tput us ) # Start underline
italic=$( tput sitm || tput ZH ) # Start italic
eitalic=$( tput ritm || tput ZH ) # End italic
default=$( tput op )
back=$'\b'
[[ $TERM != *-m ]] && {
black=$( tput setaf 0 || tput AF 0 )
red=$( tput setaf 1 || tput AF 1 )
green=$( tput setaf 2 || tput AF 2 )
yellow=$( tput setaf 3 || tput AF 3 )
blue=$( tput setaf 4 || tput AF 4 )
magenta=$( tput setaf 5 || tput AF 5 )
cyan=$( tput setaf 6 || tput AF 6 )
white=$( tput setaf 7 || tput AF 7 )
onblue=$( tput setab 4 || tput AB 4 )
ongrey=$( tput setab 7 || tput AB 7 )
}
} 2>/dev/null ||:
# osx's termcap doesn't have italics. The below adds support for iTerm2
# and is harmless on Terminal.app
[ "$(get_platform)" = "osx" ] && {
italic=$(echo -e "\033[3m")
eitalic=$(echo -e "\033[23m")
}
}
heading() {
local line="$*"
echo "$bold$red${line:2}$reset"
}
quotation() {
local line="$*"
echo "$under${line:2}$reset"
}
list_item() {
local line="$*"
echo "$line$reset"
}
code() {
local line="$*"
# I'm sure there's a better way to strip the first and last characters.
line="${line:1}"
line="${line%\`}"
# convert {{variable}} to italics
line=${line//\{\{/$italic}
line=${line//\}\}/$eitalic}
echo "$bold$line$reset"
}
text() {
local line="$*"
echo "$line"
}
# an idiot-level recognition of tldr's markdown. Needs improvement, or
# subcontracting out to a markdown -> ANSI formatting command
display_tldr() {
# read one line at a time, don't strip whitespace ('IFS='), and process
# last line even if it doesn't have a newline at the end
while IFS= read -r line || [[ -n "$line" ]]; do
start=${line:0:1} # get the first character
case "$start" in
'#') heading "$line"
;;
'>') quotation "$line"
;;
'-') list_item "$line"
;;
'`') code "$line"
;;
*) text "$line"
;;
esac
done
}
# convert the local platorm name to tldr's version
get_platform() {
case `uname -s` in
Darwin) echo "osx" ;;
Linux) echo "linux" ;;
SunOS) echo "sunos" ;;
*) echo "common" ;;
esac
}
# extract the platform key from index.json, return preferred subpath to tldrpage
path_for_cmd() {
local desc=$(tr '{' '\n' < $index | grep "\"name\":\"$1\"")
# results in, eg, "name":"netstat","platform":["linux","osx"]},
[ -z "$desc" ] && return
# use the platform specific version of the tldr first
if [[ $desc =~ \"$platform\" ]]; then
echo "$platform/$1.md"
elif [[ $desc =~ \"common\" ]]; then
echo "common/$1.md"
else
# take the first one so we can show something, but warn the user
local p=$(echo "$desc" | cut -d '"' -f 8)
>&2 echo -e "${red}tldr page $1 not found in $platform or common, using page from platform $p instead$reset\n"
echo "$p/$1.md"
fi
}
# return the local cached copy of the tldrpage, or retrieve and cache from github
get_tldr() {
local p="$(path_for_cmd $1)"
cached="$configdir/$p"
recent "$cached" || {
mkdir -p $(dirname $cached)
curl -sf -o "$cached" "$base_url/$p"
}
# if the curl failed for some reason, keep cat from whinging
cat "$cached" 2>/dev/null
}
config
usage() {
cmd=$(basename $0)
cat <<EOF
USAGE: $cmd [options] <command>
[options]
-l, --list: show all available pages
-p, --platform: show page from specific platform rather than autodetecting
-u, --update: update, force retrieving latest copies of locally cached files
-h, -?, --help: this help overview
<command>
Show examples for this command
The client caches a copy of all pages and the index locally under
$configdir. By default, the cached copies will expire in $cache_days days.
EOF
exit 0
}
while [ $# -gt 0 ]
do
case "$1" in
-l|--list)
>&2 echo -e "Known tldr pages: \n"
tr '{' '\n' < "$configdir/index.json" | cut -d '"' -f4 | column
exit 0
;;
-u|--update)
force_update=yes
update_index
;;
-h|-\?|--help)
usage
;;
-p|--platform)
shift
platform=$1
;;
-*)
usage
;;
*)
page=${1:-''}
;;
esac
shift
done
[ -z ${page:-} ] && usage
tldr="$(get_tldr $page)"
if [ -z "$tldr" ]; then
echo "tldr page for command $page not found"
exit 1
fi
display_tldr <<< "$tldr"
echo

View File

@@ -1,2 +0,0 @@
#!/bin/bash
docker run -ti --rm --user 1000:1000 --name yarn-${PWD##*/} -v ~/.yarn:/home/node/.cache/yarn -v $(pwd):$(pwd) -w $(pwd) kkarczmarczyk/node-yarn:latest yarn "$@"

1
config.nix Normal file
View File

@@ -0,0 +1 @@
{ allowUnfree = true; }

View File

@@ -1,244 +0,0 @@
---
- name: Setup the machine as a root user
hosts: localhost
become: yes
roles:
- {
role: flyinggecko.i3,
tags: windowmanager,
i3_state: "present",
i3_user: [
{ name: pierre, i3config: [ i3.base ], i3status: i3status.desktop }
]
}
- {
role: franklinkim.vim,
tags: vim,
vim_config: [ 'set expandtab' ]
}
- {
role: geerlingguy.git,
tags: git,
git_packages: [
"git-gui",
"gitk",
"git-flow",
"tig"
]
}
- {
role: kosssi.phpstorm,
tags: phpstorm,
phpstorm_version: "2017.2.4"
}
- {
role: ansiblebit.oracle-java,
tags: phpstorm,
oracle_java_set_as_default: yes
}
- {
role: franklinkim.docker,
tags: docker,
docker_containers: [
{
image: jwilder/nginx-proxy,
name: nginx-proxy,
ports: ["80:80", "443:443"],
volumes: [
"/var/run/docker.sock:/tmp/docker.sock:ro",
"/home/pierre/dotfiles/my_nginx_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro"
]
}
]
}
- {
role: franklinkim.docker-compose,
tags: docker,
docker_compose_version: 1.7.0
}
- {
role: glennr.oh-my-zsh,
tags: shell,
user: pierre
}
- {
role: nickjj.dnsmasq,
tags: dnsmasq,
dnsmasq_tld: test
}
- {
role: jdauphant.sublimetext,
sublimetext_build: 3126,
tags: sublimetext
}
- {
role: mglaman.atom,
atom_ver : '1.8.0',
atom_packages_packages: [
'docker',
'editorconfig',
'git-time-machine',
'minimap',
],
tags: atom
}
tasks:
- name: Ensure package definition is up-to-date, aka "apt-get update"
apt: update_cache=yes cache_valid_time=3600
- name: Window manager related packages are installed
apt: name={{ item }} state=present
tags: windowmanager
with_items:
- suckless-tools
- pcmanfm
- dunst
- numlockx
- xbacklight
- name: Required PPAs are available
apt_repository: repo={{ item }} state=present
tags: tools
with_items:
- 'ppa:zeal-developers/ppa'
- 'ppa:nathan-renniewaldock/flux'
# Distro too old! Need to upgrade kid
# - 'ppa:peek-developers/stable'
- name: Other convenient tools are installed
apt: name={{ item }} state=present
tags: tools
with_items:
- asciidoctor
- silversearcher-ag
- byzanz
- curl
- filezilla
- fluxgui
- freemind
- kazam
- gimp
- htop
- libreoffice
- lftp
- meld
- mysql-workbench
- pandoc
# - peek
- pv
- pwgen
- openssh-server
- owncloud-client
- shutter
- exfat-utils
- exfat-fuse
- ncdu
- p7zip
- python-pip
- tree
- unison
- whois
- xclip
- zeal
- name: Other convenient Python tools are installed
pip: name={{ item }}
tags: tools
with_items:
- http-prompt
- httpie-oauth
- name: Thinkpad related packages are installed
apt: name={{ item }} state=present
tags: thinkpad
with_items:
- alsa-tools-gui # See how to configure dock audio output at http://askubuntu.com/questions/670334/thinkpad-w540-docking-station-no-sound-on-external-speakers
- name: Setup user settings
hosts: localhost
become: no
vars:
BIN_DIR: "{{ansible_env.HOME}}/bin"
roles:
- {
role: igor_mukhin.sublimetext3_packagecontrol,
tags: sublimetext,
packagecontrol_packages: [
"AutoFileName",
"Dockerfile Syntax Highlighting",
"EditorConfig",
"Git",
"GitGutter",
"SideBarEnhancements",
"SCSS",
"Terminal"
]
}
tasks:
- name: ensure Git is properly configured
tags: git
template: src=templates/{{ item.src }} dest={{ansible_env.HOME}}/{{ item.dest }}
with_items:
- { src: gitconfig.j2, dest: .gitconfig }
- { src: gitignore.j2, dest: .gitignore }
- name: ensure a writable "bin" directory exists
tags: shell
file: path={{BIN_DIR}} state=directory mode=0755
- name: ensure fasd is installed and configured
tags: shell
get_url: url=https://raw.githubusercontent.com/clvv/fasd/master/fasd dest={{BIN_DIR}}/fasd mode=0755
- name: ensure binaries are available in path
tags: shell
copy: src=bin/ dest={{BIN_DIR}}/ mode=0755
- name: ensure dotfiles are available
tags: shell
copy: src=.zshrc dest={{ansible_env.HOME}}/.zshrc
# TODO
# Docker DNS qui trace : dans dnsmasq.conf
# listen-address=127.0.0.1
# listen-address=172.17.0.1
#
# https://github.com/sindresorhus/pure#getting-started instead of oh-my-zsh
#
# Thunderbird addon when upgraded - https://addons.mozilla.org/fr/thunderbird/addon/grammalecte-fr-thunderbird/
#
# i3 bugfixes/improvements:
# ++ http://www.draconianoverlord.com/2014/05/26/from-xmonad-to-i3.html
#
# echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
#
# Disable iBus (for IDEA at least: https://youtrack.jetbrains.com/issue/IDEA-78860)
# Config with "localectl --no-convert set-x11-keymap fr pc104"
# https://github.com/sgentle/caniuse-cmd
#
# Tigrc : https://github.com/chadrien/dotfiles/blob/master/roles/shell/files/tigrc#L10
#
# Capistrano : docker run --rm -it -v `pwd`:/home -v $HOME/.ssh:/root/.ssh --workdir="/home" ruby bash -c "bundle install && bundle exec cap deploy"
# Composer : docker run -v $(pwd):/app composer/composer install
# Auth.json -> home/qsdqs
# Mysql
#
# Corriger l'hibernation : http://doc.ubuntu-fr.org/veille_et_hibernation
#
# sudo usermod -aG docker pierre ?
# Dropbox
# Vault for passwords and sensitive data: http://docs.ansible.com/ansible/playbooks_vault.html
#
# Skype : https://hub.docker.com/r/sameersbn/skype/
# docker run -it --rm --volume /usr/local/bin:/target quay.io/sameersbn/skype:latest install
#
# Aliases++ https://github.com/thbkrkr/dotfiles/blob/master/dotfiles/.zshrc#L45
#
# Zeal pour doc offline
#
# http://askubuntu.com/questions/292696/ubuntu-crashes-when-on-battery-power
# ou http://askubuntu.com/questions/598224/cpu-frequency-control ou truc du genre
#
# Chrome :
# - { role: devbox.chrome, tags: browser }
# Brave: https://github.com/brave/browser-laptop/blob/master/docs/linuxInstall.md
#
# https://github.com/donnemartin/gitsome/blob/master/README.md
#
# https://github.com/sharkdp/fd
#
# Stow: http://sametmax.com/regrouper-ses-fichiers-de-settings-avec-stow/
#
# Refactoring:
# Nginx-proxy: move the config file by copying it where it belongs

108
home.nix Normal file
View File

@@ -0,0 +1,108 @@
{ pkgs, ... }:
let
latest = import <nixpkgs>{};
in
{
home.packages = with pkgs; [
fasd
latest.gitAndTools.gitflow latest.gitAndTools.tig
google-chrome-beta
latest.vscode
latest.jetbrains.phpstorm
unclutter-xfixes
# Peek. See https://github.com/NixOS/nixpkgs/issues/39832
peek
ffmpeg
glib
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-ugly
keybinder
];
services.unclutter.enable = true;
programs.home-manager = {
enable = true;
path = https://github.com/rycee/home-manager/archive/release-18.03.tar.gz;
};
programs.zsh = {
enable = true;
enableAutosuggestions = true;
enableCompletion = true;
history = {
ignoreDups = true;
save = 100000000000;
size = 100000000000;
};
oh-my-zsh = {
enable = true;
theme = "robbyrussell";
plugins = [ "git" "git-flow" "docker" "ssh-agent" "last-working-dir" "fasd" ];
};
sessionVariables = {
EDITOR = "vim";
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=7";
};
shellAliases = {
a = "fasd -a"; # any
s = "fasd -si"; # show / search / select
d = "fasd -d"; # directory
f = "fasd -f"; # file
sd = "fasd -sid"; # interactive directory selection
sf = "fasd -sif"; # interactive file selection
z = "fasd_cd -d"; # cd, same functionality as j in autojump
j = "fasd_cd -d"; # cd, same functionality as j in autojump
zz = "fasd_cd -d -i"; # cd with interactive selection
dc = "docker-compose";
dcr = "docker-compose run --rm";
copy = "xclip -selection c";
deploy = "docker run -it --rm -v ~/.ssh:/root/.ssh -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v $(pwd):/source neolao/capistrano:3.4.0 bash";
bepo = "setxkbmap -layout fr -variant bepo";
fr = "setxkbmap -layout fr -variant oss";
m = "make";
t = "task";
p = "pass";
tg = "tig --all";
};
};
programs.git = {
enable = true;
package = latest.gitAndTools.gitFull;
userEmail = "pierre@occitech.fr";
userName = "Pierre Martin";
aliases = {
co = "checkout";
};
ignores = [
".DS_Store"
".svn"
"*~"
"*.swp"
"*.rbc"
".watsonrc"
".idea"
".vscode"
];
};
}
# TODO
#
# - setup GPG: Git, pass etc...

2
hosts
View File

@@ -1,2 +0,0 @@
[local]
127.0.0.1 ansible_ssh_user=pierre

167
i3.base
View File

@@ -1,167 +0,0 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesnt scale on retina/hidpi displays.
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
bindsym $mod+d exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move windows
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+h split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
# switch to workspace
bindsym $mod+1 workspace number 1
bindsym $mod+2 workspace number 2
bindsym $mod+3 workspace number 3
bindsym $mod+4 workspace number 4
bindsym $mod+5 workspace number 5
bindsym $mod+6 workspace number 6
bindsym $mod+7 workspace number 7
bindsym $mod+8 workspace number 8
bindsym $mod+9 workspace number 9
bindsym $mod+0 workspace number 10
# See https://faq.i3wm.org/question/2332/flexible-monitor-setup/?answer=3557#post-id-3557
bindsym $mod+Control+r exec i3-input -F 'rename workspace to "%s"' -P 'New name: '
# Back and forth
bindsym $mod+Tab workspace back_and_forth
bindsym $mod+Shift+j workspace prev_on_output
bindsym $mod+Shift+k workspace next_on_output
# move workspaces between outputs
bindsym $mod+Control+Left move workspace to output left
bindsym $mod+Control+Right move workspace to output right
bindsym $mod+Control+Up move workspace to output up
bindsym $mod+Control+Down move workspace to output down
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym j resize shrink width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym semicolon resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# To get keycodes, run: sudo showkey -k
bindsym XF86AudioRaiseVolume exec --no-startup-id handle-volume-change up
bindsym XF86AudioLowerVolume exec --no-startup-id handle-volume-change down
bindsym XF86AudioMute exec --no-startup-id handle-volume-change mute
bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 10
bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 10
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
status_command i3status
}
exec --no-startup-id gnome-session
exec --no-startup-id unity-settings-daemon
exec --no-startup-id numlockx on # turn verr num on

View File

@@ -1,70 +0,0 @@
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
interval = 5
}
order += "cpu_usage"
order += "cpu_temperature 0"
order += "disk /"
order += "run_watch DHCP"
order += "run_watch VPN"
order += "wireless wlan0"
order += "ethernet eth0"
order += "battery 0"
order += "battery 1"
order += "load"
order += "tztime local"
cpu_usage {
format = "CPU: %usage"
}
wireless wlan0 {
format_up = "W: (%quality at %essid) %ip"
format_down = "W: down"
}
ethernet eth0 {
# if you use %speed, i3status requires root privileges
format_up = "E: %ip (%speed)"
format_down = "E: down"
}
battery 0 {
format = "%status %percentage %remaining"
}
battery 1 {
format = "%status %percentage %remaining"
}
run_watch DHCP {
pidfile = "/var/run/dhclient*.pid"
}
run_watch VPN {
pidfile = "/var/run/vpnc/pid"
}
tztime local {
format = "%d/%m/%Y %H:%M:%S"
}
load {
format = "%1min"
}
disk "/" {
format = "%avail"
}
cpu_temperature 0 {
format = "T: %degrees°C"
}

View File

@@ -1,6 +0,0 @@
#!/bin/bash
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y software-properties-common ansible

View File

@@ -1,5 +0,0 @@
client_max_body_size 600m;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

View File

@@ -1,12 +0,0 @@
franklinkim.vim
jdauphant.sublimetext
igor_mukhin.sublimetext3_packagecontrol
geerlingguy.git
ansiblebit.oracle-java
kosssi.phpstorm
franklinkim.docker
franklinkim.docker-compose
glennr.oh-my-zsh
flyinggecko.i3
nickjj.dnsmasq
mglaman.atom

View File

@@ -1,23 +0,0 @@
# {{ansible_managed}}
[user]
email=pierre@occitech.fr
name=Pierre Martin
[alias]
co = checkout
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
[core]
excludesfile = ~/.gitignore
editor = vim
filemode = false
[rerere]
enabled = true
[push]
default = simple
[credential]
helper = cache

View File

@@ -1,9 +0,0 @@
# {{ansible_managed}}
.DS_Store
.svn
*~
*.swp
*.rbc
.watsonrc
.idea
.vscode

View File

@@ -1,9 +0,0 @@
#!/bin/bash
TAGS=''
if [ ! -z $1 ]; then
TAGS="--tags=$1"
fi
ansible-playbook --ask-become-pass dotfiles.yml -i hosts $TAGS \
|| sudo ansible-galaxy install -r requirements.txt --ignore-errors