Split up base and add xonsh

Add Xonsh configurations from dotfiles
Split up the base configuration into more manageable sizes
This commit is contained in:
Greg Hellings
2022-04-21 04:49:44 +00:00
parent 55cc25a12a
commit 91dbef3d59
7 changed files with 225 additions and 88 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
mods = hostname: [
inputs.agenix.nixosModule
./modules
./profiles/base.nix
./profiles/base
./hosts/${hostname}
inputs.home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
-7
View File
@@ -1,7 +0,0 @@
{ ... }:
{
home.files.".xonshrc" = ''
'';
}
+10 -80
View File
@@ -1,32 +1,21 @@
{ config, pkgs, agenix, ... }:
let
syncs = [
"nas"
"dns"
"linode"
];
in
{
# Enable flakes
nix = {
package = pkgs.nixFlakes;
imports = [
./nix.nix
./programs.nix
./syncthing.nix
./xonsh.nix
];
# Keep freespace available, at a minimum, and enable Flakes
extraOptions = ''
experimental-features = nix-command flakes
min-free = ${toString (1024 * 1024 * 1024) }
max-free = ${toString (5 * 1024 * 1024 * 1024) }
'';
# Use hardlinking instead of copying when possible
autoOptimiseStore = true;
};
nixpkgs.config.allowUnfree = true;
# I am a fan of network manager, myself
networking.networkmanager.enable = true;
# Enable the OpenSSH daemon for remote control
services.openssh.enable = true;
#services.openssh.permitRootLogin = "yes";
# Define a user account. Don't forget to set a password with passwd.
users.users.greg = {
isNormalUser = true;
@@ -39,65 +28,6 @@ in
];
};
# Enable the OpenSSH daemon for remote control
services.openssh.enable = true;
#services.openssh.permitRootLogin = "yes";
services.syncthing = {
enable = true;
user = "greg";
group = "users";
dataDir = "/home/greg/sync";
devices = {
nas = {
addresses = [
"tcp://nas.thehellings.lan:22000"
"tcp://chronicles.greg-hellings.gmail.com.beta.tailscale.net:22000"
];
id = "74JUTZG-77EPGO3-FEYCL2P-CHDWP5G-6EXWZVB-XTAH6O5-TUXCVY2-QNRHSQ4";
};
dns = {
addresses = [
"tcp://dns.thehellings.lan:22000"
"tcp://2maccabees.greg-hellings.gmail.com.beta.tailscale.net:22000"
];
id = "C4XJCH7-3ZNW6XZ-R5DB2EU-OEGVVT2-WPHQAG7-UDWER36-6NO5KZR-4MN5VAK";
};
linode = {
addresses = [
"tcp://linode.thehellings.com:22000"
];
id = "3PHWAI5-ILAWGGD-S5FC5QM-M2WQ2FX-PZ3IXQF-QVRKANG-WXAACJC-2MZN3Q5";
};
};
folders = {
"mkrvy-tc6x9" = {
enable = true;
path = "/home/greg/drive";
devices = syncs;
};
};
};
# Base packages that need to be in all my hosts
environment.systemPackages = with pkgs; [
agenix.defaultPackage."${system}"
diffutils
git
gnupatch
findutils
home-manager
htop
python3
pwgen
tmux
transcrypt
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
xonsh
yamllint # Used in vim
];
i18n.defaultLocale = "en_US.UTF-8";
console = {
+19
View File
@@ -0,0 +1,19 @@
{ pkgs, ... }:
{
# Enable flakes
nix = {
package = pkgs.nixFlakes;
# Keep freespace available, at a minimum, and enable Flakes
extraOptions = ''
experimental-features = nix-command flakes
min-free = ${toString (1024 * 1024 * 1024) }
max-free = ${toString (5 * 1024 * 1024 * 1024) }
'';
# Use hardlinking instead of copying when possible
autoOptimiseStore = true;
};
nixpkgs.config.allowUnfree = true;
}
+22
View File
@@ -0,0 +1,22 @@
{ pkgs, agenix, ... }:
{
# Base packages that need to be in all my hosts
environment.systemPackages = with pkgs; [
agenix.defaultPackage."${system}"
diffutils
git
gnupatch
findutils
home-manager
htop
python3
pwgen
tmux
transcrypt
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
xonsh
yamllint # Used in vim
];
}
+46
View File
@@ -0,0 +1,46 @@
{ ... }:
let
syncs = [
"nas"
"dns"
"linode"
];
in
{
services.syncthing = {
enable = true;
user = "greg";
group = "users";
dataDir = "/home/greg/sync";
devices = {
nas = {
addresses = [
"tcp://nas.thehellings.lan:22000"
"tcp://chronicles.greg-hellings.gmail.com.beta.tailscale.net:22000"
];
id = "74JUTZG-77EPGO3-FEYCL2P-CHDWP5G-6EXWZVB-XTAH6O5-TUXCVY2-QNRHSQ4";
};
dns = {
addresses = [
"tcp://dns.thehellings.lan:22000"
"tcp://2maccabees.greg-hellings.gmail.com.beta.tailscale.net:22000"
];
id = "C4XJCH7-3ZNW6XZ-R5DB2EU-OEGVVT2-WPHQAG7-UDWER36-6NO5KZR-4MN5VAK";
};
linode = {
addresses = [
"tcp://linode.thehellings.com:22000"
];
id = "3PHWAI5-ILAWGGD-S5FC5QM-M2WQ2FX-PZ3IXQF-QVRKANG-WXAACJC-2MZN3Q5";
};
};
folders = {
"mkrvy-tc6x9" = {
enable = true;
path = "/home/greg/drive";
devices = syncs;
};
};
};
}
+127
View File
@@ -0,0 +1,127 @@
{ pkgs, ... }:
{
programs.xonsh = {
enable = true;
config = ''
# set -e == $RAISE_SUBPROC_ERROR = True
# set -x == trace on; $XONSH_TRACE_SUBPROC = True
# $? == _.rtn
import os
$TIMEFORMAT = '%3Uu %3Ss %3lR %P%%'
$CLICOLOR = 1
$LSCOLORS = 'ExGxBxDxCxEgEdxbxgxcxd'
$EDITOR = '${pkgs.vim}/vim'
$PKG_CONFIG_PATH = '/usr/local/lib/pkgconfig'
# Tells vox where to find virtualenvs
$VIRTUALENV_HOME = $HOME + '/venv/'
$PROMPT = '{env_name}{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} {short_cwd}{branch_color}{curr_branch: {}}{RESET} {BOLD_BLUE}{prompt_end}{RESET} '
$SWORD_PATH = $HOME + '/.sword'
$OS_CLOUD = 'default'
$GOPATH = '~/.go'
$JAVA_HOME = '/etc/alternatives/java_sdk'
$MAVEN_OPTS = ' -Dmaven.wagon.http.ssl.insecure=true'
# Coloured man page support
# using 'less' env vars (format is '\E[<brightness>;<colour>m')
$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
####################################
#
# Alias Time
#
####################################
aliases['ll'] = 'ls -l'
aliases['vup'] = 'vagrant up --provision --provider libvirt'
aliases['vos'] = 'vagrant up --provision --provider openstack'
aliases['vssh'] = 'vagrant ssh'
aliases['vhalt'] = 'vagrant halt'
aliases['vprov'] = 'vagrant provision'
aliases['vdown'] = 'vagrant destroy'
aliases['ac'] = 'vox activate'
aliases['d'] = 'vox deactivate'
aliases['devroles'] = 'cd ~/src/ansible_collections/devroles'
aliases['molcol'] = 'molecule -c ../../tests/molecule.yml'
aliases['packaging'] = 'cd ~/src/packaging'
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
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
# Open a new terminal tab (Gnome Terminal) in the same CWD
$PROMPT = '{vte_new_tab_cwd}' + $PROMPT
'';
};
}