diff options
| author | Fuwn <[email protected]> | 2024-09-24 19:38:45 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-09-24 19:38:45 -0700 |
| commit | c26287d1c37f8a486f4204973eecdb2f9e9056a1 (patch) | |
| tree | 92a987a4bb1e3d9edd8df79bda72213195f0b7ac /flake.nix | |
| parent | chore(nix): add nix development environment (diff) | |
| download | whirl-c26287d1c37f8a486f4204973eecdb2f9e9056a1.tar.xz whirl-c26287d1c37f8a486f4204973eecdb2f9e9056a1.zip | |
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 53 |
1 files changed, 51 insertions, 2 deletions
@@ -2,6 +2,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; + crane.url = "github:ipetkov/crane"; rust-overlay = { url = "github:oxalica/rust-overlay"; @@ -14,15 +15,63 @@ nixpkgs, flake-utils, rust-overlay, + crane, ... }: flake-utils.lib.eachDefaultSystem ( system: let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { inherit system overlays; }; + pkgs = import nixpkgs { + inherit system; + + overlays = [ (import rust-overlay) ]; + }; + + rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + + commonArgs = { + src = craneLib.cleanCargoSource ./.; + + nativeBuildInputs = with pkgs; [ + rustToolchain + pkg-config + ]; + + buildInputs = with pkgs; [ + openssl + sqlite + ]; + }; + + whirl = craneLib.buildPackage ( + commonArgs + // { + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + } + ); in { + packages = { + inherit whirl; + + default = whirl; + + docker = pkgs.dockerTools.buildLayeredImage { + name = "fuwn/whirl"; + tag = "latest"; + + config = { + Entrypoint = [ "${whirl}/bin/whirl" ]; + + Cmd = [ + "run" + "distributor,hub" + ]; + }; + }; + }; + devShell = with pkgs; mkShell.override |