/ flake.nix
flake.nix
1 { 2 description = "rust"; 3 inputs = { 4 flake-utils.url = "github:numtide/flake-utils"; 5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 6 }; 7 8 outputs = { self, nixpkgs, flake-utils }: 9 flake-utils.lib.eachDefaultSystem 10 (system: 11 let 12 pkgs = nixpkgs.legacyPackages.${system}; 13 manifest = (nixpkgs.lib.importTOML ./Cargo.toml).package; 14 in 15 { 16 packages.default = pkgs.rustPlatform.buildRustPackage rec { 17 name = manifest.name; 18 version = manifest.version; 19 src = ./.; 20 cargoLock.lockFile = "${src}/Cargo.lock"; 21 nativeBuildInputs = with pkgs; [ openssl pkg-config ]; 22 PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; 23 }; 24 apps."${manifest.name}"= { 25 type = "app"; 26 program = "${self.packages.${system}.default}/bin/${manifest.name}"; 27 meta.description = "${manifest.description}"; 28 meta.license = "${manifest.license}"; 29 }; 30 devShells.default = pkgs.mkShell { 31 inputsFrom = [self.packages.${system}.default]; 32 nativeBuildInputs = with pkgs; [ bacon rust-analyzer rustfmt clippy ]; 33 }; 34 } 35 ); 36 }