simplify
This commit is contained in:
parent
0c6b3151b2
commit
2cf6561753
83
flake.nix
83
flake.nix
@ -1,69 +1,34 @@
|
|||||||
{
|
{
|
||||||
|
description = "Simple Rush nix flake";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs:
|
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
|
||||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
systems = [ "x86_64-linux" ];
|
|
||||||
perSystem = { config, self', pkgs, lib, system, ... }:
|
|
||||||
let
|
let
|
||||||
runtimeDeps = with pkgs; [ alsa-lib speechd ];
|
overlays = [ (import rust-overlay) ];
|
||||||
buildDeps = with pkgs; [ pkg-config rustPlatform.bindgenHook ];
|
pkgs = import nixpkgs {
|
||||||
devDeps = with pkgs; [ gdb ];
|
inherit system overlays;
|
||||||
|
|
||||||
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
|
|
||||||
jetbrains.rust-rover
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
_module.args.pkgs = import inputs.nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
overlays = [ (import inputs.rust-overlay) ];
|
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
};
|
};
|
||||||
|
in
|
||||||
packages.default = self'.packages.rush;
|
{
|
||||||
devShells.default = self'.devShells.stable;
|
devShells.default = with pkgs; mkShell {
|
||||||
|
buildInputs = [
|
||||||
packages.rush = (rustPackage "rush");
|
# rust-bin.beta.latest.default
|
||||||
packages.rush-base = (rustPackage "");
|
rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)
|
||||||
|
];
|
||||||
devShells.nightly = (mkDevShell (pkgs.rust-bin.selectLatestNightlyWith
|
packages = with pkgs; [
|
||||||
(toolchain: toolchain.default)));
|
jetbrains.rust-rover
|
||||||
devShells.stable = (mkDevShell pkgs.rust-bin.stable.latest.default);
|
];
|
||||||
devShells.msrv = (mkDevShell pkgs.rust-bin.stable.${msrv}.default);
|
shellHook = ''
|
||||||
};
|
export SHELL=${pkgs.lib.getExe pkgs.bashInteractive}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user