From 037aabb60f2e77fbbcc5859c5552e4cf7d3e2b5e Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 23 Jun 2025 00:14:26 +0100 Subject: [PATCH] Refactor --- flake.nix | 28 +++++++++------------------- modules/nodejs.nix | 34 ++++++++++++++++++---------------- modules/php82.nix | 30 ++++++++++++++---------------- modules/php83.nix | 29 ++++++++++++++--------------- modules/tailwindcss.nix | 28 +++++++++++++++------------- 5 files changed, 70 insertions(+), 79 deletions(-) diff --git a/flake.nix b/flake.nix index 147de7e..f0e9fd2 100644 --- a/flake.nix +++ b/flake.nix @@ -11,28 +11,18 @@ flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" ]; + imports = [ + ./modules/nodejs.nix + ./modules/php82.nix + ./modules/php83.nix + ./modules/tailwindcss.nix + ]; + perSystem = { config, pkgs, ... }: - let - inherit (pkgs) callPackage; - - commonPhpPackages = with pkgs; [ - phpactor - ]; - in { - devShells = { - default = pkgs.mkShell { - packages = with pkgs; [ nixd ]; - }; - - nodejs = callPackage ./modules/nodejs.nix { }; - - php82 = callPackage ./modules/php82.nix { inherit commonPhpPackages; }; - - php83 = callPackage ./modules/php83.nix { inherit commonPhpPackages; }; - - tailwindcss = callPackage ./modules/tailwindcss.nix { }; + devShells.default = pkgs.mkShell { + packages = with pkgs; [ nixd ]; }; formatter = pkgs.nixfmt-rfc-style; diff --git a/modules/nodejs.nix b/modules/nodejs.nix index 6c52e2b..f1f344e 100644 --- a/modules/nodejs.nix +++ b/modules/nodejs.nix @@ -1,18 +1,20 @@ -{ lib, pkgs }: +{ + perSystem = + { pkgs, ... }: + { + devShells.nodejs = pkgs.mkShell { + packages = with pkgs; [ + bun + eslint_d + nodejs + nodePackages.pnpm + nodePackages.yarn + prettier + ]; -with pkgs; - -mkShell { - packages = [ - bun - eslint_d - nodejs - nodePackages.pnpm - nodePackages.yarn - prettier - ]; - - shellHook = '' - echo "nodejs $(${lib.getExe nodejs} --version)" - ''; + shellHook = '' + echo "nodejs $(node --version)" + ''; + }; + }; } diff --git a/modules/php82.nix b/modules/php82.nix index 514a378..b70488a 100644 --- a/modules/php82.nix +++ b/modules/php82.nix @@ -1,19 +1,17 @@ { - commonPhpPackages, - lib, - pkgs, - ... -}: + perSystem = + { pkgs, ... }: + { + devShells.php82 = pkgs.mkShell { + packages = with pkgs; [ + php82 + php82Packages.composer + phpactor + ]; -with pkgs; - -mkShell { - packages = [ - php82 - php82Packages.composer - ] ++ commonPhpPackages; - - shellHook = '' - ${lib.getExe php82} --version - ''; + shellHook = '' + php --version + ''; + }; + }; } diff --git a/modules/php83.nix b/modules/php83.nix index 5af6f44..5bcf12a 100644 --- a/modules/php83.nix +++ b/modules/php83.nix @@ -1,18 +1,17 @@ { - commonPhpPackages, - lib, - pkgs, -}: + perSystem = + { pkgs, ... }: + { + devShells.php83 = pkgs.mkShell { + packages = with pkgs; [ + php83 + php83Packages.composer + phpactor + ]; -with pkgs; - -mkShell { - packages = [ - php83 - php83Packages.composer - ] ++ commonPhpPackages; - - shellHook = '' - ${lib.getExe php83} --version - ''; + shellHook = '' + php --version + ''; + }; + }; } diff --git a/modules/tailwindcss.nix b/modules/tailwindcss.nix index 1eebf52..e5c0a50 100644 --- a/modules/tailwindcss.nix +++ b/modules/tailwindcss.nix @@ -1,15 +1,17 @@ -{ lib, pkgs }: +{ + perSystem = + { pkgs, ... }: + { + devShells.tailwindcss = pkgs.mkShell { + packages = with pkgs; [ + tailwindcss-language-server + tailwindcss_4 + watchman + ]; -with pkgs; - -mkShell { - packages = [ - tailwindcss-language-server - tailwindcss_4 - watchman - ]; - - shellHook = '' - ${lib.getExe tailwindcss_4} --help - ''; + shellHook = '' + tailwindcss --help + ''; + }; + }; }