about summary refs log tree commit diff
path: root/modules/common/profiles/dev
diff options
context:
space:
mode:
Diffstat (limited to 'modules/common/profiles/dev')
-rw-r--r--modules/common/profiles/dev/containers.nix76
-rw-r--r--modules/common/profiles/dev/default.nix89
-rw-r--r--modules/common/profiles/dev/editorconfig.ini83
-rw-r--r--modules/common/profiles/dev/gdbinit41
-rw-r--r--modules/common/profiles/dev/ghci.conf35
-rw-r--r--modules/common/profiles/dev/pystartup.py121
-rw-r--r--modules/common/profiles/dev/sql.nix101
7 files changed, 546 insertions, 0 deletions
diff --git a/modules/common/profiles/dev/containers.nix b/modules/common/profiles/dev/containers.nix
new file mode 100644
index 0000000..cc24ab3
--- /dev/null
+++ b/modules/common/profiles/dev/containers.nix
@@ -0,0 +1,76 @@
+{
+  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.default.enable;
+    };
+
+  config = mkIf cfg.enable {
+    hm = {
+      home = {
+        sessionVariables = {
+          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; [
+          argocd
+          chart-testing
+          clusterctl
+          cmctl
+          datree
+          helm
+          istioctl
+          kubeconform
+          kubectl
+          kubectl-doctor
+          kubectl-images
+          kubectl-tree
+          kubectx
+          kubelogin
+          kubent
+          kubescape
+          kubeseal
+          kubespy
+          minikube
+          skaffold
+          skopeo
+          stern
+          telepresence
+          werf
+        ];
+      };
+
+      programs.bash = {
+        shellAliases = with pkgs; {
+          b = "${buildah}/bin/buildah";
+          h = "${helm}/bin/helm";
+          k = "${kubectl}/bin/kubectl";
+          kns = "${kubectx}/bin/kubens";
+          ktx = "${kubectx}/bin/kubectx";
+        };
+        initExtra = mkAfter ''
+          _complete_alias b _buildah buildah
+          _complete_alias h __start_helm helm
+          _complete_alias k __start_kubectl kubectl
+          _complete_alias kns _kube_namespaces kubens
+          _complete_alias ktx _kube_contexts kubectx
+        '';
+      };
+    };
+  };
+}
diff --git a/modules/common/profiles/dev/default.nix b/modules/common/profiles/dev/default.nix
new file mode 100644
index 0000000..b05aeac
--- /dev/null
+++ b/modules/common/profiles/dev/default.nix
@@ -0,0 +1,89 @@
+{
+  config,
+  lib,
+  pkgs,
+  this,
+  ...
+}:
+with lib; let
+  cfg = config.nixfiles.modules.profiles.dev.default;
+in {
+  imports = [
+    ./containers.nix
+    ./sql.nix
+  ];
+
+  options.nixfiles.modules.profiles.dev.default.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;
+      git.client.enable = true;
+      gnupg.enable = true;
+      nmap.enable = true;
+      wget.enable = true;
+    };
+
+    hm.home = {
+      file = {
+        ".editorconfig".source = ./editorconfig.ini;
+
+        ".gdbinit".source = ./gdbinit;
+
+        ".ghc/ghci.conf".source = ./ghci.conf;
+
+        ".stack/config.yaml".text = generators.toYAML {} {
+          templates.params = rec {
+            author-name = my.fullname;
+            author-email = my.email;
+            copyright = "Copyright (c) ${author-name} <${author-email}>";
+            github-username = my.username;
+          };
+        };
+
+        ".stack/global-project/stack.yaml".text = generators.toYAML {} {
+          packages = [];
+          resolver = "lts-20.3";
+        };
+      };
+
+      sessionVariables = with config.dirs; rec {
+        CABAL_DIR = "${config.my.home}/.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.my.home}/.stack";
+
+        CARGO_HOME = "${config.my.home}/.cargo";
+
+        GOPATH = "${config.my.home}/.go";
+
+        PYTHONSTARTUP = ./pystartup.py;
+      };
+
+      packages = with pkgs; [
+        htmlq
+        jq
+        yq
+      ];
+    };
+  };
+}
diff --git a/modules/common/profiles/dev/editorconfig.ini b/modules/common/profiles/dev/editorconfig.ini
new file mode 100644
index 0000000..17b0317
--- /dev/null
+++ b/modules/common/profiles/dev/editorconfig.ini
@@ -0,0 +1,83 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+max_line_length = 80
+trim_trailing_whitespace = true
+
+[*.nix]
+indent_size = 2
+indent_style = space
+
+[*.{S,s,asm}]
+indent_size = 4
+indent_style = tab
+
+[*.{C,H,c,c++,cc,cpp,cxx,h,h++,hh,hpp,hxx}]
+indent_size = 4
+indent_style = tab
+
+[*.{cl,clj,el,l,lisp,lsp,rkt,scm,ss}]
+indent_size = 2
+indent_style = space
+
+[*.go]
+indent_size = 4
+indent_style = tab
+
+[*.{py,pyx}]
+indent_size = 4
+indent_style = space
+
+[*.{hs,lhs}]
+indent_size = 2
+indent_style = space
+
+[*.{html,xhtml,xml}]
+indent_size = 4
+indent_style = tab
+
+[*.json]
+indent_size = 2
+indent_style = space
+
+[*.{yaml,yml}]
+indent_size = 2
+indent_style = space
+
+[*.{toml,tml}]
+indent_size = 4
+indent_style = space
+
+[*.{py,pyx}]
+indent_size = 4
+indent_style = space
+max_line_length = 72
+
+[*.zig]
+indent_size = 4
+indent_style = tab
+
+[configure.ac]
+indent_size = 4
+indent_style = tab
+
+[{Makefile*,*.mk}]
+indent_size = 4
+indent_style = tab
+
+[{CMakeLists.txt,*.cmake}]
+indent_size = 8
+indent_style = tab
+
+[*.tex]
+indent_size = 4
+indent_style = tab
+
+[*.{md,adoc,rtf,txt}]
+indent_size = 4
+indent_style = tab
diff --git a/modules/common/profiles/dev/gdbinit b/modules/common/profiles/dev/gdbinit
new file mode 100644
index 0000000..e266236
--- /dev/null
+++ b/modules/common/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/common/profiles/dev/ghci.conf b/modules/common/profiles/dev/ghci.conf
new file mode 100644
index 0000000..d672167
--- /dev/null
+++ b/modules/common/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/common/profiles/dev/pystartup.py b/modules/common/profiles/dev/pystartup.py
new file mode 100644
index 0000000..adde66c
--- /dev/null
+++ b/modules/common/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/common/profiles/dev/sql.nix b/modules/common/profiles/dev/sql.nix
new file mode 100644
index 0000000..7a2a09c
--- /dev/null
+++ b/modules/common/profiles/dev/sql.nix
@@ -0,0 +1,101 @@
+{
+  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.default.enable;
+    };
+
+  config = mkIf cfg.enable {
+    hm = {
+      home.packages = with pkgs; [
+        dbeaver
+        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.colourScheme; {
+          "arg-toolbar" = "noinherit bold";
+          "arg-toolbar.text" = "nobold";
+          "bottom-toolbar" = "bg:${black} ${white}";
+          "bottom-toolbar.off" = "bg:${black} ${brightBlack}";
+          "bottom-toolbar.on" = "bg:${black} ${brightWhite}";
+          "bottom-toolbar.transaction.failed" = "bg:${black} ${red} bold";
+          "bottom-toolbar.transaction.valid" = "bg:${black} ${green} bold";
+          "completion-menu.completion" = "bg:${black} ${white}";
+          "completion-menu.completion.current" = "bg:${white} ${black}";
+          "completion-menu.meta.completion" = "bg:${black} ${yellow}";
+          "completion-menu.meta.completion.current" = "bg:${yellow} ${black}";
+          "completion-menu.multi-column-meta" = "bg:${yellow} ${black}";
+          "scrollbar" = "bg:${black}";
+          "scrollbar.arrow" = "bg:${black}";
+          "search" = "bg:${magenta} ${brightWhite}";
+          "search-toolbar" = "noinherit bold";
+          "search-toolbar.text" = "nobold";
+          "search.current" = "bg:${green} ${brightWhite}";
+          "selected" = "bg:${blue} ${brightWhite}";
+          "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 = {
+              auto_expand = "True";
+              casing_file = "/dev/null";
+              expand = "True";
+              history_file = "/dev/null";
+              keyring = "False";
+              multi_line_mode = "psql";
+              on_error = "STOP";
+              prompt = "'\\u@\\h:\\d> '";
+              vi = "True";
+            };
+          }
+          {
+            name = "litecli";
+            custom = {
+              audit_log = "/dev/null";
+              key_bindings = "vi";
+              prompt = "'\\d> '";
+              prompt_continuation = "'-> '";
+              auto_vertical_output = "True";
+            };
+          }
+        ]);
+      };
+    };
+  };
+}

Consider giving Nix/NixOS a try! <3