1
Fork 0
minesweeper-nojs/flake.nix

89 lines
2.2 KiB
Nix
Raw Permalink Normal View History

2023-12-31 22:49:37 +01:00
{
description = "A Nix-flake-based Rust development environment";
inputs = {
2024-05-23 09:36:23 +02:00
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
2024-05-02 20:39:19 +02:00
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-12-31 22:49:37 +01:00
};
2024-05-02 20:39:19 +02:00
outputs =
{
self,
nixpkgs,
treefmt-nix,
fenix,
}:
2023-12-31 22:49:37 +01:00
let
2024-05-02 20:39:19 +02:00
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem =
f:
nixpkgs.lib.genAttrs supportedSystems (
system:
f (
2023-12-31 22:49:37 +01:00
let
2024-05-23 13:16:11 +02:00
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};
2024-05-02 20:39:19 +02:00
fenix' = (import fenix { inherit system pkgs; });
2024-05-23 13:16:11 +02:00
toolchain = fenix'.fromToolchainFile {
file = ./rust-toolchain.toml;
2024-09-08 17:14:59 +02:00
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
2024-05-23 13:16:11 +02:00
};
2023-12-31 22:49:37 +01:00
in
2024-05-02 20:39:19 +02:00
{
inherit pkgs toolchain;
}
)
);
2023-12-31 22:49:37 +01:00
in
{
2024-05-02 20:39:19 +02:00
formatter = forEachSupportedSystem (
{ pkgs, ... }: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build.wrapper
);
devShells = forEachSupportedSystem (
{ pkgs, toolchain }:
{
default = pkgs.mkShell {
nativeBuildInputs = [ toolchain ];
buildInputs = [ toolchain ];
};
}
);
packages = forEachSupportedSystem (
{ pkgs, toolchain }:
{
default = (
let
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
in
rustPlatform.buildRustPackage {
pname = manifest.name;
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;
}
);
}
);
2023-12-31 22:49:37 +01:00
};
}