Files
nixos/home/xonsh.nix
T

139 lines
4.1 KiB
Nix
Raw Normal View History

2022-08-02 01:50:50 -05:00
{ pkgs, config, lib, ... }:
2022-04-29 10:58:31 -05:00
2022-08-02 01:50:50 -05:00
{
2022-04-29 10:58:31 -05:00
programs.xonsh = {
enable = true;
sessionVariables = {
TIMEFORMAT = "%3Uu %3Ss %3lR %P%%";
CLICOLOR = 1;
LSCOLORS = "ExGxBxDxCxEgEdxbxgxcxd";
EDITOR = "${pkgs.vim}/bin/vim";
# Tells vox where to find virtualenvs
VIRTUALENV_HOME = "${config.home.homeDirectory}/venv/";
# vte_new_tab_cwd causes new Terminal tabs to open in the
# same CWD as the current tab
PROMPT = "{vte_new_tab_cwd}{env_name}{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} {short_cwd}{branch_color}{curr_branch: {}}{RESET} {BOLD_BLUE}{prompt_end}{RESET} ";
SWORD_PATH = "${config.home.homeDirectory}/.sword/";
OS_CLOUD = "default";
MAVEN_OPTS = " -Dmaven.wagon.http.ssl.insecure=true";
LESS_TERMCAP_mb = "\\033[01;31m"; # begin blinking
LESS_TERMCAP_md = "\\033[01;31m"; # begin bold
LESS_TERMCAP_me = "\\033[0m"; # end mode
LESS_TERMCAP_so = "\\033[01;44;36m"; # begin standout-mode (bottom of screen)
LESS_TERMCAP_se = "\\033[0m"; # end standout-mode
LESS_TERMCAP_us = "\\033[00;36m"; # begin underline
LESS_TERMCAP_ue = "\\033[0m"; # end underline
};
aliases = {
ac = "vox activate";
2022-09-27 11:04:50 -05:00
cblack = "compass workspace run src/python3/uc/tools:run_black --";
cci = "./scripts/circleci-checks.py";
crun = "compass workspace run";
cylint = "./scripts/run_yaml_lint.py";
2022-04-29 10:58:31 -05:00
d = "vox deactivate";
devroles = "cd ~/src/ansible_collections/devroles";
2022-09-27 11:04:50 -05:00
dirflake = "nix flake new -t github:nix-community/nix-direnv";
ll = "ls -l";
2022-04-29 10:58:31 -05:00
molcol = "molecule -c ../../tests/molecule.yml";
pa = "cd ~/src/packaging";
2022-06-12 00:50:26 -05:00
tsup = "sudo tailscale up";
tspub = "sudo tailscale up --exit-node=linode";
2022-06-13 16:14:41 +00:00
tshome = "sudo tailscale up --exit-node=2maccabees";
2022-06-12 00:56:46 -05:00
tsclear = "sudo tailscale up --exit-node=''";
2022-09-27 11:04:50 -05:00
vdown = "vagrant destroy";
vhalt = "vagrant halt";
vos = "vagrant up --provision --provider openstack";
vprov = "vagrant provision";
vup = "vagrant up --provision --provider libvirt";
vssh = "vagrant ssh";
2022-04-29 10:58:31 -05:00
};
configHeader = ''
2022-09-12 10:05:07 -05:00
if '__NIX_DARWIN_SET_ENVIRONMENT_DONE' not in ''${...} or not $__NIX_DARWIN_SET_ENVIRONMENT_DONE:
source-bash /etc/bashrc
2022-04-29 10:58:31 -05:00
# set -e == $RAISE_SUBPROC_ERROR = True
# set -x == trace on; $XONSH_TRACE_SUBPROC = True
# $? == _.rtn
import os
2022-05-04 13:52:38 -05:00
xontrib load direnv
2022-04-29 10:58:31 -05:00
'';
#$PKG_CONFIG_PATH = '/usr/local/lib/pkgconfig'
#$GOPATH = $HOME + '/.go'
#$JAVA_HOME = '/etc/alternatives/java_sdk'
configFooter = ''
2022-09-09 13:30:12 -05:00
def _rebuild(args):
import os
system = os.uname()
if system.sysname == 'Darwin':
darwin-rebuild --flake ~/.config/nix switch
else:
sudo nixos-rebuild switch
2022-04-29 10:58:31 -05:00
def _yaml2json(args, stdin=None, stdout=None):
import sys, yaml, json
from yaml import CLoader
json.dump(yaml.load(stdin, Loader=CLoader), stdout, indent=4)
def _py2env(args):
vox new @(args[0]) -p /usr/bin/python2
def _py3env(args):
vox new @(args[0])
def _rundock(args):
if os.path.exists('/usr/bin/podman'):
e = 'podman'
else:
e = 'docker'
@(e) exec -ti @(args[0]) /bin/bash
def _pip_extras(args):
import importlib_metadata
print(importlib_metadata.metadata(args[0]).get_all('Provides-Extra'))
# Container stuff
def _newdock(args):
if os.path.exists('/usr/bin/podman'):
e = 'podman'
else:
e = 'docker'
@(e) run -P --privileged=true -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v @(os.getcwd()):/dmnt -v /etc/pki:/etc/pki:ro -d --name @(args[1]) @(args[0]) /sbin/init
rundock @(args[1])
def _unknown_host(args):
sed -i -e @(args[0])d ~/.ssh/known_hosts
2022-09-09 13:30:12 -05:00
aliases['rebuild'] = _rebuild
2022-04-29 10:58:31 -05:00
aliases['yaml2json'] = _yaml2json
aliases['py2env'] = _py2env
aliases['py3env'] = _py3env
aliases['rundock'] = _rundock
aliases['newdock'] = _newdock
aliases['unknown_host'] = _unknown_host
aliases['pip_extras'] = _pip_extras
###
#
# Other random nice-to-have things
#
###
# Does virtualenv support
xontrib load vox
# Faster coreutils
xontrib load coreutils
# Allows identifying JSON as if it was Python by adding some new builtins to the language
import builtins
builtins.true = True
builtins.false = False
builtins.null = None
'';
};
}