From 6690e658148d695e963d9a61c8734a91906c216d Mon Sep 17 00:00:00 2001 From: Warren Hood Date: Thu, 19 Sep 2024 23:43:03 +0200 Subject: [PATCH] Added back working nix flake --- .config/hakari.toml | 24 ++++++++ Cargo.toml | 7 +++ deny.toml | 6 ++ flake.lock | 116 ++++++++++++++++++++++++++++++++++++++ flake.nix | 134 ++++++++++++++++++++++++++++++++++++++++++++ taplo.toml | 13 +++++ 6 files changed, 300 insertions(+) create mode 100644 .config/hakari.toml create mode 100644 deny.toml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 taplo.toml diff --git a/.config/hakari.toml b/.config/hakari.toml new file mode 100644 index 0000000..c391f64 --- /dev/null +++ b/.config/hakari.toml @@ -0,0 +1,24 @@ +# This file contains settings for `cargo hakari`. +# See https://docs.rs/cargo-hakari/latest/cargo_hakari/config for a full list of options. + +hakari-package = "mcmpmgr-workspace" + +# Format version for hakari's output. Version 4 requires cargo-hakari 0.9.22 or above. +dep-format-version = "4" + +# Setting workspace.resolver = "2" in the root Cargo.toml is HIGHLY recommended. +# Hakari works much better with the new feature resolver. +# For more about the new feature resolver, see: +# https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver +resolver = "2" + +# Add triples corresponding to platforms commonly used by developers here. +# https://doc.rust-lang.org/rustc/platform-support.html +platforms = [ + # "x86_64-unknown-linux-gnu", + # "x86_64-apple-darwin", + # "x86_64-pc-windows-msvc", +] + +# Write out exact versions rather than a semver range. (Defaults to false.) +# exact-versions = true diff --git a/Cargo.toml b/Cargo.toml index 3634289..2d7aeef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,10 @@ [workspace] resolver = "2" members = ["mcmpmgr", "mmm"] + +[workspace.package] +version = "0.1.0" +edition = "2021" + +[workspace.metadata.crane] +name = "mcmpmgr-workspace" diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..31accdf --- /dev/null +++ b/deny.toml @@ -0,0 +1,6 @@ +[bans] +multiple-versions = 'allow' + +[licenses] +private = { ignore = true } +allow = ["Apache-2.0", "BSD-3-Clause", "MIT", "Unicode-DFS-2016"] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6b16ef9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,116 @@ +{ + "nodes": { + "advisory-db": { + "flake": false, + "locked": { + "lastModified": 1726496182, + "narHash": "sha256-V5193OeAuy0smfeOF2omeJXk+kq+tlEzcpk2MrUpai0=", + "owner": "rustsec", + "repo": "advisory-db", + "rev": "3cae2352cf82b5815b98aa309e0f4df6aa737cec", + "type": "github" + }, + "original": { + "owner": "rustsec", + "repo": "advisory-db", + "type": "github" + } + }, + "crane": { + "locked": { + "lastModified": 1725409566, + "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": [] + }, + "locked": { + "lastModified": 1726727555, + "narHash": "sha256-WAYoFXry7bU3UXCFklX6tBOfBdZUHi+MeIk1JxUKNEo=", + "owner": "nix-community", + "repo": "fenix", + "rev": "3b974166133158907839fe20147e11696fade644", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1726583932, + "narHash": "sha256-zACxiQx8knB3F8+Ze+1BpiYrI+CbhxyWpcSID9kVhkQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "658e7223191d2598641d50ee4e898126768fe847", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "advisory-db": "advisory-db", + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..91a329c --- /dev/null +++ b/flake.nix @@ -0,0 +1,134 @@ +{ + description = "mcmpmgr - A minecraft modpack manager"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + crane.url = "github:ipetkov/crane"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.rust-analyzer-src.follows = ""; + }; + + flake-utils.url = "github:numtide/flake-utils"; + + advisory-db = { + url = "github:rustsec/advisory-db"; flake = false; }; + }; + + outputs = { self, nixpkgs, crane, fenix, flake-utils, advisory-db, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + inherit (pkgs) lib; + + craneLib = crane.mkLib pkgs; + src = craneLib.cleanCargoSource ./.; + + # Common arguments can be set here to avoid repeating them later + commonArgs = { + inherit src; + strictDeps = true; + + buildInputs = [ + pkgs.openssl + ] ++ lib.optionals pkgs.stdenv.isDarwin [ + # Additional darwin specific inputs can be set here + pkgs.libiconv + ]; + + nativeBuildInputs = [ + pkgs.pkg-config + ]; + + # Additional environment variables can be set directly + # MY_CUSTOM_VAR = "some value"; + }; + + craneLibLLvmTools = craneLib.overrideToolchain + (fenix.packages.${system}.complete.withComponents [ + "cargo" + "llvm-tools" + "rustc" + ]); + + # Build *just* the cargo dependencies (of the entire workspace), + # so we can reuse all of that work (e.g. via cachix) when running in CI + # It is *highly* recommended to use something like cargo-hakari to avoid + # cache misses when building individual top-level-crates + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + + individualCrateArgs = commonArgs // { + inherit cargoArtifacts; + inherit (craneLib.crateNameFromCargoToml { inherit src; }) version; + # NB: we disable tests since we'll run them all via cargo-nextest + doCheck = false; + }; + + fileSetForCrate = crate: lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./Cargo.toml + ./Cargo.lock + crate + ]; + }; + + # Build the top-level crates of the workspace as individual derivations. + # This allows consumers to only depend on (and build) only what they need. + # Though it is possible to build the entire workspace as a single derivation, + # so this is left up to you on how to organize things + mcmpmgr = craneLib.buildPackage (individualCrateArgs // { + pname = "mcmpmgr"; + cargoExtraArgs = "-p mcmpmgr"; + src = craneLib.cleanCargoSource ./.; + }); + mmm = craneLib.buildPackage (individualCrateArgs // { + pname = "mmm"; + cargoExtraArgs = "-p mmm"; + src = craneLib.cleanCargoSource ./.; + }); + in + { + checks = {}; + + packages = { + inherit mcmpmgr; + inherit mmm; + default = mcmpmgr; + } // lib.optionalAttrs (!pkgs.stdenv.isDarwin) { + mcmpmgr-workspace-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // { + inherit cargoArtifacts; + }); + }; + + + apps = { + mcmpmgr = flake-utils.lib.mkApp { + drv = mcmpmgr; + }; + mmm = flake-utils.lib.mkApp { + drv = mmm; + }; + }; + + + devShells.default = craneLib.devShell { + # Inherit inputs from checks. + checks = self.checks.${system}; + + # Additional dev-shell environment variables can be set directly + # MY_CUSTOM_DEVELOPMENT_VAR = "something else"; + + # Extra inputs can be added here; cargo and rustc are provided by default. + packages = [ + pkgs.cargo-hakari + pkgs.nil + pkgs.rust-analyzer + ]; + }; + }); +} diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 0000000..e832af1 --- /dev/null +++ b/taplo.toml @@ -0,0 +1,13 @@ +# Sorts `Cargo.toml` dependencies. All other `.toml` files are formatted with the default config. +# +# https://taplo.tamasfe.dev/configuration/file.html#configuration-file + +[formatting] +reorder_keys = false + +[[rule]] +include = ["**/Cargo.toml"] +keys = ["dependencies"] + +[rule.formatting] +reorder_keys = true