From bc779a2764c0a8b7a577c9e69eb0e444116b380c Mon Sep 17 00:00:00 2001 From: Bryan Bennett Date: Tue, 18 Jun 2024 06:52:05 -0400 Subject: [PATCH] Update flake and conventions for 24.05+ --- .ocamlformat | 2 +- default.nix | 13 +++---- dune-workspace | 3 +- flake.lock | 94 ++++++++++++-------------------------------------- flake.nix | 20 ++++++++--- 5 files changed, 48 insertions(+), 84 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index 40137a6..fa46d0a 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,2 +1,2 @@ -version=0.26.1 +version=0.26.2 profile=default \ No newline at end of file diff --git a/default.nix b/default.nix index 7b4b0a7..10fc287 100644 --- a/default.nix +++ b/default.nix @@ -4,11 +4,8 @@ , buildDunePackage , core , core_unix -, coreutils -, findlib , lib , nix-filter -, ocaml , ppx_yojson_conv , ppx_yojson_conv_lib , re @@ -36,14 +33,18 @@ buildDunePackage { }; duneVersion = "3"; doCheck = true; + # We strip by hand before packing + dontStrip = true; + # patchELF can't handle UPX'd binaries + # We produce a static OCaml binary that + dontPatchELF = true; postPatch = '' - substituteInPlace direnvrc --replace "@flake_env@" "$out/bin/flake_env" - substituteInPlace tests/spit*.sh --replace "/usr/bin/env" "${coreutils}/bin/env" + substituteInPlace direnvrc --replace-fail "@flake_env@" "$out/bin/flake_env" ''; postInstall = '' ${bintools}/bin/strip --strip-unneeded $out/bin/flake_env ${upx}/bin/upx $out/bin/flake_env - install -m400 -D direnvrc $out/share/flake_env/direnvrc + install -m444 -D direnvrc $out/share/flake_env/direnvrc ''; buildInputs = [ core diff --git a/dune-workspace b/dune-workspace index 42130a0..335ece4 100644 --- a/dune-workspace +++ b/dune-workspace @@ -1,2 +1 @@ -(lang dune 3.11) -(instrument_with bisect_ppx) \ No newline at end of file +(lang dune 3.11) \ No newline at end of file diff --git a/flake.lock b/flake.lock index 0cfb382..475bc58 100644 --- a/flake.lock +++ b/flake.lock @@ -23,11 +23,11 @@ ] }, "locked": { - "lastModified": 1709336216, - "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", "type": "github" }, "original": { @@ -36,28 +36,33 @@ "type": "github" } }, - "flake-utils": { + "git-hooks": { "inputs": { - "systems": "systems" + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "lastModified": 1717664902, + "narHash": "sha256-7XfBuLULizXjXfBYy/VV+SpYMHreNRHk9nKMsm1bgb4=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "cc4d466cb1254af050ff7bdf47f6d404a7c646d1", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "cachix", + "repo": "git-hooks.nix", "type": "github" } }, "gitignore": { "inputs": { "nixpkgs": [ - "pre-commit-hooks", + "git-hooks", "nixpkgs" ] }, @@ -92,11 +97,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1711106783, - "narHash": "sha256-PDwAcHahc6hEimyrgGmFdft75gmLrJOZ0txX7lFqq+I=", + "lastModified": 1718396522, + "narHash": "sha256-C0re6ZtCqC1ndL7ib7vOqmgwvZDhOhJ1W0wQgX1tTIo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a3ed7406349a9335cb4c2a71369b697cecd9d351", + "rev": "3e6b9369165397184774a4b7c5e8e5e46531b53f", "type": "github" }, "original": { @@ -122,65 +127,12 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1710765496, - "narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e367f7a1fb93137af22a3908f00b9a35e2d286a7", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "gitignore": "gitignore", - "nixpkgs": "nixpkgs_2", - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1710923068, - "narHash": "sha256-6hOpUiuxuwpXXc/xfJsBUJeqqgGI+JMJuLo45aG3cKc=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "e611897ddfdde3ed3eaac4758635d7177ff78673", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { "flake-parts": "flake-parts", + "git-hooks": "git-hooks", "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index b61bbff..6ee4707 100644 --- a/flake.nix +++ b/flake.nix @@ -6,14 +6,17 @@ url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; }; + git-hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nix-filter = { url = "github:numtide/nix-filter"; }; }; outputs = inputs @ { flake-parts , nix-filter - , pre-commit-hooks + , git-hooks , ... }: flake-parts.lib.mkFlake { inherit inputs; } ({ lib, ... }: { @@ -24,7 +27,7 @@ "x86_64-darwin" "aarch64-darwin" ]; - imports = [ pre-commit-hooks.flakeModule ]; + imports = [ git-hooks.flakeModule ]; perSystem = { config , pkgs @@ -60,7 +63,16 @@ check.enable = true; settings.hooks = { nixpkgs-fmt.enable = true; - dune-fmt.enable = true; + + dune-fmt = { + enable = true; + settings = { + extraRuntimeInputs = [ + pkgs.ocamlPackages.reason + ]; + }; + }; + }; }; };