Skip to content

Commit

Permalink
nix: remove flake-utils in favor of lib.genAttrs (#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Dec 8, 2024
1 parent b6c835c commit dae33d4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 75 deletions.
48 changes: 7 additions & 41 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 39 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
}));
}
);
};
}

0 comments on commit dae33d4

Please sign in to comment.