68 lines
1.9 KiB
Nix
68 lines
1.9 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
fenix.url = "github:nix-community/fenix";
|
|
fenix.inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, fenix }:
|
|
let
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
|
|
toolchain = fenix.packages.${system}.complete;
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [
|
|
(_: super: let pkgs = fenix.inputs.nixpkgs.legacyPackages.${system}; in fenix.overlays.default pkgs pkgs)
|
|
];
|
|
};
|
|
in f system pkgs toolchain);
|
|
in {
|
|
apps = forAllSystems (system: pkgs: _: let
|
|
mkApp = program: {
|
|
type = "app";
|
|
program = "${pkgs.lib.getExe program}";
|
|
};
|
|
in {
|
|
default = mkApp self.packages.${system}.default;
|
|
});
|
|
|
|
devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell {
|
|
packages = [
|
|
(toolchain.withComponents [
|
|
"cargo" "rustc" "rustfmt" "clippy"
|
|
])
|
|
];
|
|
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/";
|
|
});
|
|
|
|
overlays.default = final: prev: self.packages.${prev.system};
|
|
|
|
packages = (forAllSystems (system: pkgs: _: {
|
|
default = let
|
|
cargo-toml = pkgs.lib.importTOML ./Cargo.toml;
|
|
in pkgs.rustPlatform.buildRustPackage rec {
|
|
pname = cargo-toml.package.name;
|
|
version = cargo-toml.package.version;
|
|
src = ./.;
|
|
|
|
cargoSha256 = "sha256-ykcbKz8NnSw1uP8ajBVr/PGZKrDJvjFKpaFOyKoEGTc=";
|
|
|
|
meta = with pkgs.lib; {
|
|
description = cargo-toml.package.description;
|
|
homepage = cargo-toml.package.repository;
|
|
license = licenses.mit;
|
|
platforms = systems;
|
|
mainProgram = (pkgs.lib.head cargo-toml.bin).name;
|
|
};
|
|
};
|
|
}));
|
|
};
|
|
}
|
|
|