Update the flake #7

Manually merged
tlater merged 3 commits from tlater/update into master 2022-08-14 00:28:54 +01:00
3 changed files with 600 additions and 479 deletions

861
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,21 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": { "locked": {
"lastModified": 1631561581, "lastModified": 1631561581,
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
@ -21,6 +36,27 @@
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": {
"lastModified": 1659610603,
"narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=",
"owner": "nmattia",
"repo": "naersk",
"rev": "c6a45e4277fa58abd524681466d3450f896dc094",
"type": "github"
},
"original": {
"owner": "nmattia",
"repo": "naersk",
"type": "github"
}
},
"naersk_2": {
"inputs": {
"nixpkgs": [
"tlaternet-templates",
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1632266297, "lastModified": 1632266297,
"narHash": "sha256-J1yeJk6Gud9ef2pEf6aKQemrfg1pVngYDSh+SAY94xk=", "narHash": "sha256-J1yeJk6Gud9ef2pEf6aKQemrfg1pVngYDSh+SAY94xk=",
@ -36,6 +72,22 @@
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1660318005,
"narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1632408697, "lastModified": 1632408697,
"narHash": "sha256-JqTfu361AwFmV0WszXLAjfukqGxBbHRopRgdp9A2w8s=", "narHash": "sha256-JqTfu361AwFmV0WszXLAjfukqGxBbHRopRgdp9A2w8s=",
@ -53,18 +105,41 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"naersk": "naersk", "naersk": "naersk",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay",
"tlaternet-templates": "tlaternet-templates"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1660358625,
"narHash": "sha256-uv+ZtOAEeM5tw78CLdRQmbZyDZYc0piSflthG2kNnrc=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "18354cce8137aaef0d505d6f677e9bbdd542020d",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"rust-overlay_2": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": [
"tlaternet-templates",
"flake-utils" "flake-utils"
], ],
"nixpkgs": [ "nixpkgs": [
"tlaternet-templates",
"nixpkgs" "nixpkgs"
] ]
}, },
@ -81,6 +156,27 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"tlaternet-templates": {
"inputs": {
"flake-utils": "flake-utils_2",
"naersk": "naersk_2",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1633433130,
"narHash": "sha256-jkW+HV8cJvE86gppOEXQl2ke+bDHJ7SAp8eJp8pJ0N8=",
"ref": "master",
"rev": "1232950c06ae16bf17fb16ac1f5f2231e971936b",
"revCount": 16,
"type": "git",
"url": "https://gitea.tlater.net/tlaternet/tlaternet.git"
},
"original": {
"type": "git",
"url": "https://gitea.tlater.net/tlaternet/tlaternet.git"
}
} }
}, },
"root": "root", "root": "root",

110
flake.nix
View file

@ -2,71 +2,81 @@
description = "tlater.net web server"; description = "tlater.net web server";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-20.09"; nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = { rust-overlay = {
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs = { inputs.nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
}; };
naersk = { naersk = {
url = "github:nmattia/naersk"; url = "github:nmattia/naersk";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
tlaternet-templates = {
url = "git+https://gitea.tlater.net/tlaternet/tlaternet.git";
# No need to override anything here; we can save some downloads
# if we rely on the webserver to do that.
};
}; };
outputs = { self, nixpkgs, flake-utils, rust-overlay, naersk }@inputs: outputs = {
flake-utils.lib.simpleFlake { self,
inherit self nixpkgs; nixpkgs,
name = "tlaternet-webserver"; rust-overlay,
preOverlays = [ rust-overlay.overlay ]; naersk,
tlaternet-templates,
}: 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;};
overlay = final: prev: { # Rust build config
tlaternet-webserver = let rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
# The rust toolchain to use naersk-lib = naersk.lib.${system}.override {
toolchain = cargo = rust-toolchain;
prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; rustc = rust-toolchain;
# The rust build lib, set to use the toolchain
naersk-lib = naersk.lib.${prev.system}.override {
cargo = toolchain;
rustc = toolchain;
}; };
buildInputs = with pkgs; [
# pkg-config, needed to include many native libs pkg-config
nativeBuildInputs = [ prev.pkgconfig ]; openssl
];
# Native libs in {
buildInputs = [ prev.openssl ]; packages.${system} = rec {
tlaternet-webserver = naersk-lib.buildPackage {
in rec {
# The packages provided by this flake
packages = {
webserver = prev.callPackage
({ rustPlatform, openssl, pkgconfig, ... }:
naersk-lib.buildPackage {
inherit nativeBuildInputs buildInputs;
pname = "tlaternet-webserver";
root = ./.;
}) { };
};
defaultPackage = packages.webserver;
# A dev shell to hack manually; note this includes
# additional toolchain components
devShell = prev.mkShell {
inherit buildInputs; inherit buildInputs;
nativeBuildInputs = nativeBuildInputs ++ [ pname = "tlaternet-webserver";
(toolchain.override { root = pkgs.lib.cleanSource self;
extensions = };
[ "rust-src" "rust-analysis" "rust-analyzer-preview" ]; default = tlaternet-webserver;
};
apps.${system} = {
run-with-templates = let
script = pkgs.writeShellScriptBin "run-with-templates" ''
export ROCKET_TEMPLATE_DIR=${tlaternet-templates.packages.${system}.tlaternet-templates}
${self.packages.${system}.tlaternet-webserver}/bin/tlaternet-webserver
'';
in {
type = "app";
program = "${script}/bin/run-with-templates";
};
};
devShells.${system} = {
default = pkgs.mkShell {
packages = builtins.concatLists [
buildInputs
[
(rust-toolchain.override {
extensions = ["rust-src" "rust-analysis" "rust-analyzer-preview"];
}) })
]
]; ];
}; };
}; };
}; };
};
} }