From c5b2624352b024a28cbf435185a9a3f6ee3a683f Mon Sep 17 00:00:00 2001 From: t4ccer Date: Wed, 11 Oct 2023 21:56:51 -0600 Subject: [PATCH] More robust source locking --- .../single-language/haskell-cabal/lock.json | 228 ++++++++++++------ .../dream2nix/WIP-haskell-cabal/default.nix | 38 +-- modules/dream2nix/WIP-haskell-cabal/lock.py | 32 ++- 3 files changed, 189 insertions(+), 109 deletions(-) diff --git a/examples/packages/single-language/haskell-cabal/lock.json b/examples/packages/single-language/haskell-cabal/lock.json index 56752b59..df32d965 100644 --- a/examples/packages/single-language/haskell-cabal/lock.json +++ b/examples/packages/single-language/haskell-cabal/lock.json @@ -3,154 +3,230 @@ "StateVar-1.2.2-cf8c47fbbee539e2b57175002e2dfe4425e47a8b6ccfe5beb357a085b68a502b": { "name": "StateVar", "version": "1.2.2", - "cabal-sha256": "3c022c00485fe165e3080d5da6b3ca9c9b02f62c5deebc584d1b3d1309ce673e", - "cabal-url": "https://hackage.haskell.org/package/StateVar-1.2.2/revision/0.cabal", - "url": "http://hackage.haskell.org/package/StateVar/StateVar-1.2.2.tar.gz", - "sha256": "5e4b39da395656a59827b0280508aafdc70335798b50e5d6fd52596026251825" + "cabal": { + "url": "https://hackage.haskell.org/package/StateVar-1.2.2/revision/0.cabal", + "hash": "sha256-PAIsAEhf4WXjCA1dprPKnJsC9ixd7rxYTRs9EwnOZz4=" + }, + "src": { + "url": "http://hackage.haskell.org/package/StateVar/StateVar-1.2.2.tar.gz", + "hash": "sha256-Lj9AIkUQ1ph8l1Bc6HLWuuLei43E8tfBpHxYG/XZM78=" + } }, "assoc-1.1-a0a323b970e3942d6fdb9429cfd3dff92b9e9b5b2c6e2594e70cc6c3466137dd": { "name": "assoc", "version": "1.1", - "cabal-sha256": "56d0fd1c17aaf6268e81bf19ba5afe186128d7f88126bd546d5b3151ab692652", - "cabal-url": "https://hackage.haskell.org/package/assoc-1.1/revision/1.cabal", - "url": "http://hackage.haskell.org/package/assoc/assoc-1.1.tar.gz", - "sha256": "7aa2e6548b3d9d49a286ac20639479aaf6c47a1446113ed784d98737c5f60df4" + "cabal": { + "url": "https://hackage.haskell.org/package/assoc-1.1/revision/1.cabal", + "hash": "sha256-VtD9HBeq9iaOgb8Zulr+GGEo1/iBJr1UbVsxUatpJlI=" + }, + "src": { + "url": "http://hackage.haskell.org/package/assoc/assoc-1.1.tar.gz", + "hash": "sha256-5bi78/qSe/twbD/9asNpvtgY1if4lbJh+SjJlZ1iO88=" + } }, "base-orphans-0.9.1-bb126d94e515d32e71f537247f2e1466962bc7fd12e6e1f18648ed322c873909": { "name": "base-orphans", "version": "0.9.1", - "cabal-sha256": "c4733d09f798fc4304e936924a1a7d9fc2425aefad6c46ad4592035254b46051", - "cabal-url": "https://hackage.haskell.org/package/base-orphans-0.9.1/revision/0.cabal", - "url": "http://hackage.haskell.org/package/base-orphans/base-orphans-0.9.1.tar.gz", - "sha256": "5bbf2da382c5b212d6a8be2f8c49edee0eba30f272a15fd32c13e6e4091ef172" + "cabal": { + "url": "https://hackage.haskell.org/package/base-orphans-0.9.1/revision/0.cabal", + "hash": "sha256-xHM9CfeY/EME6TaSShp9n8JCWu+tbEatRZIDUlS0YFE=" + }, + "src": { + "url": "http://hackage.haskell.org/package/base-orphans/base-orphans-0.9.1.tar.gz", + "hash": "sha256-6aPwr3q2aXW5L9MeRWzisxhJarpj2tdwdlbUvKAsQ7Q=" + } }, "bifunctors-5.6.1-f28d42274a9a30f24ae1a65ec93500cea83eaca2d75902d9309a51e6a15bad10": { "name": "bifunctors", "version": "5.6.1", - "cabal-sha256": "82fa7ed8f69f0bfa375de117ab36414c0b96a97ee046edc3ac6da7a295a94755", - "cabal-url": "https://hackage.haskell.org/package/bifunctors-5.6.1/revision/2.cabal", - "url": "http://hackage.haskell.org/package/bifunctors/bifunctors-5.6.1.tar.gz", - "sha256": "06381471b5be16516a1b2c4b21a5101a3d991038bface8e0cad144c0044d57fc" + "cabal": { + "url": "https://hackage.haskell.org/package/bifunctors-5.6.1/revision/2.cabal", + "hash": "sha256-gvp+2PafC/o3XeEXqzZBTAuWqX7gRu3DrG2nopWpR1U=" + }, + "src": { + "url": "http://hackage.haskell.org/package/bifunctors/bifunctors-5.6.1.tar.gz", + "hash": "sha256-PE+ymT2cUsEeTqgN5ty/BGqzvWlyj+fPJjYvMsbZYoo=" + } }, "comonad-5.0.8-81fad45419529ce75b7b01f100b7207e1b47a5b47917bfefb2931e997529ac19": { "name": "comonad", "version": "5.0.8", - "cabal-sha256": "4a4dbfbd03fb4963987710fca994e8b5624bd05a33e5f95b7581b26f8229c5e3", - "cabal-url": "https://hackage.haskell.org/package/comonad-5.0.8/revision/2.cabal", - "url": "http://hackage.haskell.org/package/comonad/comonad-5.0.8.tar.gz", - "sha256": "ef6cdf2cc292cc43ee6aa96c581b235fdea8ab44a0bffb24dc79ae2b2ef33d13" + "cabal": { + "url": "https://hackage.haskell.org/package/comonad-5.0.8/revision/2.cabal", + "hash": "sha256-Sk2/vQP7SWOYdxD8qZTotWJL0Foz5flbdYGyb4IpxeM=" + }, + "src": { + "url": "http://hackage.haskell.org/package/comonad/comonad-5.0.8.tar.gz", + "hash": "sha256-7Jlhs/RTGbv2uN48XtFdnUnNEcc8lCnUpJi64dJHlvM=" + } }, "contravariant-1.5.5-3b9ce530083a459f84e3df21b54474f3bf15bb2fcbd13cca4d05977dd74c1a10": { "name": "contravariant", "version": "1.5.5", - "cabal-sha256": "470ed0e040e879e2da4af1b2c8f94e199f6135852a8107858d5ae0a95365835f", - "cabal-url": "https://hackage.haskell.org/package/contravariant-1.5.5/revision/0.cabal", - "url": "http://hackage.haskell.org/package/contravariant/contravariant-1.5.5.tar.gz", - "sha256": "062fd66580d7aad0b5ba93e644ffa7feee69276ef50f20d4ed9f1deb7642dffa" + "cabal": { + "url": "https://hackage.haskell.org/package/contravariant-1.5.5/revision/0.cabal", + "hash": "sha256-Rw7Q4EDoeeLaSvGyyPlOGZ9hNYUqgQeFjVrgqVNlg18=" + }, + "src": { + "url": "http://hackage.haskell.org/package/contravariant/contravariant-1.5.5.tar.gz", + "hash": "sha256-SN5PZGGlIb0VztCwM50n/7E4a9UYYQtvEnTsKNheYSQ=" + } }, "distributive-0.6.2.1-3ff59aa3fe797089665920cdc4710b342cb42b3ec3760b12fe1b052139d05308": { "name": "distributive", "version": "0.6.2.1", - "cabal-sha256": "0f99f5541cca04acf89b64432b03422b6408e830a8dff30e6c4334ef1a48680c", - "cabal-url": "https://hackage.haskell.org/package/distributive-0.6.2.1/revision/1.cabal", - "url": "http://hackage.haskell.org/package/distributive/distributive-0.6.2.1.tar.gz", - "sha256": "d7351392e078f58caa46630a4b9c643e1e2e9dddee45848c5c8358e7b1316b91" + "cabal": { + "url": "https://hackage.haskell.org/package/distributive-0.6.2.1/revision/1.cabal", + "hash": "sha256-D5n1VBzKBKz4m2RDKwNCK2QI6DCo3/MObEM07xpIaAw=" + }, + "src": { + "url": "http://hackage.haskell.org/package/distributive/distributive-0.6.2.1.tar.gz", + "hash": "sha256-RzaqSsIn7LAH6m2FRbWNLnsZ+nFnCcE3q0MvbsgV3Pk=" + } }, "foldable1-classes-compat-0.1-020755d5ecf87ee5dcbe9f3ce3a2afabe4ce2db2fb82b4eab884942e54d1e31a": { "name": "foldable1-classes-compat", "version": "0.1", - "cabal-sha256": "fb4b3cedd33d5c22c573c39baa930c78eaa4feb22d43abb680c3149f8ab9fa4e", - "cabal-url": "https://hackage.haskell.org/package/foldable1-classes-compat-0.1/revision/4.cabal", - "url": "http://hackage.haskell.org/package/foldable1-classes-compat/foldable1-classes-compat-0.1.tar.gz", - "sha256": "d057c3f358e1a6b72c73519bc64ba6aa959f066c08fed69f73258555ef95ff12" + "cabal": { + "url": "https://hackage.haskell.org/package/foldable1-classes-compat-0.1/revision/4.cabal", + "hash": "sha256-+0s87dM9XCLFc8ObqpMMeOqk/rItQ6u2gMMUn4q5+k4=" + }, + "src": { + "url": "http://hackage.haskell.org/package/foldable1-classes-compat/foldable1-classes-compat-0.1.tar.gz", + "hash": "sha256-Om6/w38G4ZaBZAGzlFb6ElvU4BCU3aOCXogpIZsm4RE=" + } }, "free-5.2-e7a50787d932970b187bce577837d31b5e3b4c31a6940d446121ff1dc4eeaf47": { "name": "free", "version": "5.2", - "cabal-sha256": "4dd76c1a19f81d7866e7b75682350f1ef3e0441b19b4d07eccdd9ef326a0be70", - "cabal-url": "https://hackage.haskell.org/package/free-5.2/revision/3.cabal", - "url": "http://hackage.haskell.org/package/free/free-5.2.tar.gz", - "sha256": "72867f7c89173263765736e8d395e94291f1aaea626ecb1d673d72ce90b94f89" + "cabal": { + "url": "https://hackage.haskell.org/package/free-5.2/revision/3.cabal", + "hash": "sha256-TddsGhn4HXhm57dWgjUPHvPgRBsZtNB+zN2e8yagvnA=" + }, + "src": { + "url": "http://hackage.haskell.org/package/free/free-5.2.tar.gz", + "hash": "sha256-AcvcPGgeZGnAd6C6DxAjTLEcJVY1fERK5NpzCeA0xCw=" + } }, "hashable-1.4.3.0-4dc8dd84bc5d917d3ba522c535426ae92c242ca990fce19c526ecaffbeb1c78e": { "name": "hashable", "version": "1.4.3.0", - "cabal-sha256": "f3bf68acfa0df7a064a378ef2cdcfeb55e6fb96100675f4c593556dcbf3d7194", - "cabal-url": "https://hackage.haskell.org/package/hashable-1.4.3.0/revision/1.cabal", - "url": "http://hackage.haskell.org/package/hashable/hashable-1.4.3.0.tar.gz", - "sha256": "32efb16c2891786209b7cbe5c39df9b3a9ae51e836f1a54f646bc4602b7ab0f5" + "cabal": { + "url": "https://hackage.haskell.org/package/hashable-1.4.3.0/revision/1.cabal", + "hash": "sha256-879orPoN96Bko3jvLNz+tV5vuWEAZ19MWTVW3L89cZQ=" + }, + "src": { + "url": "http://hackage.haskell.org/package/hashable/hashable-1.4.3.0.tar.gz", + "hash": "sha256-D0SmhSO7gdJIfqqf9hDlnpK4T6qMgiDK2tAUVvdHR3Q=" + } }, "indexed-traversable-0.1.3-59bd0d4010c8b599ed0c4fe6f3b5cb3e2b2b599d3ecf3dd9b6803e2ec6bf797c": { "name": "indexed-traversable", "version": "0.1.3", - "cabal-sha256": "911f96592752ce4ffbeda00b1155dbbfac5135c71d6755ae02c00552819a9b17", - "cabal-url": "https://hackage.haskell.org/package/indexed-traversable-0.1.3/revision/0.cabal", - "url": "http://hackage.haskell.org/package/indexed-traversable/indexed-traversable-0.1.3.tar.gz", - "sha256": "1d32925fb6f78e3a52a849b29fc4360df51c97be95ba8ac642517d3ff01a53d9" + "cabal": { + "url": "https://hackage.haskell.org/package/indexed-traversable-0.1.3/revision/0.cabal", + "hash": "sha256-kR+WWSdSzk/77aALEVXbv6xRNccdZ1WuAsAFUoGamxc=" + }, + "src": { + "url": "http://hackage.haskell.org/package/indexed-traversable/indexed-traversable-0.1.3.tar.gz", + "hash": "sha256-TQize782MFwR4ac7Q/mJw/FmwzmDPsZRRPwMUICXjHc=" + } }, "profunctors-5.6.2-0af7e1acd30ef748e6d882f7e643e169b9d2a494778a07ebed1b00426edad2b5": { "name": "profunctors", "version": "5.6.2", - "cabal-sha256": "e178ba4468982326656626e2089e296f64485e68fdddc9f4476dcd5d612b4f78", - "cabal-url": "https://hackage.haskell.org/package/profunctors-5.6.2/revision/3.cabal", - "url": "http://hackage.haskell.org/package/profunctors/profunctors-5.6.2.tar.gz", - "sha256": "65955d7b50525a4a3bccdab1d982d2ae342897fd38140d5a94b5ef3800d8c92a" + "cabal": { + "url": "https://hackage.haskell.org/package/profunctors-5.6.2/revision/3.cabal", + "hash": "sha256-4Xi6RGiYIyZlZibiCJ4pb2RIXmj93cn0R23NXWErT3g=" + }, + "src": { + "url": "http://hackage.haskell.org/package/profunctors/profunctors-5.6.2.tar.gz", + "hash": "sha256-Vrlp6lvMNi+Bk+AHBMbnQE9NVzdASrcrFaWbkJew9qU=" + } }, "semigroupoids-6.0.0.1-9969faff2c06e197de98e299e1bfa350e96b18cec69a1bff9c65596acc8ef9da": { "name": "semigroupoids", "version": "6.0.0.1", - "cabal-sha256": "47a23b451c114e65361e713e8fe36828fca3a84285325e8f444254b2ab0c43c5", - "cabal-url": "https://hackage.haskell.org/package/semigroupoids-6.0.0.1/revision/1.cabal", - "url": "http://hackage.haskell.org/package/semigroupoids/semigroupoids-6.0.0.1.tar.gz", - "sha256": "7da38a9891bdf8205fd6522cdb712956b8c0bf5c52983da60295c8e057d77934" + "cabal": { + "url": "https://hackage.haskell.org/package/semigroupoids-6.0.0.1/revision/1.cabal", + "hash": "sha256-R6I7RRwRTmU2HnE+j+NoKPyjqEKFMl6PREJUsqsMQ8U=" + }, + "src": { + "url": "http://hackage.haskell.org/package/semigroupoids/semigroupoids-6.0.0.1.tar.gz", + "hash": "sha256-U6z7/en+XojIg6OlC1CVKgR7j5lwtXlMkTwmYd2yMro=" + } }, "tagged-0.8.8-a0ceba434643f0e1990194c2a392bc13a5cc345f9787019a9c12d5abf769dc41": { "name": "tagged", "version": "0.8.8", - "cabal-sha256": "c4fdbd3e1c423af0ccf8eb9e9962620106c34e32ed8e0cc647fb06899a703e04", - "cabal-url": "https://hackage.haskell.org/package/tagged-0.8.8/revision/0.cabal", - "url": "http://hackage.haskell.org/package/tagged/tagged-0.8.8.tar.gz", - "sha256": "a083fa7835516203c168433a1c8dfc0290a94b05fedab566ad0640fc9137a6a7" + "cabal": { + "url": "https://hackage.haskell.org/package/tagged-0.8.8/revision/0.cabal", + "hash": "sha256-xP29PhxCOvDM+OuemWJiAQbDTjLtjgzGR/sGiZpwPgQ=" + }, + "src": { + "url": "http://hackage.haskell.org/package/tagged/tagged-0.8.8.tar.gz", + "hash": "sha256-qfUjXl+yEBDlYYmZgMpoE6Ct2YodTUHtQ+KHrIFjS9Q=" + } }, "th-abstraction-0.6.0.0-9aaaedf3eb0d8b6b9657df806e8b2a3a8120d7dd98cf662192696d944938c7fa": { "name": "th-abstraction", "version": "0.6.0.0", - "cabal-sha256": "d8959fa6a2812afcdd5f6f255fd6be8b3e0ca01e425586a554544fcb70b0ec7c", - "cabal-url": "https://hackage.haskell.org/package/th-abstraction-0.6.0.0/revision/1.cabal", - "url": "http://hackage.haskell.org/package/th-abstraction/th-abstraction-0.6.0.0.tar.gz", - "sha256": "69ea6eca1f0c00b6e1e1f8329c908ec76e73855e2ce6e91ace2f8bbf92c51a30" + "cabal": { + "url": "https://hackage.haskell.org/package/th-abstraction-0.6.0.0/revision/1.cabal", + "hash": "sha256-2JWfpqKBKvzdX28lX9a+iz4MoB5CVYalVFRPy3Cw7Hw=" + }, + "src": { + "url": "http://hackage.haskell.org/package/th-abstraction/th-abstraction-0.6.0.0.tar.gz", + "hash": "sha256-eOUH1OSmLL8hS8mzijfJvGhxfMEU2vQozKHKlbv2B/A=" + } }, "transformers-base-0.4.6-ec17b969c594f087db41d88742a0dec51c83b7219ba896afc40578d47e47d720": { "name": "transformers-base", "version": "0.4.6", - "cabal-sha256": "6f18f320e371c8954c4b6b211e2fdd5d15a6d6310bd605b9d640f47ede408961", - "cabal-url": "https://hackage.haskell.org/package/transformers-base-0.4.6/revision/0.cabal", - "url": "http://hackage.haskell.org/package/transformers-base/transformers-base-0.4.6.tar.gz", - "sha256": "323bf8689eb691b122661cffa41a25e00fea7a768433fe2dde35d3da7d32cf90" + "cabal": { + "url": "https://hackage.haskell.org/package/transformers-base-0.4.6/revision/0.cabal", + "hash": "sha256-bxjzIONxyJVMS2shHi/dXRWm1jEL1gW51kD0ft5AiWE=" + }, + "src": { + "url": "http://hackage.haskell.org/package/transformers-base/transformers-base-0.4.6.tar.gz", + "hash": "sha256-lcIZSZtAeaUr1tJxsOJj3XyauKwAKHcPotrlrFrPtYg=" + } }, "transformers-compat-0.7.2-2149c73f816de26f42e847494a4774f347e627526e04a9db86fdac821179748a": { "name": "transformers-compat", "version": "0.7.2", - "cabal-sha256": "044fb9955f63ee138fcebedfdcbe54afe741f2d5892a2d0bdf3a8052bd342643", - "cabal-url": "https://hackage.haskell.org/package/transformers-compat-0.7.2/revision/0.cabal", - "url": "http://hackage.haskell.org/package/transformers-compat/transformers-compat-0.7.2.tar.gz", - "sha256": "b62c7304c9f3cbc9463d0739aa85cb9489f217ea092b9d625d417514fbcc9d6a" + "cabal": { + "url": "https://hackage.haskell.org/package/transformers-compat-0.7.2/revision/0.cabal", + "hash": "sha256-BE+5lV9j7hOPzr7f3L5Ur+dB8tWJKi0L3zqAUr00JkM=" + }, + "src": { + "url": "http://hackage.haskell.org/package/transformers-compat/transformers-compat-0.7.2.tar.gz", + "hash": "sha256-Y18vN1o5Q3/XnWbVa3XxYOpqeHOTXfa3u7Gsx+vesYc=" + } }, "unordered-containers-0.2.19.1-fd8945f93fd4931c5f08e27a8fca121d3f94765a1d7c2c59b6cd540c7af6d376": { "name": "unordered-containers", "version": "0.2.19.1", - "cabal-sha256": "9ad8972c2e913c37b1d4f0e1261517fd7a1b8c8a58077e057be69837e3dbaa00", - "cabal-url": "https://hackage.haskell.org/package/unordered-containers-0.2.19.1/revision/2.cabal", - "url": "http://hackage.haskell.org/package/unordered-containers/unordered-containers-0.2.19.1.tar.gz", - "sha256": "1b27bec5e0d522b27a6029ebf4c4a6d40acbc083c787008e32fb55c4b1d128d2" + "cabal": { + "url": "https://hackage.haskell.org/package/unordered-containers-0.2.19.1/revision/2.cabal", + "hash": "sha256-mtiXLC6RPDex1PDhJhUX/XobjIpYB34Fe+aYN+PbqgA=" + }, + "src": { + "url": "http://hackage.haskell.org/package/unordered-containers/unordered-containers-0.2.19.1.tar.gz", + "hash": "sha256-wzfh4BOMhBNNnB/uuhLwJJM4Ix5vY/ZvmZ/xpBfyzKE=" + } }, "zlib-0.6.3.0-36d455b073cd2f52fce48d7ee5952ee655d626d80206236ff97d7bc4d3c51d0e": { "name": "zlib", "version": "0.6.3.0", - "cabal-sha256": "cf2a8edc1f4086934638d11882423780dd096c4e77d9c6639ccc469c6c26f041", - "cabal-url": "https://hackage.haskell.org/package/zlib-0.6.3.0/revision/3.cabal", - "url": "http://hackage.haskell.org/package/zlib/zlib-0.6.3.0.tar.gz", - "sha256": "9eaa989ad4534438b5beb51c1d3a4c8f6a088fdff0b259a5394fbf39aaee04da" + "cabal": { + "url": "https://hackage.haskell.org/package/zlib-0.6.3.0/revision/3.cabal", + "hash": "sha256-zyqO3B9AhpNGONEYgkI3gN0JbE532cZjnMxGnGwm8EE=" + }, + "src": { + "url": "http://hackage.haskell.org/package/zlib/zlib-0.6.3.0.tar.gz", + "hash": "sha256-3PLCQ94ONQtjQc8AqVMgCVrZZW766T8PDevOvKC4VDw=" + } } }, "invalidationHash": "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a" diff --git a/modules/dream2nix/WIP-haskell-cabal/default.nix b/modules/dream2nix/WIP-haskell-cabal/default.nix index c09adf06..8f20666e 100644 --- a/modules/dream2nix/WIP-haskell-cabal/default.nix +++ b/modules/dream2nix/WIP-haskell-cabal/default.nix @@ -22,42 +22,20 @@ ; }; - getNameVer = p: "${p.name}-${p.version}"; - fetchCabalFile = p: config.deps.fetchurl { - url = p.cabal-url; - sha256 = p.cabal-sha256; + inherit (p.cabal) url hash; }; - fetchFromHackage = p: - config.deps.stdenv.mkDerivation { - name = "${getNameVer p}-source"; - - # NOTE: Cannot use fetchTarball because cabal gives hash before unpacking - src = config.deps.fetchurl { - inherit (p) url sha256; - }; - - # We are fetching cabal file separately to match the revision - # p.url contains only "base" release - installPhase = '' - runHook preInstall - - mkdir unpacked - tar -C unpacked -xf "$src" - mv unpacked/${getNameVer p} $out - cp ${fetchCabalFile p} $out/${p.name}.cabal - - runHook postInstall - ''; - - dontFixup = true; + fetchDependency = p: + config.deps.fetchzip { + inherit (p.src) url hash; }; vendorPackage = p: '' - echo "Vendoring ${fetchFromHackage p}" - cp -r ${fetchFromHackage p} $VENDOR_DIR/${p.name} + echo "Vendoring ${p.name}-${p.version}" + cp --no-preserve=all -r ${fetchDependency p} $VENDOR_DIR/${p.name} + cp --no-preserve=all ${fetchCabalFile p} $VENDOR_DIR/${p.name}/${p.name}.cabal ''; vendorPackages = @@ -123,6 +101,7 @@ in { config.deps.cabal-install config.deps.haskell-compiler config.deps.coreutils + config.deps.nix (config.deps.python3.withPackages (ps: with ps; [requests])) ] '' cd $TMPDIR @@ -139,6 +118,7 @@ in { cabal-install python3 fetchurl + fetchzip stdenv coreutils bash diff --git a/modules/dream2nix/WIP-haskell-cabal/lock.py b/modules/dream2nix/WIP-haskell-cabal/lock.py index 093329dc..da03cb6b 100644 --- a/modules/dream2nix/WIP-haskell-cabal/lock.py +++ b/modules/dream2nix/WIP-haskell-cabal/lock.py @@ -10,6 +10,7 @@ from urllib.parse import urljoin import json import os import requests +import subprocess import sys with open("./dist-newstyle/cache/plan.json") as f: @@ -30,6 +31,16 @@ pkg_len = len(pkgs) lock = {} + +def to_sri(h): + return subprocess.run( + ["nix", "hash", "to-sri", "--type", "sha256", h], + check=True, + capture_output=True, + text=True, + ).stdout.strip() + + for i, pkg in enumerate(pkgs): name = pkg["pkg-name"] id = pkg["id"] @@ -56,13 +67,26 @@ for i, pkg in enumerate(pkgs): rev_hash = sha256(rev_cabal.encode("utf-8")).hexdigest() if rev_hash == pkg["pkg-cabal-sha256"]: + # Cabal gives hash before unpack, so we need to prefetch the source + src_hash = subprocess.run( + ["nix-prefetch-url", "--unpack", "--type", "sha256", url], + check=True, + capture_output=True, + text=True, + ).stdout.strip() + src_hash = to_sri(src_hash) + lock[id] = { "name": name, "version": version, - "cabal-sha256": rev_hash, - "cabal-url": rev_url, - "url": url, - "sha256": pkg["pkg-src-sha256"], + "cabal": { + "url": rev_url, + "hash": to_sri(rev_hash), + }, + "src": { + "url": url, + "hash": src_hash, + }, } break else: