diff --git a/flake.lock b/flake.lock index b419c1e..466aec2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,51 +1,15 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nix-filter": { - "locked": { - "lastModified": 1710156097, - "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", - "owner": "numtide", - "repo": "nix-filter", - "rev": "3342559a24e85fc164b295c3444e8a139924675b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "nix-filter", - "type": "github" - } - }, "nixpkgs": { "inputs": { - "flake-utils": [ - "flake-utils" - ], "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1727433901, - "narHash": "sha256-ZF8jDOu3Q+n78h/57gAtMf++X/Kv4b1rioY8uD/3GSw=", + "lastModified": 1739164772, + "narHash": "sha256-DlcAsid/PovJMRc2kHQK3jr/pwXDl5AHf9KW4juYJwA=", "owner": "nix-ocaml", "repo": "nix-overlays", - "rev": "b35be5d803b249d8ed804d13582e39524f05df5b", + "rev": "e8ab9d047597fd471920f9f5f421e01ce8c0b0f0", "type": "github" }, "original": { @@ -56,41 +20,24 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1727420604, - "narHash": "sha256-9El1mpPlV1orzCoD59pNAB0u/mLHesZ6Ngl44HzAQDI=", + "lastModified": 1739097848, + "narHash": "sha256-bbdQB0Y4mB2msqbyQ9QC+YPDZGt1evUK53AwQSyShHM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1e15add1c28614820fcd4b75e8a5001f1e0b290f", + "rev": "9a0b855695c31ea653181b742c65e026bada3881", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "1e15add1c28614820fcd4b75e8a5001f1e0b290f", + "rev": "9a0b855695c31ea653181b742c65e026bada3881", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nix-filter": "nix-filter", "nixpkgs": "nixpkgs" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 40b8a79..0ca82f7 100644 --- a/flake.nix +++ b/flake.nix @@ -1,73 +1,95 @@ { description = "melange-jest Nix Flake"; - inputs.nix-filter.url = "github:numtide/nix-filter"; - inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.nixpkgs = { - url = "github:nix-ocaml/nix-overlays"; - inputs.flake-utils.follows = "flake-utils"; - }; + inputs.nixpkgs.url = "github:nix-ocaml/nix-overlays"; - outputs = { self, nixpkgs, flake-utils, nix-filter }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages."${system}".extend (self: super: { - ocamlPackages = super.ocaml-ng.ocamlPackages_5_2; - }); - inherit (pkgs) nodejs_latest lib stdenv darwin yarn cacert; + outputs = { self, nixpkgs }: + let + forAllSystems = f: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system: + let + pkgs = nixpkgs.legacyPackages.${system}.extend (self: super: { + ocamlPackages = super.ocaml-ng.ocamlPackages_5_2; + }); + in + f pkgs); + in + { + packages = forAllSystems (pkgs: + let + inherit (pkgs) nodejs_latest lib stdenv darwin yarn cacert; - checkPhaseNodePackages = pkgs.buildNpmPackage { - name = "melange-jest-deps"; - version = "0.0.0-dev"; + checkPhaseNodePackages = pkgs.buildNpmPackage { + name = "melange-jest-deps"; + version = "0.0.0-dev"; + src = + let fs = pkgs.lib.fileset; in + fs.toSource { + root = ./.; + fileset = fs.unions [ + ./dune-project + ./dune + ./melange-jest.opam + ./melange-jest.opam.template + ./jest + ./jest-dom + ./jest.config.js + ./package.json + ./package-lock.json + ]; + }; - src = ./.; - dontNpmBuild = true; - npmDepsHash = "sha256-T0oSCDJtwK0vNwoQQBgRtgcrz/1/gfIEUaz2uHgVKKY="; - installPhase = '' - runHook preInstall - mkdir -p "$out" - cp -r ./node_modules "$out/node_modules" - runHook postInstall - ''; - }; - melange-jest = with pkgs.ocamlPackages; buildDunePackage { - pname = "melange-jest"; - version = "dev"; + dontNpmBuild = true; + npmDepsHash = "sha256-T0oSCDJtwK0vNwoQQBgRtgcrz/1/gfIEUaz2uHgVKKY="; + installPhase = '' + runHook preInstall + mkdir -p "$out" + cp -r ./node_modules "$out/node_modules" + runHook postInstall + ''; + }; - src = ./.; - nativeBuildInputs = with pkgs.ocamlPackages; [ melange ]; - propagatedBuildInputs = with pkgs.ocamlPackages; [ melange ]; - doCheck = true; - nativeCheckInputs = [ reason nodejs_latest yarn cacert ]; - checkInputs = [ melange-webapi cacert checkPhaseNodePackages ]; - checkPhase = '' - dune build @all -p melange-jest --display=short - ln -sfn "${checkPhaseNodePackages}/node_modules" ./node_modules - ./node_modules/.bin/jest - ''; - }; + melange-jest = with pkgs.ocamlPackages; buildDunePackage { + pname = "melange-jest"; + version = "dev"; - mkShell = { buildInputs ? [ ] }: pkgs.mkShell { - inputsFrom = [ melange-jest ]; - nativeBuildInputs = with pkgs; [ - yarn - nodejs_latest - ] ++ (with pkgs.ocamlPackages; [ - ocamlformat - merlin - reason - ]); - inherit buildInputs; - }; - in - rec { - packages.default = melange-jest; - devShells = { + src = ./.; + nativeBuildInputs = with pkgs.ocamlPackages; [ melange ]; + propagatedBuildInputs = with pkgs.ocamlPackages; [ melange ]; + doCheck = true; + nativeCheckInputs = [ reason nodejs_latest yarn cacert ]; + checkInputs = [ melange-webapi cacert checkPhaseNodePackages ]; + checkPhase = '' + dune build @all -p melange-jest --display=short + ln -sfn "${checkPhaseNodePackages}/node_modules" ./node_modules + ./node_modules/.bin/jest + ''; + }; + in + { + inherit melange-jest; + default = melange-jest; + }); + devShells = forAllSystems (pkgs: + let + mkShell = { buildInputs ? [ ] }: pkgs.mkShell { + inputsFrom = [ self.packages.${pkgs.system}.melange-jest ]; + nativeBuildInputs = with pkgs; [ + yarn + nodejs_latest + ] ++ (with pkgs.ocamlPackages; [ + ocamlformat + merlin + reason + ]); + inherit buildInputs; + }; + in + { default = mkShell { }; release = mkShell { buildInputs = with pkgs; [ cacert curl ocamlPackages.dune-release git ]; }; - }; - }); + }); + }; }