-
Notifications
You must be signed in to change notification settings - Fork 139
flake: remove flake-utils dependency #1226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,84 @@ | ||
{ | ||
inputs = { | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
}; | ||
|
||
outputs = { self, flake-utils, nixpkgs, ... }@inputs: | ||
outputs = { self, nixpkgs, ... }@inputs: | ||
let | ||
package = "ocaml-lsp-server"; | ||
overlay = final: prev: { | ||
${package} = prev.${package}.overrideAttrs (_: { | ||
# Do not add share/nix-support, so that dependencies from | ||
# the scope don't leak into dependent derivations | ||
doNixSupport = false; | ||
}); | ||
dune-release = prev.dune-release.overrideAttrs (_: { | ||
doCheck = false; | ||
}); | ||
ocamlPackages = prev.ocamlPackages.overrideScope' (oself: osuper: | ||
let | ||
fixPreBuild = o: { | ||
propagatedBuildInputs = o.propagatedBuildInputs ++ [ oself.pp ]; | ||
preBuild = '' | ||
rm -r vendor/csexp vendor/pp | ||
''; | ||
}; | ||
in | ||
{ | ||
dyn = osuper.dyn.overrideAttrs fixPreBuild; | ||
dune-private-libs = osuper.dune-private-libs.overrideAttrs fixPreBuild; | ||
dune-glob = osuper.dune-glob.overrideAttrs fixPreBuild; | ||
dune-action-plugin = osuper.dune-action-plugin.overrideAttrs fixPreBuild; | ||
dune-rpc = osuper.dune-rpc.overrideAttrs fixPreBuild; | ||
stdune = osuper.stdune.overrideAttrs fixPreBuild; | ||
}); | ||
}; | ||
lspPackage = pkgs: | ||
with pkgs.ocamlPackages; | ||
buildDunePackage { | ||
pname = package; | ||
version = "n/a"; | ||
src = ./.; | ||
duneVersion = "3"; | ||
buildInputs = [ | ||
ocamlc-loc | ||
astring | ||
camlp-streams | ||
dune-build-info | ||
re | ||
dune-rpc | ||
chrome-trace | ||
dyn | ||
fiber | ||
xdg | ||
ordering | ||
spawn | ||
pp | ||
csexp | ||
ocamlformat-rpc-lib | ||
stdune | ||
yojson | ||
ppx_yojson_conv_lib | ||
uutf | ||
merlin-lib | ||
]; | ||
propagatedBuildInputs = [ ]; | ||
doCheck = false; | ||
buildPhase = '' | ||
runHook preBuild | ||
dune build ${package}.install --release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} | ||
runHook postBuild | ||
''; | ||
meta = { | ||
mainProgram = "ocamllsp"; | ||
}; | ||
}; | ||
in | ||
{ | ||
overlays.default = (final: prev: { | ||
ocamlPackages = prev.ocamlPackages.overrideScope (oself: osuper: | ||
with oself; | ||
|
||
{ | ||
ocaml-lsp = lspPackage final; | ||
} | ||
); | ||
supportedSystems = [ | ||
"aarch64-darwin" | ||
"aarch64-linux" | ||
"x86_64-darwin" | ||
"x86_64-linux" | ||
]; | ||
|
||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
|
||
nixpkgsFor = forAllSystems (system: import nixpkgs { | ||
inherit system; | ||
overlays = builtins.attrValues self.overlays; | ||
}); | ||
} // (flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { overlays = [ overlay ]; inherit system; }; | ||
inherit (pkgs.ocamlPackages) buildDunePackage; | ||
fast = rec { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these are stubs to speed up the build? I moved them all to |
||
in | ||
{ | ||
overlays = { | ||
default = final: prev: { | ||
${package} = prev.${package}.overrideAttrs (_: { | ||
# Do not add share/nix-support, so that dependencies from | ||
# the scope don't leak into dependent derivations | ||
doNixSupport = false; | ||
}); | ||
|
||
jsonrpc = buildDunePackage { | ||
pname = "jsonrpc"; | ||
version = "n/a"; | ||
src = ./.; | ||
duneVersion = "3"; | ||
propagatedBuildInputs = with pkgs.ocamlPackages; [ ]; | ||
dune-release = prev.dune-release.overrideAttrs (_: { | ||
doCheck = false; | ||
}; | ||
}); | ||
|
||
lsp = buildDunePackage { | ||
pname = "lsp"; | ||
version = "n/a"; | ||
src = ./.; | ||
duneVersion = "3"; | ||
propagatedBuildInputs = with pkgs.ocamlPackages; [ | ||
jsonrpc | ||
yojson | ||
stdune | ||
ppx_yojson_conv_lib | ||
uutf | ||
]; | ||
checkInputs = with pkgs.ocamlPackages; [ cinaps ppx_expect ]; | ||
doCheck = false; | ||
}; | ||
ocamlPackages = prev.ocamlPackages.overrideScope' (oself: osuper: | ||
let | ||
fixPreBuild = o: { | ||
propagatedBuildInputs = o.propagatedBuildInputs ++ [ oself.pp ]; | ||
preBuild = '' | ||
rm -r vendor/csexp vendor/pp | ||
''; | ||
}; | ||
in | ||
{ | ||
dyn = osuper.dyn.overrideAttrs fixPreBuild; | ||
dune-private-libs = osuper.dune-private-libs.overrideAttrs fixPreBuild; | ||
dune-glob = osuper.dune-glob.overrideAttrs fixPreBuild; | ||
dune-action-plugin = osuper.dune-action-plugin.overrideAttrs fixPreBuild; | ||
dune-rpc = osuper.dune-rpc.overrideAttrs fixPreBuild; | ||
stdune = osuper.stdune.overrideAttrs fixPreBuild; | ||
ocaml-lsp = self.packages.${prev.system}.ocaml-lsp; | ||
}); | ||
}; | ||
|
||
ocaml-lsp-only = final: prev: { | ||
ocamlPackages = prev.ocamlPackages.overrideScope' (_: _: { | ||
ocaml-lsp = self.packages.${prev.system}.ocaml-lsp; | ||
}); | ||
}; | ||
}; | ||
|
||
packages = forAllSystems (system: | ||
let | ||
pkgs = nixpkgsFor.${system}; | ||
inherit (pkgs.ocamlPackages) buildDunePackage; | ||
in | ||
{ | ||
# we have a package without opam2nix for easy consumption for nix users | ||
default = self.packages.${system}.ocaml-lsp; | ||
|
||
ocaml-lsp = buildDunePackage { | ||
pname = "ocaml-lsp"; | ||
pname = package; | ||
version = "n/a"; | ||
src = ./.; | ||
duneVersion = "3"; | ||
checkInputs = with pkgs.ocamlPackages; [ ppx_expect ]; | ||
propagatedBuildInputs = with pkgs.ocamlPackages; [ | ||
buildInputs = with pkgs.ocamlPackages; [ | ||
ocamlc-loc | ||
octavius | ||
astring | ||
camlp-streams | ||
dune-build-info | ||
re | ||
dune-rpc | ||
|
@@ -141,43 +95,70 @@ | |
yojson | ||
ppx_yojson_conv_lib | ||
uutf | ||
lsp | ||
astring | ||
camlp-streams | ||
merlin-lib | ||
] ++ [ | ||
self.packages.${system}.lsp | ||
]; | ||
propagatedBuildInputs = [ ]; | ||
doCheck = false; | ||
buildPhase = '' | ||
runHook preBuild | ||
dune build ${package}.install --release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} | ||
runHook postBuild | ||
''; | ||
meta = { | ||
mainProgram = "ocamllsp"; | ||
}; | ||
}; | ||
|
||
# stub builds | ||
jsonrpc = buildDunePackage { | ||
pname = "jsonrpc"; | ||
version = "n/a"; | ||
src = ./.; | ||
duneVersion = "3"; | ||
propagatedBuildInputs = with pkgs.ocamlPackages; [ ]; | ||
doCheck = false; | ||
}; | ||
}; | ||
in | ||
{ | ||
packages = | ||
rec { | ||
# we have a package without opam2nix for easy consumption for nix users | ||
default = lspPackage pkgs; | ||
|
||
ocaml-lsp = fast.ocaml-lsp; | ||
lsp = buildDunePackage { | ||
pname = "lsp"; | ||
version = "n/a"; | ||
src = ./.; | ||
duneVersion = "3"; | ||
propagatedBuildInputs = with pkgs.ocamlPackages; [ | ||
yojson | ||
stdune | ||
ppx_yojson_conv_lib | ||
uutf | ||
] ++ [ | ||
self.packages.${system}.jsonrpc | ||
]; | ||
checkInputs = with pkgs.ocamlPackages; [ cinaps ppx_expect ]; | ||
doCheck = false; | ||
}; | ||
}); | ||
|
||
devShells = { | ||
devShells = forAllSystems (system: | ||
let pkgs = nixpkgsFor.${system}; in { | ||
default = pkgs.mkShell { | ||
buildInputs = (with pkgs; | ||
[ | ||
# dev tools | ||
ocamlformat_0_26_1 | ||
yarn | ||
name = package; | ||
inputsFrom = builtins.attrValues self.packages.${system}; | ||
buildInputs = with pkgs; [ | ||
# dev tools | ||
ocamlformat_0_26_1 | ||
yarn | ||
|
||
ocamlPackages.ppx_expect | ||
ocamlPackages.utop | ||
ocamlPackages.cinaps | ||
ocamlPackages.ppx_yojson_conv | ||
]); | ||
inputsFrom = [ fast.ocaml-lsp fast.jsonrpc fast.lsp ]; | ||
ocamlPackages.ppx_expect | ||
ocamlPackages.utop | ||
ocamlPackages.cinaps | ||
ocamlPackages.ppx_yojson_conv | ||
]; | ||
}; | ||
|
||
release = pkgs.mkShell { | ||
buildInputs = [ pkgs.dune-release ]; | ||
}; | ||
}; | ||
})); | ||
}); | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not Nix’s defaults (theirs includes 32-bit Linux last I checked), but matches the default systems of
flake-utils
so the change should have no effect on anyone.