flake.nix,flake.lock: prepare rust environment

This commit is contained in:
2025-12-22 19:59:14 +09:00
parent 03ef47638d
commit 00793bed2b
3 changed files with 53 additions and 9 deletions

View File

@@ -1,7 +1,12 @@
{
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }: let
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, rust-overlay }: let
inherit (nixpkgs) lib;
systems = [
@@ -12,16 +17,33 @@
"armv7l-linux"
];
forAllSystems = f: lib.genAttrs systems (system: f system nixpkgs.legacyPackages.${system});
forAllSystems = f: nixpkgs.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" ];
};
in f system pkgs toolchain);
in {
devShells = forAllSystems (system: pkgs: {
devShells = forAllSystems (system: pkgs: toolchain: {
default = pkgs.mkShell {
packages = with pkgs; [
toolchain
cargo-edit
ruff
(python3.withPackages (ppkgs: with ppkgs; [
psycopg2-binary
]))
];
env.RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
};
});
@@ -31,7 +53,7 @@
nixosModules.default = ./module.nix;
packages = forAllSystems (system: pkgs: {
packages = forAllSystems (system: pkgs: _: {
default = self.packages.${system}.mclog2psql;
mclog2psql = pkgs.writers.writePython3Bin "mclog2psql" {
libraries = [ pkgs.python3Packages.psycopg2 ];