From 690893bff0392bd079496c50dd10651cd59a3681 Mon Sep 17 00:00:00 2001 From: Danilo Reyes Date: Fri, 18 Apr 2025 22:05:19 -0600 Subject: [PATCH] added go, zig, and ruby, as well as environment --- base.nix | 8 ------- flake.nix | 24 +++++++++----------- modules/dev/go.nix | 45 +++++++++++++++++++++++++++++++++++++ modules/dev/ruby.nix | 40 +++++++++++++++++++++++++++++++++ modules/dev/rust.nix | 11 ++++++--- modules/dev/zig.nix | 33 +++++++++++++++++++++++++++ modules/services/nvidia.nix | 1 + 7 files changed, 138 insertions(+), 24 deletions(-) create mode 100644 modules/dev/go.nix create mode 100644 modules/dev/ruby.nix create mode 100644 modules/dev/zig.nix diff --git a/base.nix b/base.nix index 49b3216..d36e1be 100644 --- a/base.nix +++ b/base.nix @@ -148,11 +148,6 @@ XDG_STATE_HOME = "\${HOME}/.local/state"; # DEV PATH - CARGO_HOME = "${XDG_DATA_HOME}/cargo"; - GEM_HOME = "${XDG_DATA_HOME}/ruby/gems"; - GEM_PATH = "${XDG_DATA_HOME}/ruby/gems"; - GEM_SPEC_CACHE = "${XDG_DATA_HOME}/ruby/specs"; - GOPATH = "${XDG_DATA_HOME}/go"; PSQL_HISTORY = "${XDG_DATA_HOME}/psql_history"; REDISCLI_HISTFILE = "${XDG_DATA_HOME}/redis/rediscli_history"; WINEPREFIX = "${XDG_DATA_HOME}/wine"; @@ -164,9 +159,6 @@ "_JAVA_OPTIONS" = "-Djava.util.prefs.userRoot=${XDG_CONFIG_HOME}/java"; ORG_DEVICE = "workstation"; - # NVIDIA - CUDA_CACHE_PATH = "${XDG_CACHE_HOME}/nv"; - # WAYLAND WLR_NO_HARDWARE_CURSORS = 1; NIXOS_OZONE_WL = 1; diff --git a/flake.nix b/flake.nix index c6764b8..bf9f41b 100644 --- a/flake.nix +++ b/flake.nix @@ -54,6 +54,11 @@ inherit system; config.allowUnfree = true; }; + langList = builtins.filter (name: name != "emacs.nix") ( + builtins.map (file: builtins.replaceStrings [ ".nix" ] [ "" ] (baseNameOf file)) ( + builtins.attrNames (builtins.readDir ./modules/dev) + ) + ); createConfig = name: local-nixpkgs: let @@ -86,18 +91,11 @@ server = createConfig "server" inputs.nixpkgs-small; shell = createConfig "shell" inputs.nixpkgs; }; - devShells.${system} = { - inherit (self.nixosConfigurations.shell.config.devShells) - cc - docker - haskell - javascript - julia - nix - python - rust - sh - ; - }; + devShells.${system} = builtins.listToAttrs ( + map (lang: { + name = lang; + value = self.nixosConfigurations.shell.config.devShells.${lang}; + }) langList + ); }; } diff --git a/modules/dev/go.nix b/modules/dev/go.nix new file mode 100644 index 0000000..6a3361d --- /dev/null +++ b/modules/dev/go.nix @@ -0,0 +1,45 @@ +{ + config, + lib, + pkgs, + ... +}: +let + packages = builtins.attrValues { + inherit (pkgs) + go # Go compiler and core toolchain + gocode-gomod # Code completion for Go (modern fork of gocode) + gotools # Contains godoc, gorename, goimports, etc. + gore # Go REPL + gotests # Generate Go tests from function signatures + gomodifytags # Struct tag manipulation + golangci-lint # Linter aggregation + ; + }; + GOPATH = "\${XDG_DATA_HOME}/go"; +in +{ + options = { + my.dev.go.enable = lib.mkEnableOption "Install Go tooling globally"; + devShells.go = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages GOPATH; + name = "go-dev-shell"; + shellHook = '' + echo "🐹 Go dev environment" + ''; + }; + description = "Go development shell with Emacs tooling, REPL, formatter, and linter"; + }; + }; + + config = lib.mkMerge [ + { + environment.variables = { inherit GOPATH; }; + } + (lib.mkIf config.my.dev.go.enable { + users.users.jawz = { inherit packages; }; + }) + ]; +} diff --git a/modules/dev/ruby.nix b/modules/dev/ruby.nix new file mode 100644 index 0000000..d974447 --- /dev/null +++ b/modules/dev/ruby.nix @@ -0,0 +1,40 @@ +{ + config, + lib, + pkgs, + ... +}: +let + packages = builtins.attrValues { + inherit (pkgs) ruby; # Ruby interpreter + inherit (pkgs.rubyPackages) solargraph; # LSP for Ruby + }; +in +{ + options = { + my.dev.ruby.enable = lib.mkEnableOption "Install Ruby tooling globally"; + devShells.ruby = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "ruby-dev-shell"; + shellHook = '' + echo "💎 Ruby dev environment" + ''; + }; + description = "Ruby development shell with interpreter and Solargraph LSP"; + }; + }; + config = lib.mkMerge [ + (lib.mkIf config.my.dev.ruby.enable { + users.users.jawz = { inherit packages; }; + }) + { + environment.variables = { + GEM_HOME = "\${XDG_DATA_HOME}/ruby/gems"; + GEM_PATH = "\${XDG_DATA_HOME}/ruby/gems"; + GEM_SPEC_CACHE = "\${XDG_DATA_HOME}/ruby/specs"; + }; + } + ]; +} diff --git a/modules/dev/rust.nix b/modules/dev/rust.nix index f96b7cd..b7e6ffb 100644 --- a/modules/dev/rust.nix +++ b/modules/dev/rust.nix @@ -29,7 +29,12 @@ in description = "Rust development shell with cargo and rust-analyzer"; }; }; - config = lib.mkIf config.my.dev.rust.enable { - users.users.jawz = { inherit packages; }; - }; + config = lib.mkMerge [ + (lib.mkIf config.my.dev.rust.enable { + users.users.jawz = { inherit packages; }; + }) + { + environment.variables.CARGO_HOME = "\${XDG_DATA_HOME}/cargo"; + } + ]; } diff --git a/modules/dev/zig.nix b/modules/dev/zig.nix new file mode 100644 index 0000000..f6ca287 --- /dev/null +++ b/modules/dev/zig.nix @@ -0,0 +1,33 @@ +{ + config, + lib, + pkgs, + ... +}: +let + packages = builtins.attrValues { + inherit (pkgs) + zig # Zig compiler and stdlib + zls # Language server for Zig + ; + }; +in +{ + options = { + my.dev.zig.enable = lib.mkEnableOption "Install Zig tooling globally"; + devShells.zig = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "zig-dev-shell"; + shellHook = '' + echo "🦎 Zig dev environment" + ''; + }; + description = "Zig development shell with compiler and LSP"; + }; + }; + config = lib.mkIf config.my.dev.zig.enable { + users.users.jawz = { inherit packages; }; + }; +} diff --git a/modules/services/nvidia.nix b/modules/services/nvidia.nix index e5d4196..859da81 100644 --- a/modules/services/nvidia.nix +++ b/modules/services/nvidia.nix @@ -7,6 +7,7 @@ { options.my.services.nvidia.enable = lib.mkEnableOption "enable"; config = lib.mkIf config.my.services.nvidia.enable { + environment.variables.CUDA_CACHE_PATH = "\${XDG_CACHE_HOME}/nv"; boot.kernelParams = lib.mkIf (config.networking.hostName == "workstation") [ "nvidia-drm.fbdev=1" ]; services.xserver.videoDrivers = [ "nvidia" ]; hardware = {