Integrate templates project
This commit is contained in:
parent
3a5d4b9756
commit
76f5246814
55 changed files with 11946 additions and 144 deletions
95
flake.nix
95
flake.nix
|
@ -3,78 +3,63 @@
|
|||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
naersk = {
|
||||
url = "github:nmattia/naersk";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
dream2nix.url = "github:nix-community/dream2nix";
|
||||
|
||||
tlaternet-templates = {
|
||||
url = "git+https://gitea.tlater.net/tlaternet/tlaternet-templates.git";
|
||||
# No need to override anything here; we can save some downloads
|
||||
# if we rely on the webserver to do that.
|
||||
fenix = {
|
||||
url = "github:nix-community/fenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
naersk,
|
||||
tlaternet-templates,
|
||||
dream2nix,
|
||||
fenix,
|
||||
}: let
|
||||
# At the moment, we only deploy to x86_64-linux. Update when we
|
||||
# care about another platform.
|
||||
system = "x86_64-linux";
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
];
|
||||
pkgs = import nixpkgs {inherit system overlays;};
|
||||
|
||||
# Rust build config
|
||||
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
naersk-lib = naersk.lib.${system}.override {
|
||||
cargo = rust-toolchain;
|
||||
rustc = rust-toolchain;
|
||||
};
|
||||
buildInputs = with pkgs; [
|
||||
pkg-config
|
||||
openssl
|
||||
];
|
||||
flakeOutputs = import ./nix/packages.nix {inherit nixpkgs dream2nix fenix system;};
|
||||
in {
|
||||
packages.${system} = rec {
|
||||
tlaternet-webserver = naersk-lib.buildPackage {
|
||||
inherit buildInputs;
|
||||
pname = "tlaternet-webserver";
|
||||
root = pkgs.lib.cleanSource self;
|
||||
};
|
||||
default = tlaternet-webserver;
|
||||
};
|
||||
|
||||
apps.${system} = {
|
||||
run-with-templates = let
|
||||
script = pkgs.writeShellScriptBin "run-with-templates" ''
|
||||
RUST_LOG=info ${self.packages.${system}.tlaternet-webserver}/bin/tlaternet-webserver \
|
||||
--template-directory ${tlaternet-templates.packages.${system}.default}
|
||||
'';
|
||||
in {
|
||||
type = "app";
|
||||
program = "${script}/bin/run-with-templates";
|
||||
};
|
||||
packages.${system} = {
|
||||
server = flakeOutputs.server.packages.${system}.default;
|
||||
templates = flakeOutputs.templates.packages.${system}.default;
|
||||
};
|
||||
|
||||
devShells.${system} = {
|
||||
default = pkgs.mkShell {
|
||||
packages = builtins.concatLists [
|
||||
buildInputs
|
||||
templates = flakeOutputs.templates.devShells.${system}.default.overrideAttrs (old: {
|
||||
buildInputs = with nixpkgs.legacyPackages.${system};
|
||||
[
|
||||
(rust-toolchain.override {
|
||||
extensions = ["rust-src" "rust-analysis" "rust-analyzer-preview"];
|
||||
})
|
||||
yj
|
||||
]
|
||||
++ old.buildInputs;
|
||||
|
||||
shellHook =
|
||||
''
|
||||
# Update package.json
|
||||
if [ -e ./package.json ]; then
|
||||
unlink ./package.json
|
||||
fi
|
||||
|
||||
cat ./package.yaml | yj > ./package.json
|
||||
''
|
||||
+ old.shellHook;
|
||||
});
|
||||
|
||||
server = nixpkgs.legacyPackages.${system}.mkShell {
|
||||
packages = [
|
||||
(flakeOutputs.server.rust-toolchain.withComponents [
|
||||
"rustc"
|
||||
"cargo"
|
||||
"rustfmt"
|
||||
"rust-std"
|
||||
"rust-docs"
|
||||
"clippy"
|
||||
"rust-src"
|
||||
"rust-analysis"
|
||||
])
|
||||
fenix.packages.${system}.rust-analyzer
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue