summaryrefslogtreecommitdiff
path: root/modules/profiles/dev
diff options
context:
space:
mode:
Diffstat (limited to 'modules/profiles/dev')
-rw-r--r--modules/profiles/dev/containers.nix71
-rw-r--r--modules/profiles/dev/default.nix94
-rw-r--r--modules/profiles/dev/gdbinit41
-rw-r--r--modules/profiles/dev/ghci.conf35
-rw-r--r--modules/profiles/dev/pystartup.py121
-rw-r--r--modules/profiles/dev/sql.nix105
6 files changed, 467 insertions, 0 deletions
diff --git a/modules/profiles/dev/containers.nix b/modules/profiles/dev/containers.nix
new file mode 100644
index 0000000..f75a26b
--- /dev/null
+++ b/modules/profiles/dev/containers.nix
@@ -0,0 +1,71 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+with lib;
+let
+ cfg = config.nixfiles.modules.profiles.dev.containers;
+in
+{
+ options.nixfiles.modules.profiles.dev.containers.enable =
+ mkEnableOption "Tools for working with containers and container orchestration"
+ // {
+ default = config.nixfiles.modules.profiles.dev.enable;
+ };
+
+ config = mkIf cfg.enable {
+ nixfiles.modules = {
+ common.shell.aliases = {
+ h = "helm";
+ k = "kubectl";
+ kns = "kubens";
+ ktx = "kubectx";
+ b = "buildah";
+ };
+ podman.enable = true;
+ };
+
+ hm = {
+ home = {
+ sessionVariables = {
+ MINIKUBE_HOME = "${config.dirs.config}/minikube";
+ MINIKUBE_IN_STYLE = "false";
+ WERF_DEV = "true";
+ WERF_INSECURE_REGISTRY = "true";
+ WERF_LOG_DEBUG = "true";
+ WERF_LOG_PRETTY = "false";
+ WERF_LOG_VERBOSE = "true";
+ WERF_SYNCHRONIZATION = ":local";
+ WERF_TELEMETRY = "false";
+ };
+
+ packages = with pkgs; [
+ buildah
+ k9s
+ kubectl
+ kubectl-doctor
+ kubectl-images
+ kubectl-tree
+ kubectx
+ kubelogin-oidc
+ kubent
+ kubernetes-helm
+ kubespy
+ minikube
+ skopeo
+ stern
+ telepresence2
+ werf
+ ];
+ };
+
+ xdg.dataFile."minikube/config/config.json".text = generators.toJSON { } {
+ config.Rootless = true;
+ driver = "podman";
+ container-runtime = "cri-o";
+ };
+ };
+ };
+}
diff --git a/modules/profiles/dev/default.nix b/modules/profiles/dev/default.nix
new file mode 100644
index 0000000..eab447c
--- /dev/null
+++ b/modules/profiles/dev/default.nix
@@ -0,0 +1,94 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+with lib;
+let
+ cfg = config.nixfiles.modules.profiles.dev;
+in
+{
+ imports = attrValues (modulesIn ./.);
+
+ options.nixfiles.modules.profiles.dev.enable = mkEnableOption "Catch-all profile for stuff related to software development and etc.";
+
+ config = mkIf cfg.enable {
+ nixfiles.modules = {
+ bat.enable = true;
+ curl.enable = true;
+ direnv.enable = true;
+ editorconfig.enable = true;
+ git.client.enable = true;
+ nmap.enable = true;
+ wget.enable = true;
+ };
+
+ hm = {
+ home = {
+ sessionVariables = rec {
+ CABAL_DIR = "${config.dirs.data}/cabal";
+ CABAL_CONFIG = pkgs.writeText "cabal-config" ''
+ repository hackage.haskell.org
+ url: https://hackage.haskell.org/
+ secure: True
+
+ jobs: $ncpus
+
+ remote-repo-cache: ${CABAL_DIR}/packages
+
+ world-file: ${CABAL_DIR}/world
+
+ logs-dir: ${CABAL_DIR}/logs
+ build-summary: ${CABAL_DIR}/logs/build.log
+
+ installdir: ${CABAL_DIR}/bin
+ extra-prog-path: ${CABAL_DIR}/bin
+ '';
+ STACK_ROOT = "${config.dirs.data}/stack";
+
+ RUSTUP_HOME = "${config.dirs.data}/rustup";
+ CARGO_HOME = "${config.dirs.data}/cargo";
+
+ GOPATH = "${config.dirs.data}/go";
+ GORE_HOME = "${config.dirs.data}/gore";
+
+ PYTHONSTARTUP = ./pystartup.py;
+ };
+
+ packages = with pkgs; [
+ age
+ htmlq
+ httpie
+ hydra-check
+ jq
+ logcli
+ nix-update
+ nixpkgs-review
+ sops
+ yq
+ ];
+
+ language = {
+ collate = "C";
+ messages = "C";
+ };
+ };
+
+ xdg.configFile = {
+ "gdb/gdbinit".source = ./gdbinit;
+ "ghc/ghci.conf".source = ./ghci.conf;
+ };
+ };
+
+ programs.wireshark = {
+ enable = true;
+ package = pkgs.wireshark;
+ };
+
+ my.extraGroups = [
+ "kvm"
+ "wireshark"
+ ];
+ };
+}
diff --git a/modules/profiles/dev/gdbinit b/modules/profiles/dev/gdbinit
new file mode 100644
index 0000000..e266236
--- /dev/null
+++ b/modules/profiles/dev/gdbinit
@@ -0,0 +1,41 @@
+set confirm off
+set verbose off
+set editing off
+
+set history expansion on
+
+set height 0
+set width 0
+
+handle SIGALRM nostop print nopass
+handle SIGBUS stop print nopass
+handle SIGPIPE nostop print nopass
+handle SIGSEGV stop print nopass
+
+set print address on
+set print elements 0
+set print object on
+set print pretty on
+set print repeats 0
+set print static-members on
+set print vtbl on
+
+set output-radix 10
+
+set demangle-style gnu-v3
+
+set disassembly-flavor intel
+
+alias iv=info variables
+
+alias da=disassemble
+
+define fs
+ finish
+ step
+end
+
+define btc
+ backtrace
+ continue
+end
diff --git a/modules/profiles/dev/ghci.conf b/modules/profiles/dev/ghci.conf
new file mode 100644
index 0000000..d672167
--- /dev/null
+++ b/modules/profiles/dev/ghci.conf
@@ -0,0 +1,35 @@
+:set -XBinaryLiterals
+:set -XFlexibleContexts
+:set -XNoMonomorphismRestriction
+
+:seti -XConstraintKinds
+:seti -XDataKinds
+:seti -XDeriveFunctor
+:seti -XFlexibleInstances
+:seti -XFunctionalDependencies
+:seti -XGADTs
+:seti -XLambdaCase
+:seti -XMagicHash
+:seti -XMultiParamTypeClasses
+:seti -XMultiWayIf
+:seti -XOverloadedLabels
+:seti -XPackageImports
+:seti -XPolyKinds
+:seti -XRankNTypes
+:seti -XScopedTypeVariables
+:seti -XStandaloneDeriving
+:seti -XTupleSections
+:seti -XTypeFamilies
+:seti -XTypeOperators
+:seti -XUndecidableInstances
+
+:set +c
+:set +m
+:set +r
+:set +s
+:set +t
+
+:set prompt "\ESC[1;34m>\ESC[m\STX "
+:set prompt-cont "\ESC[1;94m|\ESC[m\STX "
+
+:def hoogle \x -> pure (":!hoogle --color --count=10 \"" ++ x ++ "\"")
diff --git a/modules/profiles/dev/pystartup.py b/modules/profiles/dev/pystartup.py
new file mode 100644
index 0000000..adde66c
--- /dev/null
+++ b/modules/profiles/dev/pystartup.py
@@ -0,0 +1,121 @@
+import atexit
+import os
+import readline
+import rlcompleter
+import sys
+from code import InteractiveConsole
+from tempfile import mkstemp
+
+readline.parse_and_bind("tab: complete")
+
+
+class TermColors(dict):
+ color_templates = (
+ ("Normal", "0"),
+ ("Black", "0;30"),
+ ("Red", "0;31"),
+ ("Green", "0;32"),
+ ("Brown", "0;33"),
+ ("Blue", "0;34"),
+ ("Purple", "0;35"),
+ ("Cyan", "0;36"),
+ ("LightGray", "0;37"),
+ ("DarkGray", "1;30"),
+ ("LightRed", "1;31"),
+ ("LightGreen", "1;32"),
+ ("Yellow", "1;33"),
+ ("LightBlue", "1;34"),
+ ("LightPurple", "1;35"),
+ ("LightCyan", "1;36"),
+ ("White", "1;37"),
+ )
+ color_base = "\001\033[%sm\002"
+
+ def __init__(self):
+ self.update(dict([(k, self.color_base % v) for k, v in self.color_templates]))
+
+
+class Completer(object):
+ def save_history(self):
+ import readline
+
+ readline.write_history_file(self.python_histfile)
+
+ def __init__(self):
+ self.python_dir = os.path.expanduser("%s/python" % os.environ["XDG_DATA_HOME"])
+
+ if not os.path.exists(self.python_dir):
+ os.mkdir(self.python_dir)
+
+ self.python_histfile = os.path.expanduser("%s/history" % self.python_dir)
+
+ if os.path.exists(self.python_histfile):
+ readline.read_history_file(self.python_histfile)
+
+ readline.set_history_length(1000)
+ atexit.register(self.save_history)
+
+
+def DisplayHook(value):
+ if value is not None:
+ try:
+ import __builtin__
+
+ __builtin__._ = value
+ except ImportError:
+ __builtins__._ = value
+
+ import pprint
+
+ pprint.pprint(value)
+ del pprint
+
+
+class EditableBufferInteractiveConsole(InteractiveConsole):
+ def __init__(self, *args, **kwargs):
+ self.last_buffer = []
+ InteractiveConsole.__init__(self, *args, **kwargs)
+
+ def runsource(self, source, *args):
+ self.last_buffer = [source.encode("utf-8")]
+ return InteractiveConsole.runsource(self, source, *args)
+
+ def raw_input(self, *args):
+ line = InteractiveConsole.raw_input(self, *args)
+
+ if line == EDIT_CMD:
+ tmp_fd, tmp_file = mkstemp(".py")
+
+ os.write(tmp_fd, b"\n".join(self.last_buffer))
+ os.close(tmp_fd)
+
+ os.system("%s %s" % (EDITOR, tmp_file))
+
+ line = open(tmp_file).read()
+
+ os.unlink(tmp_file)
+ tmp_file = ""
+
+ lines = line.split("\n")
+
+ for i in range(len(lines) - 1):
+ self.push(lines[i])
+
+ line = lines[-1]
+ return line
+
+
+TC = TermColors()
+ps1 = "%sλ%s %s>%s "
+sys.ps1 = ps1 % (TC["Blue"], TC["Normal"], TC["White"], TC["Normal"])
+ps2 = " %s…%s %s>%s "
+sys.ps2 = ps2 % (TC["Blue"], TC["Normal"], TC["White"], TC["Normal"])
+sys.displayhook = DisplayHook
+
+C = Completer()
+EDITOR = os.environ.get("EDITOR", "vim")
+EDIT_CMD = ":e"
+C = EditableBufferInteractiveConsole(locals=locals())
+C.interact(banner="")
+
+sys.exit()
diff --git a/modules/profiles/dev/sql.nix b/modules/profiles/dev/sql.nix
new file mode 100644
index 0000000..c2d4894
--- /dev/null
+++ b/modules/profiles/dev/sql.nix
@@ -0,0 +1,105 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+with lib;
+let
+ cfg = config.nixfiles.modules.profiles.dev.sql;
+in
+{
+ options.nixfiles.modules.profiles.dev.sql.enable =
+ mkEnableOption "SQL stuff and database management tools"
+ // {
+ default = config.nixfiles.modules.profiles.dev.enable;
+ };
+
+ config = mkIf cfg.enable {
+ hm = {
+ home.packages = with pkgs; [
+ pgcli
+ litecli
+ ];
+
+ xdg =
+ let
+ mainSection = {
+ destructive_warning = "True";
+ enable_pager = "True";
+ keyword_casing = "auto";
+ less_chatty = "True";
+ log_file = "/dev/null";
+ log_level = "CRITICAL";
+ multi_line = "False";
+ syntax_style = "default";
+ table_format = "fancy_grid";
+ };
+
+ colorsSection = with config.colors.withHashtag; {
+ "arg-toolbar" = "noinherit bold";
+ "arg-toolbar.text" = "nobold";
+ "bottom-toolbar" = "bg:${base01} ${base06}";
+ "bottom-toolbar.off" = "bg:${base01} ${base02}";
+ "bottom-toolbar.on" = "bg:${base01} ${base07}";
+ "bottom-toolbar.transaction.failed" = "bg:${base01} ${base08} bold";
+ "bottom-toolbar.transaction.valid" = "bg:${base01} ${base0B} bold";
+ "completion-menu.completion" = "bg:${base01} ${base06}";
+ "completion-menu.completion.current" = "bg:${base06} ${base01}";
+ "completion-menu.meta.completion" = "bg:${base01} ${base13}";
+ "completion-menu.meta.completion.current" = "bg:${base09} ${base01}";
+ "completion-menu.multi-column-meta" = "bg:${base09} ${base01}";
+ "scrollbar" = "bg:${base01}";
+ "scrollbar.arrow" = "bg:${base01}";
+ "search" = "bg:${base17} ${base07}";
+ "search-toolbar" = "noinherit bold";
+ "search-toolbar.text" = "nobold";
+ "search.current" = "bg:${base14} ${base07}";
+ "selected" = "bg:${base0D} ${base07}";
+ "system-toolbar" = "noinherit bold";
+ };
+
+ mkCliConfig =
+ { name, custom }:
+ {
+ "${name}/config" = {
+ text = generators.toINI { } {
+ main = mainSection // custom;
+ colors = mapAttrs (_: v: "'${v}'") colorsSection;
+ };
+ };
+ };
+ in
+ {
+ configFile = mkMerge (
+ map mkCliConfig [
+ {
+ name = "pgcli";
+ custom = {
+ prompt = "'\\u@\\h:\\d> '";
+ multi_line_mode = "psql";
+ on_error = "STOP";
+ auto_expand = "True";
+ expand = "True";
+ keyring = "False";
+ vi = "True";
+ casing_file = "/dev/null";
+ history_file = "/dev/null";
+ };
+ }
+ {
+ name = "litecli";
+ custom = {
+ prompt = "'\\d> '";
+ prompt_continuation = "'-> '";
+ auto_vertical_output = "True";
+ key_bindings = "vi";
+ audit_log = "/dev/null";
+ };
+ }
+ ]
+ );
+ };
+ };
+ };
+}