xplr/flake.nix

71 lines
1.9 KiB
Nix
Raw Normal View History

2022-11-11 21:05:02 +00:00
{
description = "xplr - A hackable, minimal, fast TUI file explorer";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
};
outputs = inputs@{ self, nixpkgs, ... }:
2022-11-12 15:28:59 +00:00
let
lib = nixpkgs.lib;
darwin = [ "x86_64-darwin" "aarch64-darwin" ];
linux = [ "x86_64-linux" "x86_64-linux-musl" "aarch64-linux" "aarch64-linux-android" "i86_64-linux" ];
allSystems = darwin ++ linux;
forEachSystem = systems: f: lib.genAttrs systems (system: f system);
forAllSystems = forEachSystem allSystems;
2022-11-12 15:28:59 +00:00
in
{
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
rec {
# e.g. nix build .#xplr
2022-11-12 15:28:59 +00:00
xplr = pkgs.rustPlatform.buildRustPackage rec {
name = "xplr";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
2022-11-12 15:11:42 +00:00
};
2022-11-11 21:05:02 +00:00
};
# e.g. nix build .#cross.x86_64-linux-musl.xplr --impure
cross = forEachSystem (lib.filter (sys: sys != system) allSystems) (targetSystem:
let
crossPkgs = import nixpkgs { localSystem = system; crossSystem = targetSystem; };
in
{ inherit (crossPkgs) xplr; }
);
2022-11-12 20:09:24 +00:00
}
);
2022-11-12 15:28:59 +00:00
defaultPackage = forAllSystems (system: self.packages.${system}.xplr);
2022-11-12 20:09:24 +00:00
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
devRequirements = with pkgs; [
gcc
gnumake
clippy
rustc
cargo
rustfmt
rust-analyzer
];
in
{
default = pkgs.mkShell {
RUST_BACKTRACE = 1;
# For cross compilation
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM = 1;
2022-11-12 20:09:24 +00:00
buildInputs = devRequirements;
packages = devRequirements;
};
}
);
2022-11-12 15:28:59 +00:00
};
2022-11-11 21:05:02 +00:00
}