add Cargo.toml and flake.nix
This commit is contained in:
parent
692f93c56c
commit
5317a36a33
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "tito"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
75
flake.nix
Normal file
75
flake.nix
Normal file
@ -0,0 +1,75 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs = inputs:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [ "x86_64-linux" ];
|
||||
perSystem = { config, self', pkgs, lib, system, ... }:
|
||||
let
|
||||
runtimeDeps = with pkgs; [ alsa-lib speechd ];
|
||||
buildDeps = with pkgs; [ pkg-config rustPlatform.bindgenHook ];
|
||||
devDeps = with pkgs; [ gdb ];
|
||||
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||
msrv = cargoToml.package.rust-version;
|
||||
|
||||
rustPackage = features:
|
||||
(pkgs.makeRustPlatform {
|
||||
cargo = pkgs.rust-bin.stable.latest.minimal;
|
||||
rustc = pkgs.rust-bin.stable.latest.minimal;
|
||||
}).buildRustPackage {
|
||||
inherit (cargoToml.package) name version;
|
||||
src = ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
buildFeatures = features;
|
||||
buildInputs = runtimeDeps;
|
||||
nativeBuildInputs = buildDeps;
|
||||
# Uncomment if your cargo tests require networking or otherwise
|
||||
# don't play nicely with the Nix build sandbox:
|
||||
# doCheck = false;
|
||||
};
|
||||
|
||||
mkDevShell = rustc:
|
||||
pkgs.mkShell {
|
||||
shellHook = ''
|
||||
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
|
||||
export SHELL=${pkgs.lib.getExe pkgs.bashInteractive}
|
||||
'';
|
||||
buildInputs = runtimeDeps;
|
||||
nativeBuildInputs = buildDeps ++ devDeps ++ [ rustc ];
|
||||
packages = with pkgs; [
|
||||
rust-analyzer
|
||||
lldb
|
||||
(vscode-with-extensions.override {
|
||||
vscode = vscodium;
|
||||
vscodeExtensions = with vscode-extensions; [
|
||||
rust-lang.rust-analyzer
|
||||
vadimcn.vscode-lldb
|
||||
];
|
||||
})
|
||||
];
|
||||
};
|
||||
in {
|
||||
_module.args.pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import inputs.rust-overlay) ];
|
||||
};
|
||||
|
||||
packages.default = self'.packages.tito;
|
||||
# devShells.default = self'.devShells.nightly;
|
||||
devShells.default = self'.devShells.stable;
|
||||
|
||||
packages.tito = (rustPackage "tito");
|
||||
packages.tito-base = (rustPackage "");
|
||||
|
||||
devShells.nightly = (mkDevShell (pkgs.rust-bin.selectLatestNightlyWith
|
||||
(toolchain: toolchain.default)));
|
||||
devShells.stable = (mkDevShell pkgs.rust-bin.stable.latest.default);
|
||||
devShells.msrv = (mkDevShell pkgs.rust-bin.stable.${msrv}.default);
|
||||
};
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user