Silly NuShell plugin to read Minecraft NBT
at main 78 lines 2.2 kB view raw
1{ 2 inputs = { 3 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 4 flakelight.url = "github:nix-community/flakelight"; 5 flakelight.inputs.nixpkgs.follows = "nixpkgs"; 6 crane.url = "github:ipetkov/crane"; 7 fenix.url = "github:nix-community/fenix"; 8 }; 9 outputs = { 10 self, 11 nixpkgs, 12 flakelight, 13 crane, 14 fenix, 15 ... 16 } @ inputs: let 17 selectToolchain = fenix: fenix.default; 18 mkCrane = pkgs: let 19 inherit (selectToolchain pkgs.fenix) toolchain; 20 craneLib = (crane.mkLib nixpkgs.legacyPackages.${pkgs.system}).overrideToolchain toolchain; 21 rawSrc = ./.; 22 src = craneLib.cleanCargoSource rawSrc; 23 commonArgs = { 24 inherit src; 25 strictDeps = true; 26 cargoArtifacts = craneLib.buildDepsOnly commonArgs; 27 }; 28 crate = craneLib.buildPackage ( 29 commonArgs 30 // { 31 inherit (craneLib.crateNameFromCargoToml {inherit src;}) version; 32 doCheck = false; 33 } 34 ); 35 in { 36 inherit crate craneLib commonArgs; 37 }; 38 in 39 flakelight ./. { 40 inherit inputs; 41 pname = "nu_plugin_nbt"; 42 nixpkgs.overlays = [fenix.overlays.default]; 43 package = pkgs: (mkCrane pkgs).crate; 44 formatters = pkgs: let 45 alejandra = "${pkgs.lib.getExe pkgs.alejandra} ."; 46 rustfmt = "${(selectToolchain pkgs.fenix).rustfmt}/bin/rustfmt ."; 47 taplo = "${pkgs.lib.getExe pkgs.taplo} fmt ."; 48 in { 49 "*.nix" = alejandra; 50 "*.rs" = rustfmt; 51 "*.toml" = taplo; 52 }; 53 checks = pkgs: let 54 inherit (mkCrane pkgs) craneLib commonArgs; 55 in { 56 clippy = craneLib.cargoClippy ( 57 commonArgs 58 // { 59 cargoClippyExtraArgs = "--all-targets -- --deny warnings"; 60 } 61 ); 62 test = craneLib.cargoNextest ( 63 commonArgs 64 // { 65 partitions = 1; 66 partitionType = "count"; 67 cargoNextestPartitionsExtraArgs = "--no-tests=pass"; 68 } 69 ); 70 }; 71 devShell = pkgs: 72 (mkCrane pkgs).craneLib.devShell { 73 checks = self.checks.${pkgs.system}; 74 75 packages = with pkgs; [cargo-nextest]; 76 }; 77 }; 78}