Files
kagami/flake.nix
T
2026-04-25 19:29:13 +09:00

78 lines
1.9 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
};
outputs = { self, nixpkgs, rust-overlay, crane }:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = f: lib.genAttrs systems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
];
};
rust-bin = rust-overlay.lib.mkRustBin { } pkgs.buildPackages;
toolchain = rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" "rust-std" ];
};
in f system pkgs toolchain);
in {
apps = forAllSystems (system: _: _: {
default = self.apps.${system}.kagami;
kagami = {
type = "app";
program = lib.getExe self.packages.${system}.kagami;
};
});
packages = forAllSystems (system: pkgs: _: {
default = self.packages.${system}.kagami;
kagami = let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
cargoLock = ./Cargo.lock;
craneLib = crane.mkLib pkgs;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
(craneLib.fileset.commonCargoSources ./.)
];
};
in pkgs.callPackage ./nix/package.nix {
useCrane = true;
inherit cargoToml cargoLock src craneLib;
};
});
devShells = forAllSystems (system: pkgs: toolchain: {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
toolchain
cargo-edit
gitoxide
pkg-config
openssl
];
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
};
});
};
}