From 905a6a95f6c663b2180a3e5d228d7d5508b6e839 Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Sun, 9 Jul 2023 22:57:06 -0500 Subject: [PATCH] chore: switching to nix std --- .editorconfig | 231 +++++++++--------- .envrc | 1 - .gitignore | 5 + flake.lock | 517 +++++++++++++++++++++++++++++++++++++++-- flake.nix | 30 ++- lefthook.yml | 17 -- nix/common/configs.nix | 255 ++++++++++++++++++++ nix/common/shells.nix | 38 +++ scripts/release.sh | 27 +-- 9 files changed, 942 insertions(+), 179 deletions(-) delete mode 100644 lefthook.yml create mode 100644 nix/common/configs.nix create mode 100644 nix/common/shells.nix diff --git a/.editorconfig b/.editorconfig index 819c8e1..51b994c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,122 +1,121 @@ -# EditorConfig is awesome: https://EditorConfig.org - -root = true +root=true [*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -indent_style = space -indent_size = 4 +charset=utf-8 +csharp_new_line_before_members_in_object_initializers=false +csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion +csharp_preserve_single_line_blocks=true +csharp_preserve_single_line_statements=false +csharp_space_after_cast=false +csharp_style_var_elsewhere=false:hint +csharp_style_var_for_built_in_types=false:hint +csharp_style_var_when_type_is_apparent=true:hint +curly_bracket_next_line=true +dotnet_style_predefined_type_for_locals_parameters_members=true:hint +dotnet_style_predefined_type_for_member_access=true:hint +dotnet_style_qualification_for_event=true:hint +dotnet_style_qualification_for_field=true:hint +dotnet_style_qualification_for_method=true:hint +dotnet_style_qualification_for_property=true:hint +dotnet_style_require_accessibility_modifiers=for_non_interface_members:hint +end_of_line=lf +indent_brace_style=K&R +indent_size=4 +indent_style=space +insert_final_newline=true +max_line_length=80 +resharper_alignment_tab_fill_style=optimal_fill +resharper_apply_on_completion=true +resharper_blank_lines_after_control_transfer_statements=1 +resharper_blank_lines_around_single_line_auto_property=1 +resharper_blank_lines_around_single_line_property=1 +resharper_blank_lines_before_single_line_comment=1 +resharper_blank_lines_between_using_groups=1 +resharper_braces_for_for=required +resharper_braces_for_foreach=required +resharper_braces_for_ifelse=required +resharper_braces_for_while=required +resharper_can_use_global_alias=false +resharper_check_namespace_highlighting=none +resharper_convert_to_auto_property_highlighting=none +resharper_csharp_blank_lines_around_single_line_field=1 +resharper_csharp_blank_lines_around_single_line_invocable=1 +resharper_csharp_indent_style=tab +resharper_csharp_insert_final_newline=true +resharper_csharp_keep_blank_lines_in_code=1 +resharper_csharp_keep_blank_lines_in_declarations=1 +resharper_csharp_new_line_before_while=true +resharper_csharp_use_indent_from_vs=false +resharper_csharp_wrap_arguments_style=chop_if_long +resharper_csharp_wrap_extends_list_style=chop_if_long +resharper_csharp_wrap_parameters_style=chop_if_long +resharper_css_insert_final_newline=false +resharper_enforce_line_ending_style=true +resharper_html_insert_final_newline=false +resharper_indent_nested_fixed_stmt=true +resharper_js_indent_style=tab +resharper_js_insert_final_newline=true +resharper_js_keep_blank_lines_in_code=1 +resharper_js_stick_comment=false +resharper_js_use_indent_from_vs=false +resharper_js_wrap_before_binary_opsign=true +resharper_js_wrap_chained_method_calls=chop_if_long +resharper_keep_blank_lines_between_declarations=1 +resharper_localizable_element_highlighting=none +resharper_min_blank_lines_after_imports=1 +resharper_place_attribute_on_same_line=false +resharper_place_constructor_initializer_on_same_line=false +resharper_place_type_constraints_on_same_line=false +resharper_protobuf_insert_final_newline=false +resharper_qualified_using_at_nested_scope=true +resharper_redundant_comma_in_attribute_list_highlighting=none +resharper_redundant_comma_in_enum_declaration_highlighting=none +resharper_redundant_comma_in_initializer_highlighting=none +resharper_resx_insert_final_newline=false +resharper_space_within_single_line_array_initializer_braces=true +resharper_string_compare_to_is_culture_specific_highlighting=none +resharper_string_index_of_is_culture_specific_1_highlighting=none +resharper_use_indents_from_main_language_in_file=false +resharper_use_null_propagation_highlighting=none +resharper_use_object_or_collection_initializer_highlighting=hint +resharper_use_string_interpolation_highlighting=hint +resharper_vb_insert_final_newline=false +resharper_wrap_after_declaration_lpar=true +resharper_wrap_after_invocation_lpar=true +resharper_wrap_before_extends_colon=true +resharper_wrap_before_first_type_parameter_constraint=true +resharper_wrap_before_type_parameter_langle=true +resharper_xml_insert_final_newline=false +resharper_xmldoc_indent_child_elements=ZeroIndent +resharper_xmldoc_indent_text=ZeroIndent +resharper_xmldoc_insert_final_newline=false +tab_width=4 +trim_trailing_whitespace=true -# Microsoft .NET properties -csharp_new_line_before_members_in_object_initializers = false -csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion -csharp_space_after_cast = false -csharp_style_var_elsewhere = false:hint -csharp_style_var_for_built_in_types = false:hint -csharp_style_var_when_type_is_apparent = true:hint -csharp_preserve_single_line_statements = false -csharp_preserve_single_line_blocks = true -dotnet_style_predefined_type_for_locals_parameters_members = true:hint -dotnet_style_predefined_type_for_member_access = true:hint -dotnet_style_qualification_for_event = true:hint -dotnet_style_qualification_for_field = true:hint -dotnet_style_qualification_for_method = true:hint -dotnet_style_qualification_for_property = true:hint -dotnet_style_require_accessibility_modifiers = for_non_interface_members:hint - -# ReSharper properties -resharper_alignment_tab_fill_style = optimal_fill -resharper_apply_on_completion = true -resharper_blank_lines_after_control_transfer_statements = 1 -resharper_blank_lines_around_single_line_auto_property = 1 -resharper_blank_lines_around_single_line_property = 1 -resharper_blank_lines_before_single_line_comment = 1 -resharper_blank_lines_between_using_groups = 1 -resharper_braces_for_for = required -resharper_braces_for_foreach = required -resharper_braces_for_ifelse = required -resharper_braces_for_while = required -resharper_can_use_global_alias = false -resharper_csharp_blank_lines_around_single_line_field = 1 -resharper_csharp_blank_lines_around_single_line_invocable = 1 -resharper_csharp_indent_style = tab -resharper_csharp_insert_final_newline = true -resharper_csharp_keep_blank_lines_in_code = 1 -resharper_csharp_keep_blank_lines_in_declarations = 1 -resharper_csharp_new_line_before_while = true -resharper_csharp_use_indent_from_vs = false -resharper_csharp_wrap_arguments_style = chop_if_long -resharper_csharp_wrap_extends_list_style = chop_if_long -resharper_csharp_wrap_parameters_style = chop_if_long -resharper_css_insert_final_newline = false -resharper_enforce_line_ending_style = true -resharper_html_insert_final_newline = false -resharper_indent_nested_fixed_stmt = true -resharper_js_indent_style = tab -resharper_js_insert_final_newline = true -resharper_js_keep_blank_lines_in_code = 1 -resharper_js_stick_comment = false -resharper_js_use_indent_from_vs = false -resharper_js_wrap_before_binary_opsign = true -resharper_js_wrap_chained_method_calls = chop_if_long -resharper_keep_blank_lines_between_declarations = 1 -resharper_min_blank_lines_after_imports = 1 -resharper_place_attribute_on_same_line = False -resharper_place_constructor_initializer_on_same_line = false -resharper_place_type_constraints_on_same_line = false -resharper_protobuf_insert_final_newline = false -resharper_qualified_using_at_nested_scope = true -resharper_resx_insert_final_newline = false -resharper_space_within_single_line_array_initializer_braces = true -resharper_use_indents_from_main_language_in_file = false -resharper_vb_insert_final_newline = false -resharper_wrap_after_declaration_lpar = true -resharper_wrap_after_invocation_lpar = true -resharper_wrap_before_extends_colon = true -resharper_wrap_before_first_type_parameter_constraint = true -resharper_wrap_before_type_parameter_langle = true -resharper_xmldoc_indent_child_elements = ZeroIndent -resharper_xmldoc_indent_text = ZeroIndent -resharper_xmldoc_insert_final_newline = false -resharper_xml_insert_final_newline = false - -# ReSharper inspection severities -resharper_check_namespace_highlighting = none -resharper_convert_to_auto_property_highlighting = none -resharper_localizable_element_highlighting = none -resharper_redundant_comma_in_attribute_list_highlighting = none -resharper_redundant_comma_in_enum_declaration_highlighting = none -resharper_redundant_comma_in_initializer_highlighting = none -resharper_string_compare_to_is_culture_specific_highlighting = none -resharper_string_index_of_is_culture_specific_1_highlighting = none -resharper_use_null_propagation_highlighting = none -resharper_use_object_or_collection_initializer_highlighting = hint -resharper_use_string_interpolation_highlighting = hint - -# Matches the exact files either package.json or .travis.yml -[{package.json,.travis.yml}] -indent_style = space -indent_size = 2 -tab_width = 2 - -[*.{cs,js,json,jsx,proto,resjson,ts,tsx}] -indent_style = space -indent_size = 4 -tab_width = 4 - -[*.{asax,ascx,aspx,cshtml,css,htm,html,master,razor,skin,vb,xaml,xamlx,xoml}] -indent_style = space -indent_size = 4 -tab_width = 4 +[*.md] +max_line_length=off +trim_trailing_whitespace=false [*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}] -indent_style = space -indent_size = 2 -tab_width = 2 +indent_size=2 +indent_style=space +tab_width=2 -[*.proto] -indent_style = space -indent_size = 2 -tab_width = 2 +[*.{diff,patch}] +end_of_line=unset +indent_size=unset +insert_final_newline=unset +trim_trailing_whitespace=unset + +[package.json] +indent_size=2 +indent_style=space +tab_width=2 + +[{LICENSES/**,LICENSE}] +charset=unset +end_of_line=unset +indent_size=unset +indent_style=unset +insert_final_newline=unset +trim_trailing_whitespace=unset diff --git a/.envrc b/.envrc index 5816063..8dfc6aa 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1 @@ -export PATH=$PWD/scripts:$PATH use flake || use nix diff --git a/.gitignore b/.gitignore index 53987a3..b56d553 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,8 @@ tests/artifacts/ # Lefthook .lefthook-local/ lefthook-local.yml + +# nixago: ignore-linked-files +/lefthook.yml +/.conform.yaml +/treefmt.toml \ No newline at end of file diff --git a/flake.lock b/flake.lock index 9016b99..7000b2a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,15 +1,136 @@ { "nodes": { - "flake-utils": { + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "crane": { "inputs": { - "systems": "systems" + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ], + "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1687709756, - "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "lastModified": 1676162383, + "narHash": "sha256-krUCKdz7ebHlFYm/A7IbKDnj2ZmMMm3yIEQcooqm7+E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6fb400ec631b22ccdbc7090b38207f7fb5cfb5f2", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": [ + "std", + "flake-utils" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1682700442, + "narHash": "sha256-qjaAAcCYgp1pBBG7mY9z95ODUBZMtUpf0Qp3Gt/Wha0=", + "owner": "numtide", + "repo": "devshell", + "rev": "fb6673fe9fe4409e3f43ca86968261e970918a83", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "haumea": "haumea", + "nixlib": "nixlib", + "yants": [ + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1686862774, + "narHash": "sha256-ojGtRQ9pIOUrxsQEuEPerUkqIJEuod9hIflfNkY+9CE=", + "owner": "divnix", + "repo": "dmerge", + "rev": "9f7f7a8349d33d7bd02e0f2b484b1f076e503a96", + "type": "github" + }, + "original": { + "owner": "divnix", + "ref": "0.2.1", + "repo": "dmerge", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs_2", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1677306201, + "narHash": "sha256-VZ9x7qdTosFvVsrpgFHrtYfT6PU3yMIs7NRYn9ELapI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "0923f0c162f65ae40261ec940406049726cfeab4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "owner": "numtide", "repo": "flake-utils", - "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "type": "github" }, "original": { @@ -18,6 +139,135 @@ "type": "github" } }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "haumea": { + "inputs": { + "nixpkgs": [ + "std", + "dmerge", + "nixlib" + ] + }, + "locked": { + "lastModified": 1685133229, + "narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=", + "owner": "nix-community", + "repo": "haumea", + "rev": "34dd58385092a23018748b50f9b23de6266dffc2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "v0.2.2", + "repo": "haumea", + "type": "github" + } + }, + "incl": { + "inputs": { + "nixlib": [ + "std", + "dmerge", + "nixlib" + ] + }, + "locked": { + "lastModified": 1669263024, + "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=", + "owner": "divnix", + "repo": "incl", + "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", + "type": "github" + } + }, + "n2c": { + "inputs": { + "flake-utils": [ + "std", + "flake-utils" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1685771919, + "narHash": "sha256-3lVKWrhNXjHJB6QkZ2SJaOs4X/mmYXtY6ovPVpDMOHc=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "95e2220911874064b5d809f8d35f7835184c4ddf", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "nixago": { + "inputs": { + "flake-utils": [ + "std", + "flake-utils" + ], + "nixago-exts": [ + "std", + "blank" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1683210100, + "narHash": "sha256-bhGDOlkWtlhVECpoOog4fWiFJmLCpVEg09a40aTjCbw=", + "owner": "nix-community", + "repo": "nixago", + "rev": "1da60ad9412135f9ed7a004669fdcf3d378ec630", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixago", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1681001314, + "narHash": "sha256-5sDnCLdrKZqxLPK4KA8+f4A3YKO/u6ElpMILvX0g72c=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "367c0e1086a4eb4502b24d872cea2c7acdd557f4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1688590700, @@ -33,24 +283,253 @@ "type": "indirect" } }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { + "nixpkgs_2": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1677063315, + "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nosys": { + "locked": { + "lastModified": 1668010795, + "narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=", + "owner": "divnix", + "repo": "nosys", + "rev": "feade0141487801c71ff55623b421ed535dbdefa", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "nosys", + "type": "github" + } + }, + "paisano": { + "inputs": { + "nixpkgs": [ + "std", + "nixpkgs" + ], + "nosys": "nosys", + "yants": [ + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1686862844, + "narHash": "sha256-m8l/HpRBJnZ3c0F1u0IyQ3nYGWE0R9V5kfORuqZPzgk=", + "owner": "paisano-nix", + "repo": "core", + "rev": "6674b3d3577212c1eeecd30d62d52edbd000e726", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "core", + "type": "github" + } + }, + "paisano-actions": { + "inputs": { + "nixpkgs": [ + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677306424, + "narHash": "sha256-H9/dI2rGEbKo4KEisqbRPHFG2ajF8Tm111NPdKGIf28=", + "owner": "paisano-nix", + "repo": "actions", + "rev": "65ec4e080b3480167fc1a748c89a05901eea9a9b", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "actions", + "type": "github" + } + }, + "paisano-mdbook-preprocessor": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "nixpkgs": [ + "std", + "nixpkgs" + ], + "paisano-actions": "paisano-actions", + "std": [ + "std" + ] + }, + "locked": { + "lastModified": 1680654400, + "narHash": "sha256-Qdpio+ldhUK3zfl22Mhf8HUULdUOJXDWDdO7MIK69OU=", + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "rev": "11a8fc47f574f194a7ae7b8b98001f6143ba4cf1", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "type": "github" + } + }, + "paisano-tui": { + "inputs": { + "nixpkgs": [ + "std", + "blank" + ], + "std": [ + "std" + ] + }, + "locked": { + "lastModified": 1681847764, + "narHash": "sha256-mdd7PJW1BZvxy0cIKsPfAO+ohVl/V7heE5ZTAHzTdv8=", + "owner": "paisano-nix", + "repo": "tui", + "rev": "3096bad91cae73ab8ab3367d31f8a143d248a244", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "tui", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "std": "std" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1677221702, + "narHash": "sha256-1M+58rC4eTCWNmmX0hQVZP20t3tfYNunl9D/PrGUyGE=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f5401f620699b26ed9d47a1d2e838143a18dbe3b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "std", + "paisano-mdbook-preprocessor", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "std", + "paisano-mdbook-preprocessor", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "std": { + "inputs": { + "arion": [ + "std", + "blank" + ], + "blank": "blank", + "devshell": "devshell", + "dmerge": "dmerge", + "flake-utils": "flake-utils", + "incl": "incl", + "makes": [ + "std", + "blank" + ], + "microvm": [ + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": [ + "nixpkgs" + ], + "paisano": "paisano", + "paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor", + "paisano-tui": "paisano-tui", + "yants": "yants" + }, + "locked": { + "lastModified": 1686877329, + "narHash": "sha256-A/SU8KqlLP2MBuhi9wmt6gDhXyp+chCeDZ4OBxfSWBI=", + "owner": "divnix", + "repo": "std", + "rev": "aa6d423b82b7b7c2a4545693dea9ed1db14676e7", + "type": "github" + }, + "original": { + "owner": "divnix", + "ref": "v0.23.2", + "repo": "std", + "type": "github" + } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "std", + "dmerge", + "nixlib" + ] + }, + "locked": { + "lastModified": 1686863218, + "narHash": "sha256-kooxYm3/3ornWtVBNHM3Zh020gACUyFX2G0VQXnB+mk=", + "owner": "divnix", + "repo": "yants", + "rev": "8f0da0dba57149676aa4817ec0c880fbde7a648d", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", "type": "github" } } diff --git a/flake.nix b/flake.nix index 87ba515..5b47c7e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,18 +1,26 @@ { - description = "A .NET core library for easily building CLI tools"; + description = "A variety of .NET core libraries used for development"; inputs = { + std.url = "github:divnix/std/v0.23.2"; + std.inputs.nixpkgs.follows = "nixpkgs"; nixpkgs.url = "nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in { - devShell = pkgs.mkShell { - buildInputs = - [ pkgs.dotnet-sdk pkgs.lefthook pkgs.convco pkgs.nixfmt pkgs.jq pkgs.just ]; - }; - }); + outputs = inputs @ { + self, + std, + ... + }: + std.growOn { + inherit inputs; + systems = ["x86_64-linux"]; + cellsFrom = ./nix; + cellBlocks = with std.blockTypes; [ + (devshells "shells") + (nixago "configs") + ]; + } { + devShells = std.harvest self ["common" "shells"]; + }; } diff --git a/lefthook.yml b/lefthook.yml deleted file mode 100644 index 37c8be8..0000000 --- a/lefthook.yml +++ /dev/null @@ -1,17 +0,0 @@ -pre-commit: - parallel: true - commands: - nixfmt: - run: nixfmt flake.nix - -commit-msg: - commands: - commit-check: - run: convco check -n 1 - -skip_output: - - meta # Skips lefthook version printing - - summary # Skips summary block (successful and failed steps) printing - - success # Skips successful steps printing - - failure # Skips failed steps printing - - execution # Skips printing successfully executed commands and their output (but still prints failed executions) diff --git a/nix/common/configs.nix b/nix/common/configs.nix new file mode 100644 index 0000000..d26fdea --- /dev/null +++ b/nix/common/configs.nix @@ -0,0 +1,255 @@ +{ + inputs, + cell, +}: let + inherit (inputs) nixpkgs; + inherit (inputs.cells) std presets; + l = nixpkgs.lib // builtins; +in { + conform = { + data = { + commit = { + header = {length = 89;}; + conventional = { + # Only allow these types of conventional commits (inspired by Angular) + types = [ + "build" + "chore" + "ci" + "docs" + "feat" + "fix" + "perf" + "refactor" + "style" + "test" + ]; + }; + }; + }; + }; + + editorconfig = { + hook.mode = "copy"; # already useful before entering the devshell + data = { + root = true; + + "*" = { + # Common + end_of_line = "lf"; + insert_final_newline = true; + trim_trailing_whitespace = true; + charset = "utf-8"; + indent_style = "space"; + indent_size = 4; + indent_brace_style = "K&R"; + max_line_length = 80; + tab_width = 4; + curly_bracket_next_line = true; + + # Microsoft .NET properties + "csharp_new_line_before_members_in_object_initializers" = false; + "csharp_preferred_modifier_order" = "public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion"; + "csharp_space_after_cast" = false; + "csharp_style_var_elsewhere" = "false:hint"; + "csharp_style_var_for_built_in_types" = "false:hint"; + "csharp_style_var_when_type_is_apparent" = "true:hint"; + "csharp_preserve_single_line_statements" = false; + "csharp_preserve_single_line_blocks" = true; + "dotnet_style_predefined_type_for_locals_parameters_members" = "true:hint"; + "dotnet_style_predefined_type_for_member_access" = "true:hint"; + "dotnet_style_qualification_for_event" = "true:hint"; + "dotnet_style_qualification_for_field" = "true:hint"; + "dotnet_style_qualification_for_method" = "true:hint"; + "dotnet_style_qualification_for_property" = "true:hint"; + "dotnet_style_require_accessibility_modifiers" = "for_non_interface_members:hint"; + + # ReSharper properties + "resharper_alignment_tab_fill_style" = "optimal_fill"; + "resharper_apply_on_completion" = true; + "resharper_blank_lines_after_control_transfer_statements" = 1; + "resharper_blank_lines_around_single_line_auto_property" = 1; + "resharper_blank_lines_around_single_line_property" = 1; + "resharper_blank_lines_before_single_line_comment" = 1; + "resharper_blank_lines_between_using_groups" = 1; + "resharper_braces_for_for" = "required"; + "resharper_braces_for_foreach" = "required"; + "resharper_braces_for_ifelse" = "required"; + "resharper_braces_for_while" = "required"; + "resharper_can_use_global_alias" = false; + "resharper_csharp_blank_lines_around_single_line_field" = 1; + "resharper_csharp_blank_lines_around_single_line_invocable" = 1; + "resharper_csharp_indent_style" = "tab"; + "resharper_csharp_insert_final_newline" = true; + "resharper_csharp_keep_blank_lines_in_code" = 1; + "resharper_csharp_keep_blank_lines_in_declarations" = 1; + "resharper_csharp_new_line_before_while" = true; + "resharper_csharp_use_indent_from_vs" = false; + "resharper_csharp_wrap_arguments_style" = "chop_if_long"; + "resharper_csharp_wrap_extends_list_style" = "chop_if_long"; + "resharper_csharp_wrap_parameters_style" = "chop_if_long"; + "resharper_css_insert_final_newline" = false; + "resharper_enforce_line_ending_style" = true; + "resharper_html_insert_final_newline" = false; + "resharper_indent_nested_fixed_stmt" = true; + "resharper_js_indent_style" = "tab"; + "resharper_js_insert_final_newline" = true; + "resharper_js_keep_blank_lines_in_code" = 1; + "resharper_js_stick_comment" = false; + "resharper_js_use_indent_from_vs" = false; + "resharper_js_wrap_before_binary_opsign" = true; + "resharper_js_wrap_chained_method_calls" = "chop_if_long"; + "resharper_keep_blank_lines_between_declarations" = 1; + "resharper_min_blank_lines_after_imports" = 1; + "resharper_place_attribute_on_same_line" = false; + "resharper_place_constructor_initializer_on_same_line" = false; + "resharper_place_type_constraints_on_same_line" = false; + "resharper_protobuf_insert_final_newline" = false; + "resharper_qualified_using_at_nested_scope" = true; + "resharper_resx_insert_final_newline" = false; + "resharper_space_within_single_line_array_initializer_braces" = true; + "resharper_use_indents_from_main_language_in_file" = false; + "resharper_vb_insert_final_newline" = false; + "resharper_wrap_after_declaration_lpar" = true; + "resharper_wrap_after_invocation_lpar" = true; + "resharper_wrap_before_extends_colon" = true; + "resharper_wrap_before_first_type_parameter_constraint" = true; + "resharper_wrap_before_type_parameter_langle" = true; + "resharper_xmldoc_indent_child_elements" = "ZeroIndent"; + "resharper_xmldoc_indent_text" = "ZeroIndent"; + "resharper_xmldoc_insert_final_newline" = false; + "resharper_xml_insert_final_newline" = false; + + # ReSharper inspection severities + "resharper_check_namespace_highlighting" = "none"; + "resharper_convert_to_auto_property_highlighting" = "none"; + "resharper_localizable_element_highlighting" = "none"; + "resharper_redundant_comma_in_attribute_list_highlighting" = "none"; + "resharper_redundant_comma_in_enum_declaration_highlighting" = "none"; + "resharper_redundant_comma_in_initializer_highlighting" = "none"; + "resharper_string_compare_to_is_culture_specific_highlighting" = "none"; + "resharper_string_index_of_is_culture_specific_1_highlighting" = "none"; + "resharper_use_null_propagation_highlighting" = "none"; + "resharper_use_object_or_collection_initializer_highlighting" = "hint"; + "resharper_use_string_interpolation_highlighting" = "hint"; + }; + + "*.{diff,patch}" = { + end_of_line = "unset"; + insert_final_newline = "unset"; + trim_trailing_whitespace = "unset"; + indent_size = "unset"; + }; + + "*.md" = { + max_line_length = "off"; + trim_trailing_whitespace = false; + }; + + "package.json" = { + indent_style = "space"; + indent_size = 2; + tab_width = 2; + }; + + "*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}" = { + indent_style = "space"; + indent_size = 2; + tab_width = 2; + }; + + "{LICENSES/**,LICENSE}" = { + end_of_line = "unset"; + insert_final_newline = "unset"; + trim_trailing_whitespace = "unset"; + charset = "unset"; + indent_style = "unset"; + indent_size = "unset"; + }; + }; + }; + + lefthook = { + data = { + commit-msg = { + commands = { + # Runs conform on commit-msg hook to ensure commit messages are + # compliant. + conform = { + run = "${nixpkgs.conform}/bin/conform enforce --commit-msg-file {1}"; + }; + }; + }; + pre-commit = { + commands = { + # Runs treefmt on pre-commit hook to ensure checked-in source code is + # properly formatted. + treefmt = { + run = "${nixpkgs.treefmt}/bin/treefmt {staged_files}"; + }; + }; + }; + }; + }; + + prettier = { + data = { + printWidth = 80; + proseWrap = "always"; + }; + output = ".prettierrc"; + format = "json"; + }; + + treefmt = { + data = { + formatter = { + nix = { + command = "alejandra"; + includes = ["*.nix" "*.nix.hbs"]; + }; + + prettier = { + command = "prettier"; + options = ["--plugin" "prettier-plugin-toml" "--write"]; + includes = [ + "*.css" + "*.html" + "*.js" + "*.json" + "*.jsx" + "*.md" + "*.mdx" + "*.scss" + "*.ts" + "*.yaml" + "*.toml" + ]; + }; + + shell = { + command = "shfmt"; + options = ["-i" "4" "-s" "-w"]; + includes = ["*.sh"]; + }; + + # We mainly use it here to format the Markdown in our README. + prettier = { + excludes = ["**.min.js"]; + }; + }; + }; + + packages = [ + nixpkgs.alejandra + nixpkgs.nodePackages.prettier + nixpkgs.nodePackages.prettier-plugin-toml + nixpkgs.shfmt + nixpkgs.go + ]; + + devshell.startup.prettier-plugin-toml = l.stringsWithDeps.noDepEntry '' + export NODE_PATH=${nixpkgs.nodePackages.prettier-plugin-toml}/lib/node_modules:$NODE_PATH + ''; + }; +} diff --git a/nix/common/shells.nix b/nix/common/shells.nix new file mode 100644 index 0000000..4235dd1 --- /dev/null +++ b/nix/common/shells.nix @@ -0,0 +1,38 @@ +{ + inputs, + cell, +}: let + inherit (inputs.std) std lib; + inherit (inputs) nixpkgs; + inherit (inputs.cells) cli; + + l = nixpkgs.lib // builtins; + + dev = lib.dev.mkShell { + packages = [ + # Building + nixpkgs.just + nixpkgs.lefthook + + # .NET + nixpkgs.dotnet-sdk + + # Nix + nixpkgs.nixfmt + nixpkgs.alejandra + + # Git + nixpkgs.git + ]; + + nixago = [ + (lib.cfg.conform cell.configs.conform) + (lib.cfg.treefmt cell.configs.treefmt) + (lib.cfg.editorconfig cell.configs.editorconfig) + (lib.cfg.lefthook cell.configs.lefthook) + ]; + }; +in { + inherit dev; + default = dev; +} diff --git a/scripts/release.sh b/scripts/release.sh index 94ed900..698a0af 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -4,8 +4,7 @@ cd $(dirname $0)/.. ./scripts/setup.sh || exit 1 # Verify the input. -if [ "x$GITEA_TOKEN" = "x" ] -then +if [ "x$GITEA_TOKEN" = "x" ]; then echo "the environment variable GITEA_TOKEN is not defined" exit 1 fi @@ -19,10 +18,9 @@ echo "$(basename $0): setting project version" (cd src && dotnet dotnet-gitversion /updateprojectfiles) SEMVER="v$(dotnet gitversion /output json | jq -r .SemVer)" -if [ "x$SEMVER" = "x" ] -then - echo "$(basename $0): cannot figure out the semantic version" - exit 1 +if [ "x$SEMVER" = "x" ]; then + echo "$(basename $0): cannot figure out the semantic version" + exit 1 fi # Build to pick up the new version. @@ -34,18 +32,17 @@ echo "$(basename $0): creating NuGet packages" dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg || exit 1 echo "$(basename $0): publishing NuGet package" -dotnet nuget remove source mfgames.com >& /dev/null +dotnet nuget remove source mfgames.com >&/dev/null dotnet nuget add source --name mfgames.com --username dmoonfire --password $GITEA_TOKEN https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json --store-password-in-clear-text || exit 1 dotnet nuget push --skip-duplicate --source mfgames.com src/*/bin/Debug/*.nupkg || exit 1 # Tag and push, but only if we don't have a tag. -if ! git tag | grep $SEMVER >& /dev/null -then - echo "$(basename $0): tagging and pushing" - git remote add publish https://dmoonfire:$GITEA_TOKEN@src.mfgames.com/mfgames-cil/$(basename $(git config --get remote.origin.url)) - git tag $SEMVER - git push publish $SEMVER || exit 1 - git remote remove publish +if ! git tag | grep $SEMVER >&/dev/null; then + echo "$(basename $0): tagging and pushing" + git remote add publish https://dmoonfire:$GITEA_TOKEN@src.mfgames.com/mfgames-cil/$(basename $(git config --get remote.origin.url)) + git tag $SEMVER + git push publish $SEMVER || exit 1 + git remote remove publish else - echo "$(basename $0): not tagging, already exists" + echo "$(basename $0): not tagging, already exists" fi