feat(nix): remove devenv, build backend with nix
This commit is contained in:
52
flake.nix
52
flake.nix
@@ -1,57 +1,69 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
alejandra = {
|
||||
url = "github:kamadorueda/alejandra/4.0.0";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
devenv = {
|
||||
url = "github:cachix/devenv";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
devenv-root = {
|
||||
url = "file+file:///dev/null";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
nixConfig = {
|
||||
extra-trusted-public-keys = [
|
||||
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
|
||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||
"phundrak.cachix.org-1:osJAkYO0ioTOPqaQCIXMfIRz1/+YYlVFkup3R2KSexk="
|
||||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
||||
];
|
||||
extra-substituters = [
|
||||
"https://devenv.cachix.org"
|
||||
"https://phundrak.cachix.org?priority=10"
|
||||
"https://nix-community.cachix.org?priority=20"
|
||||
"https://cache.nixos.org?priority=30"
|
||||
];
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
rust-overlay,
|
||||
alejandra,
|
||||
...
|
||||
} @ inputs:
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
overlays = [(import rust-overlay)];
|
||||
pkgs = import nixpkgs {inherit system overlays;};
|
||||
rustVersion = pkgs.rust-bin.stable.latest.default;
|
||||
rustPlatform = pkgs.makeRustPlatform {
|
||||
cargo = rustVersion;
|
||||
rustc = rustVersion;
|
||||
targets = {
|
||||
linux-x86_64 = {
|
||||
crossPkgs = pkgs;
|
||||
triple = "x86_64-unknown-linux-gnu";
|
||||
};
|
||||
linux-aarch64 = {
|
||||
crossPkgs = pkgs.pkgsCross.aarch64-multiplatform;
|
||||
triple = "aarch64-unknown-linux-gnu";
|
||||
};
|
||||
};
|
||||
mkRustBuild = import ./nix/backend.nix;
|
||||
packages = {
|
||||
linux-x86_64 = mkRustBuild targets.linux-x86_64;
|
||||
linux-aarch64 = mkRustBuild targets.linux-aarch64;
|
||||
};
|
||||
defaultBySystem = {
|
||||
"x86_64-linux" = packages.linux-x86_64;
|
||||
"aarch64-linux" = packages.linux-aarch64;
|
||||
};
|
||||
in {
|
||||
formatter = alejandra.defaultPackage.${system};
|
||||
packages = import ./nix/package.nix {inherit pkgs rustPlatform;};
|
||||
devShell = import ./nix/shell.nix {
|
||||
inherit inputs pkgs self rustVersion system;
|
||||
};
|
||||
packages.backend =
|
||||
packages
|
||||
// {
|
||||
default = defaultBySystem.${system} or packages.linux-x86_64;
|
||||
};
|
||||
devShell = import ./nix/shell.nix {inherit pkgs rustVersion;};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user