From 023744a8725d58e4eaefb21a3fb0e5075f8247cb Mon Sep 17 00:00:00 2001 From: Danilo Reyes Date: Fri, 18 Apr 2025 21:29:02 -0600 Subject: [PATCH] migrated all languages to devshell --- base.nix | 2 +- flake.nix | 12 ++++++- modules/dev/cc.nix | 38 +++++++++++++------- modules/dev/docker.nix | 36 +++++++++++++++---- modules/dev/haskell.nix | 54 +++++++++++++++++++--------- modules/dev/javascript.nix | 74 ++++++++++++++++++++++++-------------- modules/dev/julia.nix | 27 +++++++++++--- modules/dev/nix.nix | 34 +++++++++++++----- modules/dev/rust.nix | 34 +++++++++++++----- modules/dev/sh.nix | 36 ++++++++++++++----- modules/shell/tools.nix | 3 +- 11 files changed, 256 insertions(+), 94 deletions(-) diff --git a/base.nix b/base.nix index c68718a..21d5c2d 100644 --- a/base.nix +++ b/base.nix @@ -32,7 +32,7 @@ users.jawz = import ./home-manager.nix; }; time = { - timeZone = config.my.timezone; + timeZone = config.my.timeZone; hardwareClockInLocalTime = true; }; i18n = { diff --git a/flake.nix b/flake.nix index 0a04bee..c6764b8 100644 --- a/flake.nix +++ b/flake.nix @@ -87,7 +87,17 @@ shell = createConfig "shell" inputs.nixpkgs; }; devShells.${system} = { - python = self.nixosConfigurations.shell.config.devShells.python; + inherit (self.nixosConfigurations.shell.config.devShells) + cc + docker + haskell + javascript + julia + nix + python + rust + sh + ; }; }; } diff --git a/modules/dev/cc.nix b/modules/dev/cc.nix index 11c0e90..4eb7356 100644 --- a/modules/dev/cc.nix +++ b/modules/dev/cc.nix @@ -4,19 +4,33 @@ pkgs, ... }: - +let + packages = builtins.attrValues { + inherit (pkgs) + clang # C/C++ compiler frontend (part of LLVM) + clang-tools # Extra LLVM tools (e.g. clang-tidy, clang-apply-replacements) + gcc # GNU Compiler Collection (C, C++, etc.) + gdb # GNU Debugger + valgrind # Memory leak detector and performance profiler + ; + }; +in { - options.my.dev.cc.enable = lib.mkEnableOption "enable"; - - config = lib.mkIf config.my.dev.cc.enable { - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) - clang # C/C++ compiler frontend (part of LLVM) - clang-tools # Extra LLVM tools (e.g. clang-tidy, clang-apply-replacements) - gcc # GNU Compiler Collection (C, C++, etc.) - gdb # GNU Debugger - valgrind # Memory leak detector and performance profiler - ; + options = { + my.dev.cc.enable = lib.mkEnableOption "Install C/C++ tooling globally"; + devShells.cc = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "cc-dev-shell"; + shellHook = '' + echo "🔧 C/C++ dev environment" + ''; + }; + description = "C/C++ development shell"; }; }; + config = lib.mkIf config.my.dev.cc.enable { + users.users.jawz.packages = packages; + }; } diff --git a/modules/dev/docker.nix b/modules/dev/docker.nix index 98659b3..403879c 100644 --- a/modules/dev/docker.nix +++ b/modules/dev/docker.nix @@ -4,13 +4,37 @@ pkgs, ... }: +let + packages = builtins.attrValues { + inherit (pkgs) dockfmt; # Format Dockerfiles + inherit (pkgs.nodePackages) + dockerfile-language-server-nodejs # LSP for Dockerfiles + ; + }; +in { - options.my.dev.docker.enable = lib.mkEnableOption "enable"; - config = lib.mkIf config.my.dev.docker.enable { - environment.variables.DOCKER_CONFIG = "\${XDG_CONFIG_HOME}/docker"; - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) dockfmt; - inherit (pkgs.nodePackages) dockerfile-language-server-nodejs; + options = { + my.dev.docker.enable = lib.mkEnableOption "Install Docker tooling globally"; + devShells.docker = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "docker-dev-shell"; + shellHook = '' + echo "🐳 Docker dev environment" + ''; + }; + description = "Docker and Dockerfile tooling shell"; }; }; + config = lib.mkMerge [ + (lib.mkIf config.my.dev.docker.enable { + users.users.jawz = { + inherit packages; + }; + }) + { + environment.variables.DOCKER_CONFIG = "\${XDG_CONFIG_HOME}/docker"; + } + ]; } diff --git a/modules/dev/haskell.nix b/modules/dev/haskell.nix index 44efa5b..05a9c60 100644 --- a/modules/dev/haskell.nix +++ b/modules/dev/haskell.nix @@ -4,23 +4,45 @@ pkgs, ... }: +let + packages = builtins.attrValues { + inherit (pkgs) + haskell-language-server # LSP server for Haskell + cabal-install # Standard Haskell build tool + hlint # Linter for Haskell source code + ; + inherit (pkgs.haskellPackages) + hoogle # Haskell API search engine + ; + }; +in { - options.my.dev.haskell.enable = lib.mkEnableOption "enable"; - config = lib.mkIf config.my.dev.haskell.enable { - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) - haskell-language-server # LSP server for Haskell - cabal-install # Standard Haskell build tool - hlint # Linter for Haskell source code - ; - inherit (pkgs.haskellPackages) - hoogle # Haskell API search engine - ; - }; - environment.variables = { - CABAL_DIR = "\${XDG_CACHE_HOME}/cabal"; - STACK_ROOT = "\${XDG_DATA_HOME}/stack"; - GHCUP_USE_XDG_DIRS = "true"; + options = { + my.dev.haskell.enable = lib.mkEnableOption "Install Haskell tooling globally"; + devShells.haskell = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "haskell-dev-shell"; + shellHook = '' + echo "λ Haskell dev environment" + ''; + }; + description = "Haskell development shell"; }; }; + config = lib.mkMerge [ + (lib.mkIf config.my.dev.haskell.enable { + users.users.jawz = { + inherit packages; + }; + }) + { + environment.variables = { + CABAL_DIR = "\${XDG_CACHE_HOME}/cabal"; + STACK_ROOT = "\${XDG_DATA_HOME}/stack"; + GHCUP_USE_XDG_DIRS = "true"; + }; + } + ]; } diff --git a/modules/dev/javascript.nix b/modules/dev/javascript.nix index 11a3a68..cee0f93 100644 --- a/modules/dev/javascript.nix +++ b/modules/dev/javascript.nix @@ -4,35 +4,55 @@ pkgs, ... }: +let + packages = builtins.attrValues { + inherit (pkgs) nodejs; # Node.js runtime + inherit (pkgs.nodePackages) pnpm; # Fast package manager alternative to npm + }; +in { - options.my.dev.javascript.enable = lib.mkEnableOption "enable"; - config = lib.mkIf config.my.dev.javascript.enable { - home-manager.users.jawz.xdg.configFile = { - "npm/npmrc".text = '' - user=0 - unsafe-perm=true - prefix=$XDG_DATA_HOME/npm - cache=$XDG_CACHE_HOME/npm - tmp=$XDG_RUNTIME_DIR/npm - init-module=$XDG_CONFIG_HOME/npm/config/npm-init.js - store-dir=$XDG_DATA_HOME/pnpm-store - ''; - "configstore/update-notifier-npm-check.json".text = builtins.toJSON { - optOut = false; - lastUpdateCheck = 1646662583446; + options = { + my.dev.javascript.enable = lib.mkEnableOption "Install JavaScript tooling globally"; + devShells.javascript = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "javascript-dev-shell"; + shellHook = '' + echo "📦 JavaScript dev environment" + ''; }; - }; - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) nodejs; - inherit (pkgs.nodePackages) pnpm; - }; - environment.variables = { - NPM_CONFIG_USERCONFIG = "\${XDG_CONFIG_HOME}/npm/npmrc"; - PNPM_HOME = "\${XDG_DATA_HOME}/pnpm"; - PATH = [ - "\${XDG_DATA_HOME}/npm/bin" - "\${XDG_DATA_HOME}/pnpm" - ]; + description = "JavaScript/Node development shell with npm/pnpm support"; }; }; + config = lib.mkMerge [ + (lib.mkIf config.my.dev.javascript.enable { + users.users.jawz = { inherit packages; }; + }) + { + home-manager.users.jawz.xdg.configFile = { + "npm/npmrc".text = '' + user=0 + unsafe-perm=true + prefix=$XDG_DATA_HOME/npm + cache=$XDG_CACHE_HOME/npm + tmp=$XDG_RUNTIME_DIR/npm + init-module=$XDG_CONFIG_HOME/npm/config/npm-init.js + store-dir=$XDG_DATA_HOME/pnpm-store + ''; + "configstore/update-notifier-npm-check.json".text = builtins.toJSON { + optOut = false; + lastUpdateCheck = 1646662583446; + }; + }; + environment.variables = { + NPM_CONFIG_USERCONFIG = "\${XDG_CONFIG_HOME}/npm/npmrc"; + PNPM_HOME = "\${XDG_DATA_HOME}/pnpm"; + PATH = [ + "\${XDG_DATA_HOME}/npm/bin" + "\${XDG_DATA_HOME}/pnpm" + ]; + }; + } + ]; } diff --git a/modules/dev/julia.nix b/modules/dev/julia.nix index 8a323e7..5fd6e49 100644 --- a/modules/dev/julia.nix +++ b/modules/dev/julia.nix @@ -1,15 +1,32 @@ { + config, lib, pkgs, - config, ... }: +let + packages = builtins.attrValues { + inherit (pkgs) julia; # High-performance dynamic language for technical computing + }; +in { - options.my.dev.julia.enable = lib.mkEnableOption "enable"; - + options = { + my.dev.julia.enable = lib.mkEnableOption "Install Julia globally"; + devShells.julia = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "julia-dev-shell"; + shellHook = '' + echo "🔬 Julia dev environment" + ''; + }; + description = "Julia development shell"; + }; + }; config = lib.mkIf config.my.dev.julia.enable { - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) julia; + users.users.jawz = { + inherit packages; }; }; } diff --git a/modules/dev/nix.nix b/modules/dev/nix.nix index 313068e..5120373 100644 --- a/modules/dev/nix.nix +++ b/modules/dev/nix.nix @@ -4,16 +4,34 @@ pkgs, ... }: +let + packages = builtins.attrValues { + inherit (pkgs) + nixfmt-rfc-style # formatting + cachix # binary cache management + nixd # language server for Nix + statix # linter for Nix expressions + ; + }; +in { - options.my.dev.nix.enable = lib.mkEnableOption "enable"; + options = { + my.dev.nix.enable = lib.mkEnableOption "Install Nix tooling globally"; + devShells.nix = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "nix-dev-shell"; + shellHook = '' + echo "❄️ Nix dev environment" + ''; + }; + description = "Nix/NixOS development shell with formatter, linter, LSP, and Cachix"; + }; + }; config = lib.mkIf config.my.dev.nix.enable { - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) - nixfmt-rfc-style # formating - cachix # why spend time compiling? - nixd # language server - statix # linter - ; + users.users.jawz = { + inherit packages; }; }; } diff --git a/modules/dev/rust.nix b/modules/dev/rust.nix index 0b0c9b1..2847ec5 100644 --- a/modules/dev/rust.nix +++ b/modules/dev/rust.nix @@ -4,16 +4,34 @@ pkgs, ... }: +let + packages = builtins.attrValues { + inherit (pkgs) + cargo # Rust package manager + rust-analyzer # Language server for Rust + clippy # Linter for Rust + rustfmt # Formatter for Rust code + ; + }; +in { - options.my.dev.rust.enable = lib.mkEnableOption "enable"; + options = { + my.dev.rust.enable = lib.mkEnableOption "Install Rust tooling globally"; + devShells.rust = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "rust-dev-shell"; + shellHook = '' + echo "🦀 Rust dev environment" + ''; + }; + description = "Rust development shell with cargo and rust-analyzer"; + }; + }; config = lib.mkIf config.my.dev.rust.enable { - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) - cargo # Rust package manager - rust-analyzer # Language server for Rust - clippy # Linter for Rust - rustfmt # Formatter for Rust code - ; + users.users.jawz = { + inherit packages; }; }; } diff --git a/modules/dev/sh.nix b/modules/dev/sh.nix index bf35849..efda2af 100644 --- a/modules/dev/sh.nix +++ b/modules/dev/sh.nix @@ -4,17 +4,35 @@ pkgs, ... }: +let + packages = builtins.attrValues { + inherit (pkgs) + bashdb # Debugger and completion support + shellcheck # Shell script linter + shfmt # Shell parser and formatter + ; + # LSP for Bash and sh + inherit (pkgs.nodePackages) bash-language-server; + }; +in { - options.my.dev.sh.enable = lib.mkEnableOption "enable"; + options = { + my.dev.sh.enable = lib.mkEnableOption "Install shell scripting tools globally"; + devShells.sh = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "sh-dev-shell"; + shellHook = '' + echo "💻 Shell scripting dev environment" + ''; + }; + description = "Shell scripting dev shell"; + }; + }; config = lib.mkIf config.my.dev.sh.enable { - users.users.jawz.packages = builtins.attrValues { - inherit (pkgs) - bashdb # autocomplete - shellcheck # linting - shfmt # a shell parser and formatter - ; - #LSP - inherit (pkgs.nodePackages) bash-language-server; + users.users.jawz = { + inherit packages; }; }; } diff --git a/modules/shell/tools.nix b/modules/shell/tools.nix index e9b8560..46bdefe 100644 --- a/modules/shell/tools.nix +++ b/modules/shell/tools.nix @@ -74,7 +74,8 @@ gdu # disk-space utility checker, somewhat useful tldr # man for retards trash-cli # oop! did not meant to delete that - jq # linting + jq # json parser + yq # yaml parser smartmontools # check hard drie health ; inherit (inputs.jawz-scripts.packages.x86_64-linux)