The world's most clever kitty cat
at main 126 lines 3.6 kB view raw
1{ 2 description = "Bingus Bot"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 6 flakelight.url = "github:nix-community/flakelight"; 7 flakelight.inputs.nixpkgs.follows = "nixpkgs"; 8 flakelight-treefmt.url = "github:m15a/flakelight-treefmt"; 9 flakelight-treefmt.inputs.flakelight.follows = "flakelight"; 10 fenix.url = "github:nix-community/fenix"; 11 fenix.inputs.nixpkgs.follows = "nixpkgs"; 12 crane.url = "github:ipetkov/crane"; 13 advisory-db = { 14 url = "github:rustsec/advisory-db"; 15 flake = false; 16 }; 17 }; 18 19 outputs = inputs @ { 20 self, 21 nixpkgs, 22 flakelight, 23 flakelight-treefmt, 24 fenix, 25 crane, 26 advisory-db, 27 }: 28 flakelight ./. ( 29 let 30 selectToolchain = pkgs: pkgs.fenix.complete; 31 mkCrane = pkgs: (crane.mkLib pkgs).overrideToolchain (selectToolchain pkgs).toolchain; 32 mkCraneStuff = pkgs: let 33 craneLib = mkCrane pkgs; 34 commonArgs = { 35 src = craneLib.cleanCargoSource ./.; 36 strictDeps = true; 37 }; 38 cargoArtifacts = craneLib.buildDepsOnly commonArgs; 39 in { 40 inherit 41 commonArgs 42 craneLib 43 cargoArtifacts 44 ; 45 }; 46 in { 47 inherit inputs; 48 imports = [flakelight-treefmt.flakelightModules.default]; 49 withOverlays = [inputs.fenix.overlays.default]; 50 pname = "bingus"; 51 treefmtConfig = {pkgs, ...}: { 52 programs = { 53 alejandra.enable = true; 54 taplo.enable = true; 55 rustfmt = { 56 enable = true; 57 package = (selectToolchain pkgs).rustfmt; 58 }; 59 }; 60 }; 61 devShell = pkgs: 62 (mkCrane pkgs).devShell { 63 buildInputs = with pkgs; [ 64 cargo-nextest 65 ]; 66 }; 67 nixosModule = { 68 lib, 69 pkgs, 70 ... 71 }: { 72 imports = [./nixosModule.nix]; 73 74 services.bingus-bot.package = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default; 75 }; 76 package = { 77 rustPlatform, 78 lib, 79 pkgs, 80 }: let 81 inherit (mkCraneStuff pkgs) craneLib commonArgs cargoArtifacts; 82 in 83 craneLib.buildPackage ( 84 commonArgs 85 // { 86 inherit cargoArtifacts; 87 doCheck = false; 88 89 meta = with lib; { 90 mainProgram = "bingus-bot"; 91 description = "A very clever kitty"; 92 license = licenses.gpl3; 93 homepage = "https://tangled.org/bwc9876.dev/bingus-bot"; 94 maintainers = with maintainers; [ 95 bwc9876 96 ]; 97 }; 98 } 99 ); 100 checks = pkgs: let 101 inherit (mkCraneStuff pkgs) craneLib commonArgs cargoArtifacts; 102 in { 103 bingus-clippy = craneLib.cargoClippy ( 104 commonArgs 105 // { 106 inherit cargoArtifacts; 107 cargoClippyExtraArgs = "--all-targets -- --deny warnings"; 108 } 109 ); 110 bingus-audit = craneLib.cargoAudit { 111 inherit (commonArgs) src; 112 inherit advisory-db; 113 }; 114 bingus-nextest = craneLib.cargoNextest ( 115 commonArgs 116 // { 117 inherit cargoArtifacts; 118 partitions = 1; 119 partitionType = "count"; 120 cargoNextestPartitionsExtraArgs = "--no-tests=pass"; 121 } 122 ); 123 }; 124 } 125 ); 126}