chir.rs/flake.nix

97 lines
2.5 KiB
Nix
Raw Permalink Normal View History

2024-11-26 07:41:01 +00:00
{
description = "rust-template";
inputs = {
cargo2nix = {
url = "github:DarkKirb/cargo2nix/master";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
2024-11-27 07:32:54 +00:00
2024-11-26 07:41:01 +00:00
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
2024-11-27 07:32:54 +00:00
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs";
riscv-overlay = {
url = "github:DarkKirb/riscv-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-11-26 07:41:01 +00:00
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
cargo2nix,
2024-11-27 07:32:54 +00:00
riscv-overlay,
2024-11-26 07:41:01 +00:00
...
}@inputs:
2024-11-26 07:51:22 +00:00
flake-utils.lib.eachSystem
[
"x86_64-linux"
"aarch64-linux"
"riscv64-linux"
]
(
system:
let
2024-11-27 07:32:54 +00:00
overlays =
[
cargo2nix.overlays.default
(import rust-overlay)
]
++ (
if system == "riscv64-linux" then
[
riscv-overlay.overlays.default
]
else
[ ]
);
2024-11-26 07:51:22 +00:00
pkgs = import nixpkgs {
inherit system overlays;
2024-11-26 07:41:01 +00:00
};
2024-11-26 07:51:22 +00:00
rustPkgs = pkgs.rustBuilder.makePackageSet {
packageFun = import ./Cargo.nix;
rustChannel = "stable";
rustVersion = "latest";
packageOverrides = pkgs: pkgs.rustBuilder.overrides.all;
};
in
rec {
devShells.default =
with pkgs;
mkShell {
buildInputs = [
cargo2nix.packages.${system}.cargo2nix
rustfilt
gdb
sqlx-cli
cargo-expand
sqlite
2024-12-03 08:15:25 +00:00
treefmt
nixfmt-rfc-style
2024-11-26 07:51:22 +00:00
];
};
packages = pkgs.lib.mapAttrs (_: v: (v { }).overrideAttrs { dontStrip = true; }) rustPkgs.workspace;
nixosModules.default = import ./nixos {
inherit inputs system;
};
checks = pkgs.lib.mapAttrs (_: v: pkgs.rustBuilder.runTests v { }) rustPkgs.workspace;
hydraJobs = {
inherit packages checks;
};
formatter = pkgs.nixfmt-rfc-style;
}
);
2024-11-26 07:41:01 +00:00
}
# Trick renovate into working: "github:NixOS/nixpkgs/nixpkgs-unstable"