diff --git a/.gitignore b/.gitignore index e306ffa4..b288b54e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,8 @@ node_modules/ dist/ +# Nix +result + # OS Thumbs.db diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..77972fb4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1775710090, + "narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4c1018dae018162ec878d42fec712642d214fdfa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..49665995 --- /dev/null +++ b/flake.nix @@ -0,0 +1,77 @@ +{ + description = "mex - CLI engine for scaffold drift detection, pre-analysis, and targeted sync"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + in + { + packages = forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.buildNpmPackage { + pname = "mex"; + version = "0.3.2"; + + src = ./.; + + # Update this hash when package-lock.json changes: + # nix build 2>&1 | grep 'got:' | awk '{print $2}' + npmDepsHash = "sha256-5gqoL5TeF7giN/qM7VfqY33rutlkmnIbq6FYPBTF3QE="; + + npmBuildScript = "build"; + + # Ensure templates directory is included + postInstall = '' + mkdir -p $out/lib/node_modules/promexeus/templates + cp -r templates/* $out/lib/node_modules/promexeus/templates/ + ''; + + meta = with pkgs.lib; { + description = "CLI engine for mex scaffold — drift detection, pre-analysis, and targeted sync"; + homepage = "https://github.com/theDakshJaitly/mex"; + license = licenses.mit; + mainProgram = "mex"; + platforms = supportedSystems; + }; + }; + }); + + overlays.default = final: prev: { + mex = self.packages.${final.system}.default; + }; + + nixosModules.default = { config, lib, pkgs, ... }: + let + cfg = config.programs.mex; + in + { + options.programs.mex = { + enable = lib.mkEnableOption "mex - scaffold drift detection CLI"; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ self.packages.${pkgs.system}.default ]; + }; + }; + + devShells = forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + nodejs_22 + ]; + }; + }); + }; +}