From b275b5e84d3fb7cd9ac00fc8744b45082f94aeba Mon Sep 17 00:00:00 2001 From: Malte Poll Date: Wed, 4 Oct 2023 13:17:01 +0200 Subject: [PATCH] bazel: use openssl from nixpkgs --- .../ms_tpm_20_ref.need | 2 +- .../ms_tpm_20_ref.patch | 2 +- 3rdparty/bazel/org_openssl/BUILD.bazel | 45 ---- 3rdparty/bazel/org_openssl/BUILD.nasm.bazel | 17 -- .../bazel/org_openssl/BUILD.openssl.bazel | 125 ----------- 3rdparty/bazel/org_openssl/LICENSE | 202 ------------------ .../org_openssl/openssl_repositories.bzl | 39 ---- 3rdparty/bazel/org_openssl/openssl_setup.bzl | 7 - 3rdparty/bazel/org_openssl/openssl_test.cc | 53 ----- WORKSPACE.bazel | 49 ++--- flake.nix | 7 + 11 files changed, 31 insertions(+), 517 deletions(-) delete mode 100644 3rdparty/bazel/org_openssl/BUILD.bazel delete mode 100644 3rdparty/bazel/org_openssl/BUILD.nasm.bazel delete mode 100644 3rdparty/bazel/org_openssl/BUILD.openssl.bazel delete mode 100644 3rdparty/bazel/org_openssl/LICENSE delete mode 100644 3rdparty/bazel/org_openssl/openssl_repositories.bzl delete mode 100644 3rdparty/bazel/org_openssl/openssl_setup.bzl delete mode 100644 3rdparty/bazel/org_openssl/openssl_test.cc diff --git a/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.need b/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.need index c112011d43..8e33335e30 100644 --- a/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.need +++ b/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.need @@ -229,7 +229,7 @@ cc_library( ], deps = [ ":ms_tpm_20_ref_google_samples", - "@org_openssl//:openssl", + "@org_openssl//:org_openssl", ], target_compatible_with = [ "@platforms//os:linux", diff --git a/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.patch b/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.patch index 8bedaa64ca..9e4bb7fc76 100644 --- a/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.patch +++ b/3rdparty/bazel/com_github_google_go_tpm_tools/ms_tpm_20_ref.patch @@ -229,7 +229,7 @@ + ], + deps = [ + ":ms_tpm_20_ref_google_samples", -+ "@org_openssl//:openssl", ++ "@org_openssl//:org_openssl", + ], + target_compatible_with = [ + "@platforms//os:linux", diff --git a/3rdparty/bazel/org_openssl/BUILD.bazel b/3rdparty/bazel/org_openssl/BUILD.bazel deleted file mode 100644 index b821312bd7..0000000000 --- a/3rdparty/bazel/org_openssl/BUILD.bazel +++ /dev/null @@ -1,45 +0,0 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("@rules_cc//cc:defs.bzl", "cc_test") - -exports_files( - [ - "BUILD.openssl.bazel", - ], - visibility = ["//visibility:public"], -) - -cc_test( - name = "openssl_test", - srcs = ["openssl_test.cc"], - linkopts = select({ - "@org_openssl//:msvc_compiler": [ - "advapi32.lib", - "user32.lib", - ], - "//conditions:default": [], - }), - target_compatible_with = [ - "@platforms//os:linux", - ], - deps = ["@org_openssl//:openssl"], -) - -build_test( - name = "build_test", - target_compatible_with = [ - "@platforms//os:linux", - ], - targets = [ - "@org_openssl//:openssl", - ], - visibility = ["//:__pkg__"], -) - -test_suite( - name = "openssl_test_suite", - tests = [ - ":build_test", - ":openssl_test", - ], - visibility = ["//:__pkg__"], -) diff --git a/3rdparty/bazel/org_openssl/BUILD.nasm.bazel b/3rdparty/bazel/org_openssl/BUILD.nasm.bazel deleted file mode 100644 index 3ac1e817c7..0000000000 --- a/3rdparty/bazel/org_openssl/BUILD.nasm.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@bazel_skylib//rules:select_file.bzl", "select_file") - -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "all_srcs", - srcs = glob( - include = ["**"], - exclude = ["*.bazel"], - ), -) - -select_file( - name = "nasm", - srcs = ":all_srcs", - subpath = "nasm.exe", -) diff --git a/3rdparty/bazel/org_openssl/BUILD.openssl.bazel b/3rdparty/bazel/org_openssl/BUILD.openssl.bazel deleted file mode 100644 index fde161d4c7..0000000000 --- a/3rdparty/bazel/org_openssl/BUILD.openssl.bazel +++ /dev/null @@ -1,125 +0,0 @@ -"""An openssl build file based on a snippet found in the github issue: -https://github.com/bazelbuild/rules_foreign_cc/issues/337 - -Note that the $(PERL) "make variable" (https://docs.bazel.build/versions/main/be/make-variables.html) -is populated by the perl toolchain provided by rules_perl. -""" - -load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make", "configure_make_variant") - -# Read https://wiki.openssl.org/index.php/Compilation_and_Installation - -filegroup( - name = "all_srcs", - srcs = glob( - include = ["**"], - exclude = ["*.bazel"], - ), -) - -CONFIGURE_OPTIONS = [ - "no-comp", - "no-idea", - "no-weak-ssl-ciphers", - "no-tests", -] - -LIB_NAME = "openssl" - -MAKE_TARGETS = [ - "build_programs", - "install_sw", -] - -config_setting( - name = "msvc_compiler", - flag_values = { - "@bazel_tools//tools/cpp:compiler": "msvc-cl", - }, - visibility = ["//visibility:public"], -) - -alias( - name = "openssl", - actual = select({ - ":msvc_compiler": "openssl_msvc", - "//conditions:default": "openssl_default", - }), - visibility = ["//visibility:public"], -) - -configure_make_variant( - name = "openssl_msvc", - build_data = [ - "@nasm//:nasm", - ], - configure_command = "Configure", - configure_in_place = True, - configure_options = CONFIGURE_OPTIONS + [ - "VC-WIN64A", - # Unset Microsoft Assembler (MASM) flags set by built-in MSVC toolchain, - # as NASM is unsed to build OpenSSL rather than MASM - "ASFLAGS=\" \"", - ], - configure_prefix = "$$PERL", - env = { - # The Zi flag must be set otherwise OpenSSL fails to build due to missing .pdb files - "CFLAGS": "-Zi", - "PATH": "$$(dirname $(execpath @nasm//:nasm))", - "PERL": "$$EXT_BUILD_ROOT$$/$(PERL)", - }, - lib_name = LIB_NAME, - lib_source = ":all_srcs", - out_binaries = ["openssl.exe"], - out_interface_libs = [ - "libssl.lib", - "libcrypto.lib", - ], - out_shared_libs = [ - "libssl-1_1-x64.dll", - "libcrypto-1_1-x64.dll", - ], - targets = MAKE_TARGETS, - toolchain = "@rules_foreign_cc//bazel/toolchains:preinstalled_nmake_toolchain", - toolchains = ["@rules_perl//:current_toolchain"], -) - -configure_make( - name = "openssl_default", - configure_command = "config", - configure_in_place = True, - configure_options = CONFIGURE_OPTIONS, - env = select({ - "@platforms//os:macos": { - "AR": "", - "PERL": "$$EXT_BUILD_ROOT$$/$(PERL)", - }, - "//conditions:default": { - "PERL": "$$EXT_BUILD_ROOT$$/$(PERL)", - }, - }), - lib_name = LIB_NAME, - lib_source = ":all_srcs", - out_binaries = ["openssl"], - # Note that for Linux builds, libssl must come before libcrypto on the linker command-line. - # As such, libssl must be listed before libcrypto - out_shared_libs = select({ - "@platforms//os:macos": [ - "libssl.1.1.dylib", - "libcrypto.1.1.dylib", - ], - "//conditions:default": [ - "libssl.so.1.1", - "libcrypto.so.1.1", - ], - }), - targets = MAKE_TARGETS, - toolchains = ["@rules_perl//:current_toolchain"], -) - -filegroup( - name = "gen_dir", - srcs = [":openssl"], - output_group = "gen_dir", - visibility = ["//visibility:public"], -) diff --git a/3rdparty/bazel/org_openssl/LICENSE b/3rdparty/bazel/org_openssl/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/3rdparty/bazel/org_openssl/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/3rdparty/bazel/org_openssl/openssl_repositories.bzl b/3rdparty/bazel/org_openssl/openssl_repositories.bzl deleted file mode 100644 index 48e4a59992..0000000000 --- a/3rdparty/bazel/org_openssl/openssl_repositories.bzl +++ /dev/null @@ -1,39 +0,0 @@ -"""A module defining the third party dependency OpenSSL""" - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") - -def openssl_repositories(): - maybe( - http_archive, - name = "org_openssl", - build_file = Label("//3rdparty/bazel/org_openssl:BUILD.openssl.bazel"), - sha256 = "c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa", - strip_prefix = "openssl-1.1.1s", - urls = [ - "https://www.openssl.org/source/openssl-1.1.1s.tar.gz", - "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1s.tar.gz", - ], - ) - - maybe( - http_archive, - name = "nasm", - build_file = Label("//3rdparty/bazel/org_openssl:BUILD.nasm.bazel"), - sha256 = "f5c93c146f52b4f1664fa3ce6579f961a910e869ab0dae431bd871bdd2584ef2", - strip_prefix = "nasm-2.15.05", - urls = [ - "https://mirror.bazel.build/www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip", - "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip", - ], - ) - - maybe( - http_archive, - name = "rules_perl", - sha256 = "24957cea0a43ee70bff9b78256698a0a11e89455483b30b4c41d1f6bfd20d269", - strip_prefix = "rules_perl-db026ffa0d89fdff97de0c27199d84bd2c3b696c", - urls = [ - "https://github.com/malt3/rules_perl/archive/db026ffa0d89fdff97de0c27199d84bd2c3b696c.tar.gz", - ], - ) diff --git a/3rdparty/bazel/org_openssl/openssl_setup.bzl b/3rdparty/bazel/org_openssl/openssl_setup.bzl deleted file mode 100644 index 9217480a0b..0000000000 --- a/3rdparty/bazel/org_openssl/openssl_setup.bzl +++ /dev/null @@ -1,7 +0,0 @@ -"""A module initialising the third party dependencies OpenSSL""" - -load("@rules_perl//perl:deps.bzl", "perl_register_toolchains", "perl_rules_dependencies") - -def openssl_setup(): - perl_rules_dependencies() - perl_register_toolchains() diff --git a/3rdparty/bazel/org_openssl/openssl_test.cc b/3rdparty/bazel/org_openssl/openssl_test.cc deleted file mode 100644 index 611f7b132e..0000000000 --- a/3rdparty/bazel/org_openssl/openssl_test.cc +++ /dev/null @@ -1,53 +0,0 @@ -#include - -#include -#include -#include -#include - -// Use (void) to silent unused warnings. -#define assertm(exp, msg) assert(((void)msg, exp)) - -// From https://stackoverflow.com/a/2262447/7768383 -bool simpleSHA256(const void* input, unsigned long length, unsigned char* md) -{ - SHA256_CTX context; - if (!SHA256_Init(&context)) - return false; - - if (!SHA256_Update(&context, (unsigned char*)input, length)) - return false; - - if (!SHA256_Final(md, &context)) - return false; - - return true; -} - -// Convert an byte array into a string -std::string fromByteArray(const unsigned char* data, unsigned long length) -{ - std::stringstream shastr; - shastr << std::hex << std::setfill('0'); - for (unsigned long i = 0; i < length; ++i) - { - shastr << std::setw(2) << static_cast(data[i]); - } - - return shastr.str(); -} - -std::string MESSAGE = "hello world"; -std::string MESSAGE_HASH = "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"; - -int main(int argc, char* argv[]) -{ - unsigned char md[SHA256_DIGEST_LENGTH] = {}; - - assertm(simpleSHA256(static_cast(MESSAGE.data()), MESSAGE.size(), md), "Failed to generate hash"); - std::string hash = fromByteArray(md, SHA256_DIGEST_LENGTH); - - assertm(hash == MESSAGE_HASH, "Unexpected message hash"); - - return 0; -} diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 84221d0a16..0b4bdbdba6 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -28,6 +28,28 @@ nixpkgs_flake_package( package = "mkosi", ) +nixpkgs_flake_package( + name = "org_openssl", + build_file_content = """\ +load("@rules_cc//cc:defs.bzl", "cc_library") +filegroup( + name = "include", + srcs = glob(["include/**/*.h"]), + visibility = ["//visibility:public"], +) +cc_library( + name = "org_openssl", + srcs = glob(["lib/**/*.a"]), + hdrs = [":include"], + strip_include_prefix = "include", + visibility = ["//visibility:public"], +) +""", + nix_flake_file = "//:flake.nix", + nix_flake_lock_file = "//:flake.lock", + package = "openssl", +) + nixpkgs_package( name = "diffutils", repository = "@nixpkgs", @@ -157,33 +179,6 @@ register_toolchains( "@zig_sdk//toolchain:windows_amd64", ) -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "rules_foreign_cc", - sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51", - strip_prefix = "rules_foreign_cc-0.9.0", - type = "tar.gz", - urls = [ - "https://cdn.confidential.cloud/constellation/cas/sha256/2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51", - "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.9.0.tar.gz", - ], -) - -load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") - -# This sets up some common toolchains for building targets. For more details, please see -# https://bazelbuild.github.io/rules_foreign_cc/0.9.0/flatten.html#rules_foreign_cc_dependencies -rules_foreign_cc_dependencies() - -load("//3rdparty/bazel/org_openssl:openssl_repositories.bzl", "openssl_repositories") - -openssl_repositories() - -load("//3rdparty/bazel/org_openssl:openssl_setup.bzl", "openssl_setup") - -openssl_setup() - # Packaging rules (tar) load("//bazel/toolchains:pkg_deps.bzl", "pkg_deps") diff --git a/flake.nix b/flake.nix index d5f14d5307..ef36e9a6e8 100644 --- a/flake.nix +++ b/flake.nix @@ -35,10 +35,17 @@ ]); })); + openssl-static = pkgsUnstable.openssl.override { static = true; }; + in { packages.mkosi = mkosiDev; + packages.openssl = pkgsUnstable.symlinkJoin { + name = "openssl"; + paths = [ openssl-static.out openssl-static.dev ]; + }; + devShells.default = import ./nix/shells/default.nix { pkgs = pkgsUnstable; }; formatter = nixpkgsUnstable.legacyPackages.${system}.nixpkgs-fmt;