From 6a02d658dde1fd5e9d9e84478796b6881b236578 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Wed, 14 Sep 2022 12:08:10 +0300 Subject: 2022-09-14 --- modules/nixfiles/alacritty.nix | 2 +- modules/nixfiles/common/nix/default.nix | 17 +- modules/nixfiles/common/xdg.nix | 67 ++--- modules/nixfiles/games/minecraft.nix | 12 +- modules/nixfiles/profiles/common.nix | 106 -------- modules/nixfiles/profiles/default.nix | 109 +++++++- modules/nixfiles/profiles/dev/common.nix | 267 -------------------- modules/nixfiles/profiles/dev/containers.nix | 77 ++++++ .../nixfiles/profiles/dev/containers/default.nix | 77 ------ modules/nixfiles/profiles/dev/default.nix | 274 ++++++++++++++++++++- modules/nixfiles/profiles/dev/sql.nix | 97 ++++++++ modules/nixfiles/profiles/dev/sql/default.nix | 94 ------- modules/nixfiles/profiles/headful.nix | 15 +- modules/nixfiles/profiles/headless.nix | 13 +- modules/nixfiles/x11.nix | 4 +- modules/nixfiles/zathura.nix | 6 +- 16 files changed, 612 insertions(+), 625 deletions(-) delete mode 100644 modules/nixfiles/profiles/common.nix delete mode 100644 modules/nixfiles/profiles/dev/common.nix create mode 100644 modules/nixfiles/profiles/dev/containers.nix delete mode 100644 modules/nixfiles/profiles/dev/containers/default.nix create mode 100644 modules/nixfiles/profiles/dev/sql.nix delete mode 100644 modules/nixfiles/profiles/dev/sql/default.nix (limited to 'modules') diff --git a/modules/nixfiles/alacritty.nix b/modules/nixfiles/alacritty.nix index 4afd11b..728e6ee 100644 --- a/modules/nixfiles/alacritty.nix +++ b/modules/nixfiles/alacritty.nix @@ -43,7 +43,7 @@ in { }; inherit size; }; - colors = with profiles.common.colourScheme; { + colors = with config.colourScheme; { primary = {inherit background foreground;}; cursor = { text = "CellBackground"; diff --git a/modules/nixfiles/common/nix/default.nix b/modules/nixfiles/common/nix/default.nix index 550749a..9fc585b 100644 --- a/modules/nixfiles/common/nix/default.nix +++ b/modules/nixfiles/common/nix/default.nix @@ -14,10 +14,9 @@ with lib; { _module.args = let importNixpkgs = nixpkgs: - import nixpkgs { - inherit (config.nixpkgs) localSystem crossSystem config; - }; + import nixpkgs {inherit (config.nixpkgs) config localSystem;}; in rec { + pkgsLocal = importNixpkgs "${config.my.home}/src/nixpkgs"; # Impure! pkgsMaster = importNixpkgs inputs.nixpkgs-master; pkgsStable = importNixpkgs inputs.nixpkgs-stable; pkgsRev = rev: hash: @@ -27,7 +26,6 @@ with lib; { inherit rev hash; }); pkgsPR = pr: pkgsRev "refs/pull/${toString pr}/head"; - pkgsLocal = importNixpkgs "${config.my.home}/src/nixpkgs"; }; nix = let @@ -51,9 +49,7 @@ with lib; { registry = mapAttrs (_: flake: {inherit flake;}) filteredInputs - // { - nixfiles.flake = inputs.self; - }; + // {nixfiles.flake = inputs.self;}; settings = { trusted-users = ["root" "@wheel"]; @@ -96,7 +92,7 @@ with lib; { // (with super; let np = nodePackages; in { - # Normalises package names. + # Normalises package names. This is done purely for aesthetics. dockerfile-language-server = np.dockerfile-language-server-nodejs; editorconfig = editorconfig-core-c; inherit (np) bash-language-server; @@ -113,6 +109,7 @@ with lib; { emacs-overlay.overlay nix-minecraft-servers.overlays.default nur.overlay + pollymc.overlay xmonad-ng.overlays.default ]; @@ -123,9 +120,9 @@ with lib; { localBinInPath = true; - defaultPackages = mkForce []; + defaultPackages = []; systemPackages = with pkgs; - optionals config.profile.headful [ + optionals this.isHeadful [ nix-top nix-tree ]; diff --git a/modules/nixfiles/common/xdg.nix b/modules/nixfiles/common/xdg.nix index 72a8e4c..60d5286 100644 --- a/modules/nixfiles/common/xdg.nix +++ b/modules/nixfiles/common/xdg.nix @@ -38,45 +38,50 @@ with lib; { }; } (mkIf this.isHeadful { - mimeApps = let - images = [ - "image/bmp" - "image/gif" - "image/jpeg" - "image/jpg" - "image/png" - "image/svg+xml" - "image/tiff" - "image/webp" - ]; - media = [ - "audio/aac" - "audio/flac" - "audio/mp3" - "audio/ogg" - "audio/wav" - "audio/webm" - "video/mkv" - "video/mp4" - "video/ogg" - "video/webm" - "video/x-matroska" - ]; - in { + mimeApps = { enable = true; - defaultApplications = mkMerge (mapAttrsToList - (n: ms: genAttrs ms (_: ["${n}.desktop"])) + (n: v: genAttrs v (_: ["${n}.desktop"])) { - aria2 = ["application/x-bittorrent" "x-scheme-handler/magnet"]; - emacsclient = ["x-scheme-handler/mailto"]; + emacsclient = [ + "application/json" + "application/vnd.ms-publisher" + "application/x-desktop" + "application/x-shellscript" + "application/x-trash" + "application/x-wine-extension-ini" + "application/xml" + "text/markdown" + "text/plain" + ]; firefox = [ "text/html" "x-scheme-handler/http" "x-scheme-handler/https" ]; - gwenview = images; - mpv = media; + gwenview = [ + "image/bmp" + "image/gif" + "image/jpeg" + "image/jpg" + "image/png" + "image/svg+xml" + "image/tiff" + "image/webp" + ]; + mpv = [ + "audio/aac" + "audio/flac" + "audio/mp3" + "audio/ogg" + "audio/wav" + "audio/webm" + "video/mkv" + "video/mp4" + "video/ogg" + "video/webm" + "video/x-matroska" + ]; }); }; }) diff --git a/modules/nixfiles/games/minecraft.nix b/modules/nixfiles/games/minecraft.nix index 2fc9bd8..e53f9eb 100644 --- a/modules/nixfiles/games/minecraft.nix +++ b/modules/nixfiles/games/minecraft.nix @@ -2,7 +2,6 @@ config, lib, pkgs, - pkgsPR, ... }: with lib; let @@ -21,16 +20,13 @@ in { }; }; - # Configurations, opslist, whitelist and plugins are managed imperatively. - # TODO Make it declarative. config = mkMerge [ (mkIf cfg.client.enable { - hm.home.packages = with pkgs; [ - UltimMC # I refuse to use a Microsoft account. Using GitHub is painful enough. - jre # Unfortunately, this cannot be provided as a PATH injection to UltimMC. - ]; + hm.home.packages = with pkgs; [pollymc]; }) (mkIf cfg.server.enable { + # Configurations, opslist, whitelist and plugins are managed imperatively. + # TODO Make it declarative. services.minecraft-server = { enable = true; eula = true; @@ -47,7 +43,7 @@ in { + " "; }; - # Found in /var/lib/minecraft/server.properties. + # Defined in /var/lib/minecraft/server.properties. networking.firewall.allowedTCPPorts = [55565]; }) ]; diff --git a/modules/nixfiles/profiles/common.nix b/modules/nixfiles/profiles/common.nix deleted file mode 100644 index 3f77da6..0000000 --- a/modules/nixfiles/profiles/common.nix +++ /dev/null @@ -1,106 +0,0 @@ -{ - config, - lib, - pkgs, - this, - ... -}: -with lib; let - cfg = config.nixfiles.modules.profiles.common; -in { - imports = [ - (mkAliasOptionModule ["colourScheme"] [ - "nixfiles" - "modules" - "profiles" - "common" - "colourScheme" - ]) - ]; - - options.nixfiles.modules.profiles.common = { - enable = mkEnableOption "The most common profiles of all profiles."; - - colourScheme = let - mkColour = default: - mkOption { - type = types.str; - inherit default; - description = "Color in a standard hexademical notation."; - example = "#000000"; - }; - in rec { - black = mkColour "#161719"; - red = mkColour "#cc6666"; - green = mkColour "#b5bd68"; - yellow = mkColour "#f0c674"; - blue = mkColour "#81a2be"; - magenta = mkColour "#b294bb"; - cyan = mkColour "#8abeb7"; - white = mkColour "#c5c8c6"; - - brightBlack = mkColour "#969896"; - brightRed = mkColour "#cc6666"; - brightGreen = mkColour "#b5bd68"; - brightYellow = mkColour "#f0c674"; - brightBlue = mkColour "#81a2be"; - brightMagenta = mkColour "#b294bb"; - brightCyan = mkColour "#8abeb7"; - brightWhite = mkColour "#ffffff"; - - background = black; - foreground = white; - }; - }; - - config = mkIf cfg.enable { - assertions = [ - { - assertion = !(with this; isHeadless && isHeadful); - message = '' - The configuration cannot be both "headful" and "headless" at the same - time. - ''; - } - ]; - - profile = with this; { - headless = isHeadless; - headful = isHeadful; - }; - - nixfiles.modules = { - htop.enable = true; - tmux.enable = true; - vim.enable = true; - }; - - home-manager.users.root.home.file.".bash_history".source = - config.hm.lib.file.mkOutOfStoreSymlink "/dev/null"; - - hm.home.language = { - collate = "C"; - messages = "C"; - }; - - programs.less = { - enable = true; - envVariables.LESSHISTFILE = "-"; - }; - - environment.systemPackages = with pkgs; [ - cryptsetup - ddrescue - file - git - gnupg - lshw - lsof - pciutils - psmisc - tree - usbutils - util-linux - ]; - }; -} diff --git a/modules/nixfiles/profiles/default.nix b/modules/nixfiles/profiles/default.nix index 3df88f8..c236722 100644 --- a/modules/nixfiles/profiles/default.nix +++ b/modules/nixfiles/profiles/default.nix @@ -1,5 +1,108 @@ -{lib, ...}: { - imports = [./common.nix ./dev ./headful.nix ./headless.nix]; +{ + config, + lib, + pkgs, + this, + ... +}: +with lib; let + cfg = config.nixfiles.modules.profiles.default; +in { + imports = [ + ./dev + ./headful.nix + ./headless.nix + (mkAliasOptionModule ["colourScheme"] [ + "nixfiles" + "modules" + "profiles" + "default" + "colourScheme" + ]) + ]; - config.nixfiles.modules.profiles.common.enable = lib.mkDefault true; + options.nixfiles.modules.profiles.default = { + enable = + mkEnableOption "The most default profile of them all." + // { + default = true; + }; + + colourScheme = let + mkColour = default: + mkOption { + type = types.str; + inherit default; + description = "Colour in a standard hexadecimal notation."; + example = "#000000"; + }; + in rec { + black = mkColour "#161719"; + red = mkColour "#cc6666"; + green = mkColour "#b5bd68"; + yellow = mkColour "#f0c674"; + blue = mkColour "#81a2be"; + magenta = mkColour "#b294bb"; + cyan = mkColour "#8abeb7"; + white = mkColour "#c5c8c6"; + + brightBlack = mkColour "#969896"; + brightRed = mkColour "#cc6666"; + brightGreen = mkColour "#b5bd68"; + brightYellow = mkColour "#f0c674"; + brightBlue = mkColour "#81a2be"; + brightMagenta = mkColour "#b294bb"; + brightCyan = mkColour "#8abeb7"; + brightWhite = mkColour "#ffffff"; + + background = black; + foreground = white; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + { + assertion = !(with this; isHeadless && isHeadful); + message = '' + The configuration cannot be both "headful" and "headless" at the same + time. + ''; + } + ]; + + nixfiles.modules = { + htop.enable = true; + tmux.enable = true; + vim.enable = true; + }; + + home-manager.users.root.home.file.".bash_history".source = + config.hm.lib.file.mkOutOfStoreSymlink "/dev/null"; + + hm.home.language = { + collate = "C"; + messages = "C"; + }; + + programs.less = { + enable = true; + envVariables.LESSHISTFILE = "-"; + }; + + environment.systemPackages = with pkgs; [ + cryptsetup + ddrescue + file + git + gnupg + lshw + lsof + pciutils + psmisc + tree + usbutils + util-linux + ]; + }; } diff --git a/modules/nixfiles/profiles/dev/common.nix b/modules/nixfiles/profiles/dev/common.nix deleted file mode 100644 index 497a573..0000000 --- a/modules/nixfiles/profiles/dev/common.nix +++ /dev/null @@ -1,267 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.nixfiles.modules.profiles.dev.common; -in { - options.nixfiles.modules.profiles.dev.common.enable = mkEnableOption ""; - - config = mkIf cfg.enable { - nixfiles.modules = { - bat.enable = true; - curl.enable = true; - direnv.enable = true; - git.enable = true; - gnupg.enable = true; - nmap.enable = true; - wget.enable = true; - }; - - hm.home = { - file = { - ".editorconfig".text = '' - 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 - ''; - - ".ghc/ghci.conf".source = ./ghci.conf; - - "${config.dirs.data}/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; - }; - }; - - ".clang-format".text = generators.toYAML {} { - AccessModifierOffset = -4; - AlignAfterOpenBracket = "Align"; - AlignConsecutiveAssignments = "Consecutive"; - AlignConsecutiveBitFields = "Consecutive"; - AlignConsecutiveDeclarations = "Consecutive"; - AlignConsecutiveMacros = "Consecutive"; - AlignEscapedNewlines = "Right"; - AlignOperands = "Align"; - AlignTrailingComments = false; - AllowAllArgumentsOnNextLine = false; - AllowAllConstructorInitializersOnNextLine = true; - AllowAllParametersOfDeclarationOnNextLine = true; - AllowShortBlocksOnASingleLine = "Never"; - AllowShortCaseLabelsOnASingleLine = false; - AllowShortEnumsOnASingleLine = false; - AllowShortFunctionsOnASingleLine = "None"; - AllowShortIfStatementsOnASingleLine = "Never"; - AllowShortLambdasOnASingleLine = "Inline"; - AllowShortLoopsOnASingleLine = false; - AlwaysBreakAfterDefinitionReturnType = "All"; - AlwaysBreakAfterReturnType = "AllDefinitions"; - AlwaysBreakBeforeMultilineStrings = false; - AlwaysBreakTemplateDeclarations = "Yes"; - BinPackArguments = false; - BinPackParameters = false; - BreakBeforeBinaryOperators = "None"; - BreakBeforeBraces = "Allman"; - BreakBeforeTernaryOperators = true; - BreakConstructorInitializers = "BeforeComma"; - BreakInheritanceList = "BeforeComma"; - BreakStringLiterals = true; - ColumnLimit = 80; - CommentPragmas = "^ IWYU pragma:"; - CompactNamespaces = false; - ConstructorInitializerAllOnOneLineOrOnePerLine = false; - ConstructorInitializerIndentWidth = 4; - ContinuationIndentWidth = 4; - Cpp11BracedListStyle = true; - DeriveLineEnding = false; - DerivePointerAlignment = false; - DisableFormat = false; - ExperimentalAutoDetectBinPacking = false; - FixNamespaceComments = true; - IncludeBlocks = "Regroup"; - IndentCaseBlocks = false; - IndentCaseLabels = false; - IndentExternBlock = "NoIndent"; - IndentGotoLabels = false; - IndentPPDirectives = "None"; - IndentWidth = 4; - IndentWrappedFunctionNames = false; - KeepEmptyLinesAtTheStartOfBlocks = false; - Language = "Cpp"; - MaxEmptyLinesToKeep = 1; - NamespaceIndentation = "None"; - PointerAlignment = "Left"; - ReflowComments = false; - SortIncludes = "CaseSensitive"; - SortUsingDeclarations = true; - SpaceAfterCStyleCast = false; - SpaceAfterLogicalNot = false; - SpaceAfterTemplateKeyword = true; - SpaceBeforeAssignmentOperators = true; - SpaceBeforeCpp11BracedList = false; - SpaceBeforeCtorInitializerColon = true; - SpaceBeforeInheritanceColon = true; - SpaceBeforeParens = "ControlStatements"; - SpaceBeforeRangeBasedForLoopColon = true; - SpaceInEmptyParentheses = false; - SpacesBeforeTrailingComments = 1; - SpacesInAngles = false; - SpacesInCStyleCastParentheses = false; - SpacesInContainerLiterals = false; - SpacesInParentheses = false; - SpacesInSquareBrackets = false; - Standard = "Latest"; - TabWidth = 4; - UseTab = "Always"; - }; - - ".gdbinit".text = '' - 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 - ''; - }; - - sessionVariables = with config.dirs; { - ANDROID_HOME = "${data}/android"; - CABAL_CONFIG = "${data}/cabal/config"; - CABAL_DIR = "${data}/cabal"; - CARGO_HOME = "${data}/cargo"; - GOPATH = "${data}/go"; - PYTHONSTARTUP = ./pystartup.py; - STACK_ROOT = "${data}/stack"; - }; - - packages = with pkgs; [ - htmlq - jq - yq - ]; - }; - - my.extraGroups = ["kvm"]; - }; -} diff --git a/modules/nixfiles/profiles/dev/containers.nix b/modules/nixfiles/profiles/dev/containers.nix new file mode 100644 index 0000000..c9e82d7 --- /dev/null +++ b/modules/nixfiles/profiles/dev/containers.nix @@ -0,0 +1,77 @@ +{ + 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 { + nixfiles.modules.podman.enable = true; + + hm = let + minikubeHome = "${config.dirs.data}/minikube"; + in { + home = { + sessionVariables = { + MINIKUBE_HOME = minikubeHome; + 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; + }; + + file."${minikubeHome}/config/config.json".text = generators.toJSON {} { + config.Rootless = true; + driver = "podman"; + container-runtime = "cri-o"; + }; + + packages = with pkgs; [ + buildah + chart-testing + cmctl + helm + kubectl + kubectx + kubescape + 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/nixfiles/profiles/dev/containers/default.nix b/modules/nixfiles/profiles/dev/containers/default.nix deleted file mode 100644 index c03a30c..0000000 --- a/modules/nixfiles/profiles/dev/containers/default.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.nixfiles.modules.profiles.dev.containers; -in { - options.nixfiles.modules.profiles.dev.containers.enable = - mkEnableOption "Wether to enable tools for working with Kubernetes."; - - config = mkIf cfg.enable { - nixfiles.modules = { - profiles.dev.common.enable = true; - podman.enable = true; - }; - - hm = let - minikubeHome = "${config.dirs.data}/minikube"; - in { - home = { - sessionVariables = { - MINIKUBE_HOME = minikubeHome; - 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; - }; - - file."${minikubeHome}/config/config.json".text = generators.toJSON {} { - config.Rootless = true; - driver = "podman"; - container-runtime = "cri-o"; - }; - - packages = with pkgs; [ - buildah - chart-testing - cmctl - helm - kubectl - kubectx - kubescape - 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/nixfiles/profiles/dev/default.nix b/modules/nixfiles/profiles/dev/default.nix index 1e0bd01..14c0730 100644 --- a/modules/nixfiles/profiles/dev/default.nix +++ b/modules/nixfiles/profiles/dev/default.nix @@ -1 +1,273 @@ -_: {imports = [./common.nix ./containers ./sql];} +{ + config, + lib, + pkgs, + ... +}: +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.enable = true; + gnupg.enable = true; + nmap.enable = true; + wget.enable = true; + }; + + hm.home = { + file = { + ".editorconfig".text = '' + 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 + ''; + + ".ghc/ghci.conf".source = ./ghci.conf; + + "${config.dirs.data}/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; + }; + }; + + ".clang-format".text = generators.toYAML {} { + AccessModifierOffset = -4; + AlignAfterOpenBracket = "Align"; + AlignConsecutiveAssignments = "Consecutive"; + AlignConsecutiveBitFields = "Consecutive"; + AlignConsecutiveDeclarations = "Consecutive"; + AlignConsecutiveMacros = "Consecutive"; + AlignEscapedNewlines = "Right"; + AlignOperands = "Align"; + AlignTrailingComments = false; + AllowAllArgumentsOnNextLine = false; + AllowAllConstructorInitializersOnNextLine = true; + AllowAllParametersOfDeclarationOnNextLine = true; + AllowShortBlocksOnASingleLine = "Never"; + AllowShortCaseLabelsOnASingleLine = false; + AllowShortEnumsOnASingleLine = false; + AllowShortFunctionsOnASingleLine = "None"; + AllowShortIfStatementsOnASingleLine = "Never"; + AllowShortLambdasOnASingleLine = "Inline"; + AllowShortLoopsOnASingleLine = false; + AlwaysBreakAfterDefinitionReturnType = "All"; + AlwaysBreakAfterReturnType = "AllDefinitions"; + AlwaysBreakBeforeMultilineStrings = false; + AlwaysBreakTemplateDeclarations = "Yes"; + BinPackArguments = false; + BinPackParameters = false; + BreakBeforeBinaryOperators = "None"; + BreakBeforeBraces = "Allman"; + BreakBeforeTernaryOperators = true; + BreakConstructorInitializers = "BeforeComma"; + BreakInheritanceList = "BeforeComma"; + BreakStringLiterals = true; + ColumnLimit = 80; + CommentPragmas = "^ IWYU pragma:"; + CompactNamespaces = false; + ConstructorInitializerAllOnOneLineOrOnePerLine = false; + ConstructorInitializerIndentWidth = 4; + ContinuationIndentWidth = 4; + Cpp11BracedListStyle = true; + DeriveLineEnding = false; + DerivePointerAlignment = false; + DisableFormat = false; + ExperimentalAutoDetectBinPacking = false; + FixNamespaceComments = true; + IncludeBlocks = "Regroup"; + IndentCaseBlocks = false; + IndentCaseLabels = false; + IndentExternBlock = "NoIndent"; + IndentGotoLabels = false; + IndentPPDirectives = "None"; + IndentWidth = 4; + IndentWrappedFunctionNames = false; + KeepEmptyLinesAtTheStartOfBlocks = false; + Language = "Cpp"; + MaxEmptyLinesToKeep = 1; + NamespaceIndentation = "None"; + PointerAlignment = "Left"; + ReflowComments = false; + SortIncludes = "CaseSensitive"; + SortUsingDeclarations = true; + SpaceAfterCStyleCast = false; + SpaceAfterLogicalNot = false; + SpaceAfterTemplateKeyword = true; + SpaceBeforeAssignmentOperators = true; + SpaceBeforeCpp11BracedList = false; + SpaceBeforeCtorInitializerColon = true; + SpaceBeforeInheritanceColon = true; + SpaceBeforeParens = "ControlStatements"; + SpaceBeforeRangeBasedForLoopColon = true; + SpaceInEmptyParentheses = false; + SpacesBeforeTrailingComments = 1; + SpacesInAngles = false; + SpacesInCStyleCastParentheses = false; + SpacesInContainerLiterals = false; + SpacesInParentheses = false; + SpacesInSquareBrackets = false; + Standard = "Latest"; + TabWidth = 4; + UseTab = "Always"; + }; + + ".gdbinit".text = '' + 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 + ''; + }; + + sessionVariables = with config.dirs; { + ANDROID_HOME = "${data}/android"; + CABAL_CONFIG = "${data}/cabal/config"; + CABAL_DIR = "${data}/cabal"; + CARGO_HOME = "${data}/cargo"; + GOPATH = "${data}/go"; + PYTHONSTARTUP = ./pystartup.py; + STACK_ROOT = "${data}/stack"; + }; + + packages = with pkgs; [ + htmlq + jq + yq + ]; + }; + + my.extraGroups = ["kvm"]; + }; +} diff --git a/modules/nixfiles/profiles/dev/sql.nix b/modules/nixfiles/profiles/dev/sql.nix new file mode 100644 index 0000000..d6bcba8 --- /dev/null +++ b/modules/nixfiles/profiles/dev/sql.nix @@ -0,0 +1,97 @@ +{ + 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; [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"; + }; + } + ]); + }; + }; + }; +} diff --git a/modules/nixfiles/profiles/dev/sql/default.nix b/modules/nixfiles/profiles/dev/sql/default.nix deleted file mode 100644 index e448e08..0000000 --- a/modules/nixfiles/profiles/dev/sql/default.nix +++ /dev/null @@ -1,94 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.nixfiles.modules.profiles.dev.sql; -in { - options.nixfiles.modules.profiles.dev.sql.enable = - mkEnableOption "SQL database management tools"; - - 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.nixfiles.modules.profiles.common.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"; - }; - } - ]); - }; - }; - }; -} diff --git a/modules/nixfiles/profiles/headful.nix b/modules/nixfiles/profiles/headful.nix index 94c0d28..f4d3dc9 100644 --- a/modules/nixfiles/profiles/headful.nix +++ b/modules/nixfiles/profiles/headful.nix @@ -2,26 +2,19 @@ config, lib, pkgs, + this, ... }: with lib; let cfg = config.nixfiles.modules.profiles.headful; in { - imports = [ - (mkAliasOptionModule ["profile" "headful"] [ - "nixfiles" - "modules" - "profiles" - "headful" - "enable" - ]) - ]; - options.nixfiles.modules.profiles.headful.enable = - mkEnableOption "headful profile"; + mkEnableOption "headful profile" // {default = this.isHeadful;}; config = mkIf cfg.enable { nixfiles.modules = { + profiles.dev.default.enable = true; + alacritty.enable = true; aria2.enable = true; chromium.enable = true; diff --git a/modules/nixfiles/profiles/headless.nix b/modules/nixfiles/profiles/headless.nix index b3c5c86..6ac91c1 100644 --- a/modules/nixfiles/profiles/headless.nix +++ b/modules/nixfiles/profiles/headless.nix @@ -2,23 +2,14 @@ config, lib, pkgs, + this, ... }: with lib; let cfg = config.nixfiles.modules.profiles.headless; in { - imports = [ - (mkAliasOptionModule ["profile" "headless"] [ - "nixfiles" - "modules" - "profiles" - "headless" - "enable" - ]) - ]; - options.nixfiles.modules.profiles.headless.enable = - mkEnableOption "headless profile"; + mkEnableOption "headless profile" // {default = this.isHeadless;}; config = mkIf cfg.enable { nixfiles.modules = { diff --git a/modules/nixfiles/x11.nix b/modules/nixfiles/x11.nix index 03c11cb..cd8dfbe 100644 --- a/modules/nixfiles/x11.nix +++ b/modules/nixfiles/x11.nix @@ -20,7 +20,7 @@ in { xsession.scriptPath = ".xinitrc"; - xresources.properties = with config.nixfiles.modules; + xresources.properties = (let font = with config.fontScheme.monospaceFont; "${family}:style=${style}:size=${toString size}"; in { @@ -34,7 +34,7 @@ in { "Xft.lcdfilter" = "lcddefault"; "Xft.rgba" = "rgb"; }) - // (with profiles.common.colourScheme; { + // (with config.colourScheme; { "*.color0" = black; "*.color8" = brightBlack; "*.color1" = red; diff --git a/modules/nixfiles/zathura.nix b/modules/nixfiles/zathura.nix index fd38ab0..03a8311 100644 --- a/modules/nixfiles/zathura.nix +++ b/modules/nixfiles/zathura.nix @@ -14,7 +14,7 @@ in { enable = true; options = - (with profiles.common.colourScheme; { + (with config.colourScheme; { default-fg = white; default-bg = black; @@ -55,7 +55,7 @@ in { highlight-transparency = "0.3"; - font = fonts.fontScheme.monospaceFont.family; + font = config.fontScheme.monospaceFont.family; n-completion-items = 10; @@ -112,7 +112,7 @@ in { scroll-wrap = true; scroll-page-aware = false; - selection-clipboard = + selection-clipboard = with config.nixfiles.modules; if (kde.enable || gnome.enable) then "clipboard" else "primary"; -- cgit v1.2.3