From dae33d4e94a1dc145d34c690fdd95c8de0f3df69 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 7 Dec 2024 17:57:09 -0800 Subject: [PATCH] nix: remove flake-utils in favor of lib.genAttrs (#1244) --- flake.lock | 48 ++++++----------------------------- flake.nix | 73 +++++++++++++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 75 deletions(-) diff --git a/flake.lock b/flake.lock index f30483499..9f44c669f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "melange-compiler-libs": { "inputs": { "nixpkgs": [ @@ -58,11 +40,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1733004991, - "narHash": "sha256-MpK4wT/Qn+kINWu2yMli20yJMKfEuarKu9b248Om6SA=", + "lastModified": 1733618663, + "narHash": "sha256-InGcpprb28501vo7POwnTk/Pbi8Co5gbpxfkdzofQRk=", "owner": "nix-ocaml", "repo": "nix-overlays", - "rev": "198a22a3eab0361a0e1e349e798397f6f3f0464c", + "rev": "82ac3f123030e98f63baf95ad9841cc152a362aa", "type": "github" }, "original": { @@ -73,42 +55,26 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1732951447, - "narHash": "sha256-ndq0dD5E6FkqwmNYFS1wUAHa/5HixS3jLjulogM+7/E=", + "lastModified": 1733603762, + "narHash": "sha256-E+cuaL8s1oHCumWD/Zkw0gkLOOQcz848pVyLfvqWDVw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "57feb2a16f705eeffb075888d92a986e66473012", + "rev": "b1dd465e8139748a8e26037fdd4c5ffe79457cbd", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "57feb2a16f705eeffb075888d92a986e66473012", + "rev": "b1dd465e8139748a8e26037fdd4c5ffe79457cbd", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", "melange-compiler-libs": "melange-compiler-libs", "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 0f2aaa2bb..21f20c545 100644 --- a/flake.nix +++ b/flake.nix @@ -3,58 +3,63 @@ inputs = { nix-filter.url = "github:numtide/nix-filter"; - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs = { - url = "github:nix-ocaml/nix-overlays"; - inputs.flake-utils.follows = "flake-utils"; - }; + nixpkgs.url = "github:nix-ocaml/nix-overlays"; melange-compiler-libs = { # this changes rarely, and it's better than having to rely on nix's poor # support for submodules url = "github:melange-re/melange-compiler-libs"; - inputs.flake-utils.follows = "flake-utils"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { self, nixpkgs, flake-utils, nix-filter, melange-compiler-libs }: + outputs = { self, nixpkgs, nix-filter, melange-compiler-libs }: + 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_3; + }); + in + f pkgs); + in { overlays.default = import ./nix/overlay.nix { nix-filter = nix-filter.lib; melange-compiler-libs-vendor-dir = melange-compiler-libs; }; - } // (flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages."${system}".extend (self: super: { - ocamlPackages = super.ocaml-ng.ocamlPackages_5_3; - }); - packages = - let - melange = pkgs.callPackage ./nix { - nix-filter = nix-filter.lib; - melange-compiler-libs-vendor-dir = melange-compiler-libs; - }; - in - { + packages = forAllSystems (pkgs: + let + melange = pkgs.callPackage ./nix { + nix-filter = nix-filter.lib; + melange-compiler-libs-vendor-dir = melange-compiler-libs; + }; + in + { + inherit melange; + default = melange; + melange-playground = pkgs.ocamlPackages.callPackage ./nix/melange-playground.nix { inherit melange; - default = melange; - melange-playground = pkgs.ocamlPackages.callPackage ./nix/melange-playground.nix { - inherit melange; - nix-filter = nix-filter.lib; - melange-compiler-libs-vendor-dir = melange-compiler-libs; - }; + nix-filter = nix-filter.lib; + melange-compiler-libs-vendor-dir = melange-compiler-libs; }; - melange-shell = opts: - pkgs.callPackage ./nix/shell.nix ({ inherit packages; } // opts); - in - { - inherit packages; - devShells = { + } + ); + + devShells = forAllSystems (pkgs: + let + melange-shell = opts: + pkgs.callPackage ./nix/shell.nix ({ + packages = self.packages.${pkgs.system}; + } // opts); + + in + { default = melange-shell { }; release = melange-shell { release-mode = true; }; - }; - })); + } + ); + }; }