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

1
.gitignore vendored
View File

@@ -1 +1,2 @@
result
target

29
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1755082269,
"narHash": "sha256-Ix7ALeaxv9tW4uBKWeJnaKpYZtZiX4H4Q/MhEmj4XYA=",
"lastModified": 1766314097,
"narHash": "sha256-laJftWbghBehazn/zxVJ8NdENVgjccsWAdAqKXhErrM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d74de548348c46cf25cb1fcc4b74f38103a4590d",
"rev": "306ea70f9eb0fb4e040f8540e2deab32ed7e2055",
"type": "github"
},
"original": {
@@ -17,7 +17,28 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1766371695,
"narHash": "sha256-W7CX9vy7H2Jj3E8NI4djHyF8iHSxKpb2c/7uNQ/vGFU=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "d81285ba8199b00dc31847258cae3c655b605e8c",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},

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 ];