nix flakes
This commit is contained in:
parent
5958ebf251
commit
5c1f09360a
3 changed files with 171 additions and 0 deletions
59
flake.nix
Normal file
59
flake.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
description = "transbeam: a low-latency file drop web app";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
crate2nix = {
|
||||
url = "github:kolloch/crate2nix";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix }: let
|
||||
name = "transbeam";
|
||||
in
|
||||
utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
rust-overlay.overlay
|
||||
(final: prev: {
|
||||
rustc = final.rust-bin.stable.latest.default;
|
||||
cargo = final.rust-bin.stable.latest.default;
|
||||
})
|
||||
];
|
||||
};
|
||||
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; })
|
||||
generatedCargoNix;
|
||||
project = import
|
||||
(generatedCargoNix {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
})
|
||||
{ inherit pkgs; };
|
||||
in rec {
|
||||
packages.${name} = pkgs.symlinkJoin {
|
||||
inherit name;
|
||||
paths = [ packages."${name}-unwrapped" ];
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/${name} \
|
||||
--set STATIC_DIR ${./static}
|
||||
'';
|
||||
};
|
||||
|
||||
defaultPackage = packages.${name};
|
||||
|
||||
packages."${name}-unwrapped" = project.rootCrate.build;
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [ rustc cargo cargo-audit stdenv.cc ];
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue