poop-graph/flake.nix

61 lines
1.7 KiB
Nix

{
description = "Better web UI for COVID wastewater data";
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 = "poop-graph";
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 STATIC_DIR ${./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;
};
devShell = with pkgs; let
fenixWith = fenixStable.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
];
in mkShell {
nativeBuildInputs = [ fenixWith cargo-audit stdenv.cc ];
};
}
);
}