From 52e24eb904446f05622e72c04146df8b4abb109a Mon Sep 17 00:00:00 2001 From: Spencer Brower Date: Mon, 26 Aug 2024 12:27:21 -0400 Subject: [PATCH] feat: Updated flakes. --- templates/default/flake.nix | 51 +++++++++++++++++++++++++++++++++++-- templates/php/flake.nix | 12 +++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/templates/default/flake.nix b/templates/default/flake.nix index 35c9b06..e5ca73f 100644 --- a/templates/default/flake.nix +++ b/templates/default/flake.nix @@ -8,15 +8,21 @@ flake-parts.url = "github:hercules-ci/flake-parts"; # process-compose-flake.url = "github:Platonic-Systems/process-compose-flake"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + # sbrow.url = "github:sbrow/nix"; }; - outputs = inputs@{ self, flake-parts, nixpkgs, nixpkgs-unstable/*, process-compose-flake, sbrow */ }: + outputs = inputs@{ self, flake-parts, nixpkgs, nixpkgs-unstable/*, process-compose-flake, sbrow */, treefmt-nix }: flake-parts.lib.mkFlake { inherit inputs; } { + # debug = true; + systems = [ "x86_64-linux" ]; imports = [ # inputs.process-compose-flake.flakeModule + inputs.treefmt-nix.flakeModule ]; perSystem = { inputs', pkgs, system, ... }: { @@ -29,11 +35,52 @@ ]; }; - formatter = pkgs.nixpkgs-fmt; + #formatter = pkgs.nixpkgs-fmt; + treefmt = { + # Used to find the project root + projectRootFile = "flake.nix"; + + # Format nix files + programs.nixpkgs-fmt.enable = true; + + # Format php files + settings.formatter."pint" = + { + command = "./vendor/bin/pint"; + includes = [ "*[!.blade].php" ]; + excludes = [ "_ide_helper*.php" ]; + }; + + # Format blade files + settings.formatter."blade-formatter" = { + command = "./bin/blade-formatter"; + options = [ "--write" ]; + includes = [ "*.blade.php" ]; + }; + + # Format js, json, and yaml files + programs.prettier.enable = true; + settings.formatter.prettier = + { + excludes = [ + "public/**" + "resources/js/modernizr.js" + "storage/app/caniuse.json" + "*.md" + ]; + }; + + # Format elm components + programs.elm-format.enable = true; + + # Override the default package + #programs.terraform.package = nixpkgs.terraform_1; + }; devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ + # config.treefmt.build.wrapper # Your packages here ]; }; diff --git a/templates/php/flake.nix b/templates/php/flake.nix index bfa3017..5cd2455 100644 --- a/templates/php/flake.nix +++ b/templates/php/flake.nix @@ -3,6 +3,7 @@ inputs = { # nixpkgs.url = "github:NixOS/nixpkgs/23.11"; + # nixpkgs-unstable.url = "github:NixOS/nixpkgs/unstable"; # dolt.url = "github:sbrow/dolt"; # phps.url = "github:fossar/nix-phps"; # phps.inputs.nixpkgs.follows = "nixpkgs"; @@ -38,6 +39,15 @@ }; in { + _module.args.pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + + overlays = [ + # (final: prev: { unstable = inputs'.nixpkgs-unstable.legacyPackages; }) + ]; + }; + formatter = pkgs.nixpkgs-fmt; process-compose.default.settings.processes = { @@ -60,6 +70,8 @@ php.packages.composer php.packages.phpcbf php.packages.phpcs + + nodePackages.intelephense ]; }; };