Initial Commit
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
commit
b93c29cb7f
9 changed files with 231 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Direnv
|
||||||
|
.direnv
|
||||||
|
|
||||||
|
# Cargo/Rust stuff
|
||||||
|
/target
|
||||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plaixt"
|
||||||
|
version = "0.1.0"
|
||||||
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "plaixt"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
97
flake.lock
generated
Normal file
97
flake.lock
generated
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729741221,
|
||||||
|
"narHash": "sha256-8AHZZXs1lFkERfBY0C8cZGElSo33D/et7NKEpLRmvzo=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "f235b656ee5b2bfd6d94c3bfd67896a575d4a6ed",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1726560853,
|
||||||
|
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729691686,
|
||||||
|
"narHash": "sha256-BAuPWW+9fa1moZTU+jFh+1cUtmsuF8asgzFwejM4wac=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "32e940c7c420600ef0d1ef396dc63b04ee9cad37",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-24.05",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729909612,
|
||||||
|
"narHash": "sha256-eXqxxbOagphPfjPptSlv0pQONB3fH15CQ4G8uCu1BW4=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "17cadbc36da05e75197d082decb382a5f4208e30",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
96
flake.nix
Normal file
96
flake.nix
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
{
|
||||||
|
description = "The Plaixt project";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-24.05";
|
||||||
|
flake-utils = {
|
||||||
|
url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
crane = {
|
||||||
|
url = "github:ipetkov/crane";
|
||||||
|
};
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
|
};
|
||||||
|
|
||||||
|
rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
unstableRustTarget = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
|
||||||
|
extensions = [ "rust-src" "miri" "rustfmt" ];
|
||||||
|
});
|
||||||
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustTarget;
|
||||||
|
unstableCraneLib = (crane.mkLib pkgs).overrideToolchain unstableRustTarget;
|
||||||
|
|
||||||
|
tomlInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; };
|
||||||
|
inherit (tomlInfo) pname version;
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
rustfmt' = pkgs.writeShellScriptBin "rustfmt" ''
|
||||||
|
exec "${unstableRustTarget}/bin/rustfmt" "$@"
|
||||||
|
'';
|
||||||
|
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly {
|
||||||
|
inherit src;
|
||||||
|
cargoExtraArgs = "--all-features --all";
|
||||||
|
};
|
||||||
|
|
||||||
|
plaixt = craneLib.buildPackage {
|
||||||
|
inherit cargoArtifacts src version;
|
||||||
|
cargoExtraArgs = "--all-features --all";
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
checks = {
|
||||||
|
inherit plaixt;
|
||||||
|
|
||||||
|
plaixt-clippy = craneLib.cargoClippy {
|
||||||
|
inherit cargoArtifacts src;
|
||||||
|
cargoExtraArgs = "--all --all-features";
|
||||||
|
cargoClippyExtraArgs = "-- --deny warnings";
|
||||||
|
};
|
||||||
|
|
||||||
|
plaixt-fmt = unstableCraneLib.cargoFmt {
|
||||||
|
inherit src;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
packages.plaixt = plaixt;
|
||||||
|
packages.default = packages.plaixt;
|
||||||
|
|
||||||
|
apps.plaixt = flake-utils.lib.mkApp {
|
||||||
|
name = "plaixt";
|
||||||
|
drv = plaixt;
|
||||||
|
};
|
||||||
|
apps.default = apps.plaixt;
|
||||||
|
|
||||||
|
devShells.default = devShells.plaixt;
|
||||||
|
devShells.plaixt = pkgs.mkShell {
|
||||||
|
buildInputs = [ ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
rustfmt'
|
||||||
|
rustTarget
|
||||||
|
|
||||||
|
pkgs.cargo-msrv
|
||||||
|
pkgs.cargo-deny
|
||||||
|
pkgs.cargo-expand
|
||||||
|
pkgs.cargo-bloat
|
||||||
|
pkgs.cargo-fuzz
|
||||||
|
|
||||||
|
pkgs.gitlint
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "1.82.0"
|
||||||
3
rustfmt.toml
Normal file
3
rustfmt.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
imports_granularity = "Item"
|
||||||
|
reorder_imports = true
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
14
src/lib.rs
Normal file
14
src/lib.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue