Files
asciinema/flake.nix

86 lines
2.1 KiB
Nix
Raw Normal View History

2024-02-14 21:54:21 +01:00
{
description = "Terminal session recorder";
inputs = {
2024-06-09 00:43:05 +02:00
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
2024-04-20 14:02:53 +02:00
rust-overlay.url = github:oxalica/rust-overlay;
2024-06-09 00:43:05 +02:00
flake-parts.url = github:hercules-ci/flake-parts;
2024-02-14 21:54:21 +01:00
};
2024-06-09 00:43:05 +02:00
outputs = inputs @ {
flake-parts,
rust-overlay,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
2024-06-09 00:47:37 +02:00
packageToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package;
msrv = packageToml.rust-version;
2024-04-20 14:02:53 +02:00
2024-06-09 00:43:05 +02:00
buildDeps = rust:
with pkgs;
[
rust
]
++ (lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Foundation
])
++ testDeps;
2024-04-20 14:02:53 +02:00
testDeps = with pkgs; [
python3
];
2024-06-09 00:43:05 +02:00
mkDevShell = rust:
pkgs.mkShell {
packages = buildDeps (rust.override {
2024-06-09 00:43:05 +02:00
extensions = ["rust-src"];
});
2024-04-20 14:02:53 +02:00
env.RUST_BACKTRACE = 1;
2024-06-09 00:43:05 +02:00
};
mkPackage = rust:
(pkgs.makeRustPlatform {
cargo = rust;
rustc = rust;
})
.buildRustPackage {
2024-06-09 00:47:37 +02:00
pname = packageToml.name;
inherit (packageToml) version;
2024-06-09 00:48:41 +02:00
src = builtins.path {
path = ./.;
inherit (packageToml) name;
};
2024-06-09 00:43:05 +02:00
cargoLock.lockFile = ./Cargo.lock;
buildInputs = buildDeps rust;
2024-06-09 00:43:05 +02:00
dontUseCargoParallelTests = true;
};
in {
_module.args = {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
};
2024-06-09 00:43:05 +02:00
formatter = pkgs.alejandra;
2024-04-20 14:02:53 +02:00
2024-06-09 00:43:05 +02:00
devShells = {
default = mkDevShell pkgs.rust-bin.stable.latest.default;
msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default;
2024-04-20 14:02:53 +02:00
};
packages.default = mkPackage pkgs.rust-bin.stable.latest.minimal;
2024-06-09 00:43:05 +02:00
};
};
2024-02-14 21:54:21 +01:00
}