Include a package in the flake
This commit is contained in:
parent
620b84fd46
commit
68d5b081b1
2 changed files with 70 additions and 14 deletions
63
flake.nix
63
flake.nix
|
@ -11,27 +11,62 @@
|
|||
nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
naersk = {
|
||||
url = "github:nmattia/naersk";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, rust-overlay }@inputs:
|
||||
outputs = { self, nixpkgs, flake-utils, rust-overlay, naersk }@inputs:
|
||||
flake-utils.lib.simpleFlake {
|
||||
inherit self nixpkgs;
|
||||
name = "tlaternet";
|
||||
preOverlays = [ rust-overlay.overlay ];
|
||||
|
||||
shell = { pkgs }:
|
||||
let
|
||||
rust_channel =
|
||||
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
in pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
(rust_channel.override {
|
||||
extensions =
|
||||
[ "rust-src" "rust-analysis" "rust-analyzer-preview" ];
|
||||
})
|
||||
pkgconfig
|
||||
];
|
||||
buildInputs = with pkgs; [ openssl ];
|
||||
overlay = final: prev: {
|
||||
tlaternet = let
|
||||
# The rust toolchain to use
|
||||
toolchain =
|
||||
prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
|
||||
# The rust build lib, set to use the toolchain
|
||||
naersk-lib = naersk.lib.${prev.system}.override {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
|
||||
# pkg-config, needed to include many native libs
|
||||
nativeBuildInputs = [ prev.pkgconfig ];
|
||||
|
||||
# Native libs
|
||||
buildInputs = [ prev.openssl ];
|
||||
|
||||
in rec {
|
||||
# The packages provided by this flake
|
||||
tlaternet = {
|
||||
webserver = prev.callPackage
|
||||
({ rustPlatform, openssl, pkgconfig, ... }:
|
||||
naersk-lib.buildPackage {
|
||||
inherit nativeBuildInputs buildInputs;
|
||||
|
||||
pname = "tlaternet-webserver";
|
||||
root = ./.;
|
||||
}) { };
|
||||
};
|
||||
defaultPackage = tlaternet.webserver;
|
||||
|
||||
# A dev shell to hack manually; note this includes
|
||||
# additional toolchain components
|
||||
devShell = prev.mkShell {
|
||||
inherit buildInputs;
|
||||
nativeBuildInputs = nativeBuildInputs ++ [
|
||||
(toolchain.override {
|
||||
extensions =
|
||||
[ "rust-src" "rust-analysis" "rust-analyzer-preview" ];
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue