Ver a proveniência

Merge remote-tracking branch 'origin/master' into cray

cray
Mitch Tishmack há 8 anos
ascendente
cometimento
01c6776c7c
12 ficheiros alterados com 155 adições e 97 eliminações
  1. +30
    -10
      Makefile
  2. +10
    -7
      bin.org
  3. +1
    -1
      dotprofile.org
  4. +0
    -1
      emacs.org
  5. +2
    -1
      etangle
  6. +0
    -15
      haskell.org
  7. +1
    -9
      nix.org
  8. +14
    -0
      options/default-macos.el
  9. +1
    -0
      options/no-testing.el
  10. +1
    -0
      options/testing.el
  11. +75
    -50
      readme.org
  12. +20
    -3
      tmux.org

+ 30
- 10
Makefile Ver ficheiro

@@ -1,19 +1,31 @@
# Makefile is here to make it possible to use this whole shebang
# outside of emacs.
#
# TODO: wrap this stuff into a script maybe?
DEST:=$(HOME)
LAST:=$(shell cat .last || echo 0)
NEXT:=$(shell l=$(LAST); ((l=l+1)); echo $$l)
LAST!=cat .last || echo 0
NEXT!=l=$(LAST); ((l=l+1)); echo $$l
NEXTGEN:=$(PWD)/generation/$(NEXT)
LASTGEN:=$(PWD)/generation/$(LAST)
TANGLERS:=$(shell ls -d *.org)
TANGLERS:=$(wildcard *.org)
GEN:=$(LAST)
OPTS:=
# OSX uses hostname -s for the "stable" hostname
# uname -n can return dhcp addresses, which aren't
# stable.
HOST=$(shell echo "$$(hostname -s || uname -n)")
# OSX uses scutil --get ComputerName
# uname -n && hostname -s can return dhcp addresses
# which aren't stable.
HOST!=scutil --get ComputerName || uname -n
USEROPTS:=$(OPTS):$(HOST)
NAME:=default

# Make it easier to check if a variable is defined or not
# params:
# variable name
# optional message to print if variable is not set
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined variable $1$(if $2, ($2))))

INSTALLDIRS=tmp $(NEXTGEN) $(LASTGEN) generation/$(GEN)

@@ -25,8 +37,6 @@ $(INSTALLDIRS):
generation: $(NEXTGEN) $(LASTGEN) tmp
cd tmp && cp -av . $(NEXTGEN)

check:

diff: generation/$(GEN)
./ddiff $(PWD)/generation/$(GEN) $(DEST)

@@ -50,6 +60,15 @@ copy:
tangle: tmp
USEROPTS=$(USEROPTS) /usr/bin/env emacs --script ./etangle $(TANGLERS)

# TODO: is this gnu diff output... only or not? note: wip until i've
# tested on bsd make etc...

.PHONY: removed
removed:
$(call check_defined, OLD, generation to compare removed files against)
$(call check_defined, NEW, generation to compare removed files to)
@diff -bur generation/$(OLD) generation/$(NEW) 2>&1 | grep 'Only in generation/'$(OLD) | sed -e 's|Only in ||' -e 's|.*[:] ||'

clean:
-rm -fr tmp

@@ -58,5 +77,6 @@ nuke: clean

.PHONY: option
option:
$(call check_defined, NAME, predicate NAME to define in option files. Note: without -p i.e. NAME-p = t and no-NAME-p = nil)
echo "(setq $(NAME)-p t)" > options/$(NAME).el
echo "(setq $(NAME)-p nil)" > options/no-$(NAME).el

+ 10
- 7
bin.org Ver ficheiro

@@ -17,7 +17,7 @@ A stupid script I wrote ages ago to help me be lazy with cidr
notation for stuff. Setup the wrong netmask a few times and
you too, will wish for something similar.

#+BEGIN_SRC perl :padline no :tangle tmp/bin/cidr:padline no
#+BEGIN_SRC perl :padline no :tangle tmp/bin/cidr
#!/usr/bin/env perl
#
# Convert input ip/cidr|netmask|hexnetmask to useable network information.
@@ -1018,14 +1018,19 @@ More for nix on macos, but just merges NixOS/nipkgs origin/master to the current
set -e

session=nix
PKGS=${PKGS:-nixpkgs}

cd ~/src/github.com/NixOS/nixpkgs
if "${PKGS}" != "nixpkgs"; then
cd ~/src/github.com/NixOS/nixpkgs/${PKGS}
else
cd ~/src/github.com/NixOS/nixpkgs
fi

if ! tmux has-session -t ${session}; then
tmux new-session -d -s ${session} -n nix
tmux send-keys -t ${session}:0 'sleep 30
while true; do
blah=$(nix-env -iA --dry-run stdboth nixpkgs.default | grep /nix); echo "${blah}" | head -n $(echo "$LINES - 2" | bc); echo "${blah}" | grep -c /nix | ts
blah=$(nix-env -f "<${PKGS}>" -iA --dry-run stdboth default | grep /nix); echo "${blah}" | head -n $(echo "$LINES - 2" | bc); echo "${blah}" | grep -c /nix | ts
echo "${blah}" | grep /nix > /dev/null 2>&1
if [ $? -eq 0 ]; then
sleep 60
@@ -1036,14 +1041,12 @@ More for nix on macos, but just merges NixOS/nipkgs origin/master to the current
done
' C-m
tmux split-window -v -t ${session}:0
tmux send-keys -t ${session}:0.1 'git fetch --all && git merge origin/master &&
time nix-env -iA nixpkgs.default && nix-env -u --leq && exit 0
tmux send-keys -t ${session}:0.1 'git fetch --all && git short HEAD > last-$(iso8601) && git rebase --autostash origin/staging &&
time nix-env -f "<${PKGS}>" -iA default && nix-env -f "<${PKGS}>" -u --leq && exit 0
' C-m
tmux select-window -t ${session}:0
fi
tmux attach -t ${session}


#+END_SRC
* ~/bin/notify



+ 1
- 1
dotprofile.org Ver ficheiro

@@ -262,7 +262,7 @@ nix_env_setup()
# BAD INSTALLER NO COOKIE!
if [ -e ${HOME}/.nix-profile/etc/profile.d/nix.sh ]; then
. ${HOME}/.nix-profile/etc/profile.d/nix.sh;
export NIX_PATH=${HOME}/src/github.com/NixOS/nixpkgs:nixpkgs=${HOME}/src/github.com/NixOS/nixpkgs
export NIX_PATH=nixpkgs=${HOME}/src/github.com/NixOS/nixpkgs:staging=${HOME}/src/github.com/NixOS/nixpkgs/staging
export NIX_CFLAGS_COMPILE="-idirafter /usr/include"
export NIX_CFLAGS_LINK="-L/usr/lib"
export PKG_CONFIG_PATH="~/.nix-profile/lib/pkgconfig"


+ 0
- 1
emacs.org Ver ficheiro

@@ -1257,7 +1257,6 @@ TODO: fixme
(add-hook 'python-mode-hook
'(lambda ()
(flycheck-select-checker 'python-flake8)
(flycheck-select-checker 'python-pylint)
)
)



+ 2
- 1
etangle Ver ficheiro

@@ -10,7 +10,8 @@
(if (getenv "USEROPTS")
(dolist (fnam (split-string (getenv "USEROPTS") ":"))
(if (not (member fnam '("" nil)))
(load-file (concat "./options/" fnam ".el"))
(if (file-readable-p (concat "./options/" fnam ".el"))
(load-file (concat "./options/" fnam ".el")))
))
)



+ 0
- 15
haskell.org Ver ficheiro

@@ -19,18 +19,3 @@ Ghci setup, mostly just cosmetics.
:set prompt "λ "
:set +t
#+END_SRC

* ~/.ghc.hs

What to automatically have loaded into ghci sessions.

#+BEGIN_SRC haskell :tangle tmp/.ghc.hs
import Control.Applicative
import Control.Monad
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Bool
import qualified Data.Set as S
import qualified Data.Map as M
#+END_SRC

+ 1
- 9
nix.org Ver ficheiro

@@ -22,11 +22,10 @@ Nix user config.nix setup.
name = "default";
ignoreCollisions = true;
paths = [
ack
aria
aspell
aspellDicts.en
bazaarTools
cabal-install
cacert
clang
clang-analyzer
@@ -41,7 +40,6 @@ Nix user config.nix setup.
duply
emacs
entr
gcc
gdbm
ghostscript
gist
@@ -55,12 +53,10 @@ Nix user config.nix setup.
gnutls
graphviz-nox
haskellPackages.ShellCheck
haskellPackages.cabal-dependency-licenses
haskellPackages.ghc-mod
haskellPackages.hasktags
haskellPackages.hindent
haskellPackages.hspec
haskellPackages.idris
haskellPackages.pandoc
htop
imagemagick
@@ -74,11 +70,8 @@ Nix user config.nix setup.
moreutils
mosh
mr
multimarkdown
multitail
munge
mutt
nox
openssl
p7zip
patchutils
@@ -98,7 +91,6 @@ Nix user config.nix setup.
rtags
silver-searcher
sloccount
sqlite
sshpass
stack
texlive.combined.scheme-full


+ 14
- 0
options/default-macos.el Ver ficheiro

@@ -0,0 +1,14 @@
;;-*-mode: emacs-lisp; coding: utf-8;-*-
;; File: default-macos.el
;; Copyright: 2017 Mitch Tishmack
;; Description: default options for macos
(setq testing-p t)
(setq macos-p t)
(setq nix-p t)
(setq tmux-p t)
(setq git-p t)
(setq emacs-p t)
(setq zsh-p t)
(setq mosh-p t)
(setq haskell-p t)
(setq perl-p t)

+ 1
- 0
options/no-testing.el Ver ficheiro

@@ -0,0 +1 @@
(setq testing-p nil)

+ 1
- 0
options/testing.el Ver ficheiro

@@ -0,0 +1 @@
(setq testing-p t)

+ 75
- 50
readme.org Ver ficheiro

@@ -5,29 +5,26 @@
#+BABEL: :cache yes
#+PROPERTY: header-args :tangle yes :cache yes :comments no :padline no

In the long long ago (2015), I used xstow and update-dotdee to construct my
dotfiles from tiny pieces of files.
In the third age of my dotfile setup (2015), I used xstow and update-dotdee to
construct my dotfiles from tiny pieces of files as a sort of mini templating
engine.

I have since evolved to this setup. Originally the intention was to make it
easy for me to compile dotfiles based on certain parameters. Aka, my dotfiles
are the same for x, y, and z, whatever those are, but for certain cases z
should have one section be different or added etc... as the case may be.
I have since evolved to this setup. Originally the intention was to make it easy
for me to compile dotfiles based on certain parameters. Aka, my dotfiles are the
same for x, y, and z, whatever those are, but for certain cases z should have
one section be different or added etc... as the case may be.

Aka it was just a glorified program or templating system.

Since I already use org-mode to build my emacs configuration,
why not just do the same for the dotfiles. Bonus, now I can have ALL
my dotfiles in one logical file that can build itself.
Since I already use org-mode to build my emacs configuration, why not just do
the same for the dotfiles.

So now if you want to look at my dotfiles, they're all in here. With one
caveat that my emacs configuration is not. That is still separate. Mostly
because it is large enough that it can stand on its own.
So now if you want to look at my dotfiles, they're all here.

* Use/Abuse

Use of this setup is somewhat simple or straightforward.

There really is one step in general:
Use of this setup is somewhat simple or straightforward. There really is one
step in general:

#+BEGIN_SRC sh :tangle no
make
@@ -35,9 +32,9 @@ There really is one step in general:

** Emacs functions to add to init.el

For all this to work in emacs so you can edit source blocks you'll need
add the following two functions otherwise you'll get an error every time
you try to edit the source block.
For all this to work in emacs so you can edit source blocks you'll need add the
following two functions otherwise you'll get an error every time you try to edit
the source block.

#+BEGIN_SRC emacs-lisp :tangle no
(defun tangle/yn (p) (if (bound-and-true-p p) "yes" "no"))
@@ -46,9 +43,9 @@ you try to edit the source block.

This is also all the "magique" that this whole stupid repo entails.

But how would you control how things get exported? Well that is done
via files with simple *(setq predicate-p t)* lines inside them. These
are all the *options/name.el* files comprise of.
But how would you control how things get exported? Well that is done via files
with simple *(setq predicate-p t)* lines inside them. These are all the
*options/name.el* files comprise of.

But lets say you want to export things to another directory than $HOME. No
worries, just specify DEST:
@@ -67,6 +64,12 @@ echo "(setq ${name}-p t)" > options/${name}.el
echo "(setq ${name}-p nil)" > options/no-${name}.el
#+END_SRC

Or, more easily/lazily using the option makefile target:

#+BEGIN_SRC sh :tangle no
make option NAME=predicate-name-without-p
#+END_SRC

And then provide the *name* (without the .el extension) to make via *OPTS*:

#+BEGIN_SRC sh :tangle no
@@ -83,12 +86,12 @@ Etc...

I wouldn't do this exactly, while you could, thats just too much to need to
remember to type. The simplest way to do things is to just create an
*options/$(uname -n).el* file with all the options you need defined. Note that
in the or *BEGIN_SRC* lines you can use elisp to control when/how something should or
*options/$(uname -n).el* file with all the options you need defined. Note that in
the or *BEGIN_SRC* lines you can use elisp to control when/how something should or
should not get tangled.

Example use of tangle/file, note the final option is just elisp and we just
use *bound-and-true-p* to detect if we have a predicate or not.
Example use of tangle/file, note the final option is just elisp and we just use
*bound-and-true-p* to detect if we have a predicate or not.

#+BEGIN_SRC emacs-lisp :tangle no
(tangle/file "some/file/name" (bound-and-true-p macos-p))
@@ -113,12 +116,12 @@ installing to some *DEST*, and want to copy that to *$HOME*? No worries:

Where N is the generation you want to copy.

Note, to ensure this doesn't by default overwrite hand edited files, a
diff is run across the files that would be copied to and what the tangled
version contains.
Note, to ensure this doesn't by default overwrite hand edited files, a diff is
run across the files that would be copied to and what the tangled version
contains.

Example, I've commented out some .gitignore lines in *~/.gitignore* manually
and then tried to tangle a new generation over the top.
Example, I've commented out some .gitignore lines in *~/.gitignore* manually and
then tried to tangle a new generation over the top.

#+BEGIN_SRC sh :tangle no
./ddiff /Users/me/src/github.com/mitchty/dotfiles/generation/291 /Users/me
@@ -138,28 +141,50 @@ differences between /Users/me/src/github.com/mitchty/dotfiles/generation/291 and
#+END_SRC

This is an attempt to ensure that we don't accidentally overwrite files that may
have customizations on it.
have manual customizations in them.

To force it just run *make copy GEN=N* with *N* as the number to force a copy for.
To forcibly overwrite the files just run *make copy GEN=N* with *N* as the number to
force overwriting the destination files.

** How does it work?

It is really rather simple, the [[file:Makefile][Makefile]] isn't that complex. Look at that
for details.
It is really rather simple, the [[file:Makefile][Makefile]] isn't that complex. Look at that for
details.

This isn't intended to cover everything. This could be considered a template for
how you could setup your files in a similar way. Look at this org mode file for
details.

** Removal of files between generations

This isn't intended to cover everything. This could be considered a template
for how you could setup your files in a similar way. Look at this org mode
file for details.
Removal of files is ultimately *YOUR* job. However... to make it possible to
remove things if desired a bit easier you can run this makefile target with the
*OLD* and *NEW* variables set:

NOTE: Removal of files is YOUR job, not this tools. One could
theoretically look at what changed between two generations and
remove that way. BUT that sounds janky and error prone. Removal of
files is the users job, not this setup.
#+BEGIN_SRC sh :tangle no
make removed OLD=generation NEW=generation
#+END_SRC

This will list all the files/directories recursively not in *OLD* compared to *NEW*.

Example:

#+BEGIN_SRC sh :tangle no
$ make removed OLD=40 NEW=470
.Xdefaults
.Xresources
.ghc.hs
escp
essh
flushdns
tomod
towip
#+END_SRC

** Explanation of what is happening

This allows me to tangle files that would be useful for linux/bsd/etc...
without affecting the existing files.
This allows me to tangle files that would be useful for linux/bsd/etc... without
affecting the existing files.

The general idea is this (look at Makefile for details):
- increment generation count from last generation
@@ -173,14 +198,14 @@ The general idea is this (look at Makefile for details):
- Update last with current generation.

Note, the destination can be anywhere, not just $HOME. This allows one to
compile/tangle files that can then be trivially rsynced to remote machines,
or to tar/xz the files as needed. The key here is emacs is only required
to generate config files, not necessarily to use them.
compile/tangle files that can then be trivially rsynced to remote machines, or
to tar/xz the files as needed. The key here is emacs is only required to
generate config files, not necessarily to use them.

** How would I use this?

Should be easy enough to either clone this repo or copy things to a new repo
and hack in what you need. Your call.
Should be easy enough to either clone this repo or copy things to a new repo and
hack in what you need. Your call.

But, say you have a heading, take .profile as an example, under an org mode
heading you would just add to your *BEGIN_SRC* definition like so:
@@ -196,8 +221,8 @@ that you put everything into *tmp*! This is used to generate things before a
generation is built. It gives the Makefile a chance to know if the tangling
worked or not.

But lets say you don't need to have lots of sub headings, or even control
a file in multiple subparts that have predicates to control things.
But lets say you don't need to have lots of sub headings, or even control a file
in multiple subparts that have predicates to control things.

Pretty simple, just add a source block like normal:
#+BEGIN_SRC text :tangle no


+ 20
- 3
tmux.org Ver ficheiro

@@ -24,6 +24,9 @@ Tmux configuration. Pretty boring in most ways.
set-window-option -g window-status-fg black
set-window-option -g window-status-current-bg white

# Selection highlight color
set-window-option -g mode-style bg=red,fg=black

# Status line options
set-option -g status-bg black
set-option -g status-fg colour7
@@ -118,9 +121,6 @@ Tmux configuration. Pretty boring in most ways.
# Non confirming kill pane plskthxbai
bind-key x kill-pane

# In case something I run exits straight away, i'd like to know about it.
set-option -g set-remain-on-exit on

# Lets change the prefix key so we don't clobber emacs back one char key
unbind-key C-b

@@ -151,3 +151,20 @@ Only set xclip for x setup.
bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
bind C-y run "tmux save-buffer - | xclip -i"
#+END_SRC

Testing of battery stuff, defaults in general.

#+BEGIN_SRC conf :tangle (tangle/file ".tmux.conf" (and (bound-and-true-p tmux-p) (bound-and-true-p testing-p)))
set-option -g status-right-length 21
set-option -g status-right "#{battery_status_fg}#{battery_remain} #{battery_icon}#[fg=white] %a %H:%M:%S"
set-option -g @batt_charged_icon "✓"
run-shell ~/src/github.com/tmux-plugins/tmux-battery/battery.tmux
#+END_SRC

And for macos, differ in that the battery charged icon is utf-8 really. TODO: do I need this really?

#+BEGIN_SRC conf :tangle (tangle/file ".tmux.conf" (and (bound-and-true-p testing-p) (bound-and-true-p tmux-p) (bound-and-true-p macos-p)))
set-option -g status-right-length 20
set-option -g status-right "#{battery_remain} #{battery_icon} %a %H:%M:%S"
run-shell ~/src/github.com/tmux-plugins/tmux-battery/battery.tmux
#+END_SRC

Carregando…
Cancelar
Guardar