Skip to content

Commit

Permalink
refactor(nix): use lib.fileset instead of nix-filter (#1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Dec 8, 2024
1 parent 053bcff commit 9f7db9e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 57 deletions.
16 changes: 0 additions & 16 deletions flake.lock

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

6 changes: 1 addition & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
description = "Melange Nix Flake";

inputs = {
nix-filter.url = "github:numtide/nix-filter";
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
Expand All @@ -12,7 +11,7 @@
};
};

outputs = { self, nixpkgs, nix-filter, melange-compiler-libs }:
outputs = { self, nixpkgs, melange-compiler-libs }:
let
forAllSystems = f: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system:
let
Expand All @@ -24,14 +23,12 @@
in
{
overlays.default = import ./nix/overlay.nix {
nix-filter = nix-filter.lib;
melange-compiler-libs-vendor-dir = melange-compiler-libs;
};

packages = forAllSystems (pkgs:
let
melange = pkgs.callPackage ./nix {
nix-filter = nix-filter.lib;
melange-compiler-libs-vendor-dir = melange-compiler-libs;
};
in
Expand All @@ -40,7 +37,6 @@
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;
};
}
Expand Down
36 changes: 18 additions & 18 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
, git
, tree
, makeWrapper
, nix-filter
, nodejs
, melange-compiler-libs-vendor-dir
, doCheck ? true
Expand All @@ -18,23 +17,24 @@ buildDunePackage {
version = "dev";
duneVersion = "3";

src = with nix-filter; filter {
root = ./..;
include = [
"belt"
"bin"
"dune-project"
"dune"
"jscomp"
"lib"
"melange.opam"
"ppx"
"scripts"
"test"
"vendor"
];
exclude = [ "jscomp/test" ];
};
src =
let fs = lib.fileset; in
fs.toSource {
root = ./..;
fileset = fs.unions [
../belt
../bin
../dune-project
../dune
(fs.difference ../jscomp ../jscomp/test)
../melange.opam
../ppx
../scripts
../test
../vendor
];
};

postPatch = ''
rm -rf vendor/melange-compiler-libs
mkdir -p ./vendor
Expand Down
33 changes: 18 additions & 15 deletions nix/melange-playground.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ melange
, lib
, buildDunePackage
, nix-filter
, cppo
, menhir
, nodejs
Expand All @@ -16,20 +16,23 @@ buildDunePackage {
version = "dev";
duneVersion = "3";

src = with nix-filter; filter {
root = ./..;
include = [
"belt"
"bin"
"dune-project"
"dune"
"jscomp"
"melange-playground.opam"
"playground"
"test/blackbox-tests/melange-playground"
"vendor"
];
};
src =
let fs = lib.fileset; in
fs.toSource {
root = ./..;
fileset = fs.unions [
../belt
../bin
../dune-project
../dune
(fs.difference ../jscomp ../jscomp/test)
../melange-playground.opam
../playground
../test/blackbox-tests/melange-playground
../vendor
];
};

postPatch = ''
rm -rf vendor/melange-compiler-libs
mkdir -p ./vendor
Expand Down
6 changes: 3 additions & 3 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ nix-filter, melange-compiler-libs-vendor-dir }:
{ melange-compiler-libs-vendor-dir }:

final: prev:

Expand All @@ -9,11 +9,11 @@ final: prev:

{
melange = prev.callPackage ./. {
inherit nix-filter melange-compiler-libs-vendor-dir;
inherit melange-compiler-libs-vendor-dir;
doCheck = false;
};
melange-playground = prev.lib.callPackageWith oself ./melange-playground.nix {
inherit nix-filter melange-compiler-libs-vendor-dir;
inherit melange-compiler-libs-vendor-dir;
inherit (prev) nodejs;
};
}
Expand Down

0 comments on commit 9f7db9e

Please sign in to comment.