From 606d717276e84caa9807a2efec6c2837018e4a92 Mon Sep 17 00:00:00 2001 From: Bryan Bennett Date: Sat, 23 Mar 2024 07:15:16 -0400 Subject: [PATCH 1/5] Fix error message if failing to hash file --- bin/flake_env.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/flake_env.re b/bin/flake_env.re index d2b6dfd..1c147a3 100644 --- a/bin/flake_env.re +++ b/bin/flake_env.re @@ -16,7 +16,7 @@ let main = () => { switch (Util.hash_files(paths)) { | Ok(hsh) => hsh | Error(msg) => - Printf.eprintf("%s\n", e); + Printf.eprintf("%s\n", msg); exit(1); }; From 358ae864fca12cd2b4dfcdc97c6d16214d51aad4 Mon Sep 17 00:00:00 2001 From: Bryan Bennett Date: Sat, 23 Mar 2024 08:16:51 -0400 Subject: [PATCH 2/5] Fix depends specification --- default.nix | 10 ++++++++-- flake.nix | 28 +++++++++++++++------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/default.nix b/default.nix index 21e15eb..737856e 100644 --- a/default.nix +++ b/default.nix @@ -30,7 +30,6 @@ buildDunePackage { ./flake.lock ./flake_env.opam ./direnvrc - ./LICENSE ]; }; duneVersion = "3"; @@ -42,9 +41,16 @@ buildDunePackage { postInstall = '' install -m400 -D direnvrc $out/share/flake_env/direnvrc ''; + buildInputs = [ + core + core_unix + ppx_yojson_conv + ppx_yojson_conv_lib + re + sha + ]; checkInputs = [ alcotest bisect_ppx ]; nativeBuildInputs = [ reason ]; - propagatedBuildInputs = [ core core_unix findlib ocaml ppx_yojson_conv ppx_yojson_conv_lib re sha ]; meta = with lib; { description = "Yet another flake plugin for direnv"; diff --git a/flake.nix b/flake.nix index 4caf913..b61bbff 100644 --- a/flake.nix +++ b/flake.nix @@ -39,19 +39,21 @@ }; devShells.default = pkgs.mkShell { inputsFrom = [ self'.packages.default ]; - packages = [ - pkgs.just - pkgs.rnix-lsp - pkgs.pre-commit - pkgs.ocamlPackages.alcotest - pkgs.ocamlPackages.bisect_ppx - pkgs.ocamlPackages.dune_3 - pkgs.ocamlPackages.findlib - pkgs.ocamlPackages.ocaml - pkgs.ocamlPackages.ocaml-lsp - pkgs.ocamlPackages.ocamlformat - pkgs.ocamlPackages.ocamlformat-rpc-lib - ]; + packages = builtins.attrValues { + inherit (pkgs) + just + nil + pre-commit + ; + inherit (pkgs.ocamlPackages) + dune_3 + findlib + ocaml + ocaml-lsp + ocamlformat + ocamlformat-rpc-lib + ; + }; shellHook = config.pre-commit.installationScript; }; pre-commit = { From a2fff9333f555c0dc4983fa6269553ef88d11d5b Mon Sep 17 00:00:00 2001 From: Bryan Bennett Date: Sat, 23 Mar 2024 08:17:20 -0400 Subject: [PATCH 3/5] Strip and pack final binary --- default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/default.nix b/default.nix index 737856e..7b4b0a7 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,5 @@ { alcotest +, bintools , bisect_ppx , buildDunePackage , core @@ -13,6 +14,7 @@ , re , reason , sha +, upx , }: buildDunePackage { @@ -39,6 +41,8 @@ buildDunePackage { substituteInPlace tests/spit*.sh --replace "/usr/bin/env" "${coreutils}/bin/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 ''; buildInputs = [ From b19f5d67c54d98369580c1750c64bc8583e00d7c Mon Sep 17 00:00:00 2001 From: Bryan Bennett Date: Mon, 25 Mar 2024 07:29:29 -0400 Subject: [PATCH 4/5] Add very basic .build.yml --- .build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .build.yml diff --git a/.build.yml b/.build.yml new file mode 100644 index 0000000..6118817 --- /dev/null +++ b/.build.yml @@ -0,0 +1,8 @@ +image: nixos/unstable +environment: + NIX_CONFIG: "experimental-features = nix-command flakes" +packages: + - cachix +tasks: + -build: | + nix build . -vL --no-out-link From e513b6e6a6d8621713a791371980972b651ab00c Mon Sep 17 00:00:00 2001 From: Bryan Bennett Date: Mon, 25 Mar 2024 07:30:51 -0400 Subject: [PATCH 5/5] Update flake.lock --- flake.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index 24f924c..0cfb382 100644 --- a/flake.lock +++ b/flake.lock @@ -23,11 +23,11 @@ ] }, "locked": { - "lastModified": 1701473968, - "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", "type": "github" }, "original": { @@ -41,11 +41,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -62,11 +62,11 @@ ] }, "locked": { - "lastModified": 1703887061, - "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", - "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { @@ -77,11 +77,11 @@ }, "nix-filter": { "locked": { - "lastModified": 1701697642, - "narHash": "sha256-L217WytWZHSY8GW9Gx1A64OnNctbuDbfslaTEofXXRw=", + "lastModified": 1710156097, + "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", "owner": "numtide", "repo": "nix-filter", - "rev": "c843418ecfd0344ecb85844b082ff5675e02c443", + "rev": "3342559a24e85fc164b295c3444e8a139924675b", "type": "github" }, "original": { @@ -92,11 +92,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1702272962, - "narHash": "sha256-D+zHwkwPc6oYQ4G3A1HuadopqRwUY/JkMwHz1YF7j4Q=", + "lastModified": 1711106783, + "narHash": "sha256-PDwAcHahc6hEimyrgGmFdft75gmLrJOZ0txX7lFqq+I=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e97b3e4186bcadf0ef1b6be22b8558eab1cdeb5d", + "rev": "a3ed7406349a9335cb4c2a71369b697cecd9d351", "type": "github" }, "original": { @@ -108,11 +108,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1704874635, - "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", "type": "github" }, "original": { @@ -124,11 +124,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1704842529, - "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=", + "lastModified": 1710765496, + "narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5", + "rev": "e367f7a1fb93137af22a3908f00b9a35e2d286a7", "type": "github" }, "original": { @@ -147,11 +147,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1705229514, - "narHash": "sha256-itILy0zimR/iyUGq5Dgg0fiW8plRDyxF153LWGsg3Cw=", + "lastModified": 1710923068, + "narHash": "sha256-6hOpUiuxuwpXXc/xfJsBUJeqqgGI+JMJuLo45aG3cKc=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "ffa9a5b90b0acfaa03b1533b83eaf5dead819a05", + "rev": "e611897ddfdde3ed3eaac4758635d7177ff78673", "type": "github" }, "original": {