transbeam/flake.nix

81 lines
2.3 KiB
Nix

{
description = "transbeam: a low-latency file drop web app";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
fenix.url = "github:nix-community/fenix";
};
outputs = { self, nixpkgs, utils, fenix }: let
name = "transbeam";
in
utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};
fenixStable = fenix.packages.${system}.stable;
fenixPlatform = pkgs.makeRustPlatform {
cargo = fenixStable.toolchain;
rustc = fenixStable.toolchain;
};
in rec {
packages.${name} = pkgs.symlinkJoin {
inherit name;
paths = [ packages."${name}-unwrapped" ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/${name} \
--set TRANSBEAM_STATIC_DIR ${./static} \
--set TRANSBEAM_CACHEBUSTER ${builtins.substring 0 8 (builtins.hashString "sha256" (toString ./static))}
'';
};
defaultPackage = packages.${name};
packages."${name}-unwrapped" = let
cargoTOML = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in fenixPlatform.buildRustPackage {
pname = name;
inherit (cargoTOML.package) version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
packages."${name}-cli" = with pkgs.python3Packages; buildPythonApplication {
pname = "${name}-cli";
version = "0.1";
propagatedBuildInputs = [
tqdm
websockets
];
src = ./cli;
};
devShell = with pkgs; let
fenixWith = fenixStable.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
];
in mkShell {
nativeBuildInputs = [
stdenv.cc
fenixWith
cargo-audit
cargo-flamegraph
(python3.withPackages (p: with p; [
tqdm
websockets
]))
];
};
}
);
}