Refactor and update flake
This commit is contained in:
parent
e7c9222070
commit
26ec66d03e
130
flake.lock
130
flake.lock
|
@ -2,11 +2,26 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1653893745,
|
"lastModified": 1656928814,
|
||||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1631561581,
|
||||||
|
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -22,11 +37,32 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655042882,
|
"lastModified": 1659610603,
|
||||||
"narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
|
"narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=",
|
||||||
"owner": "nmattia",
|
"owner": "nmattia",
|
||||||
"repo": "naersk",
|
"repo": "naersk",
|
||||||
"rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
|
"rev": "c6a45e4277fa58abd524681466d3450f896dc094",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nmattia",
|
||||||
|
"repo": "naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"naersk_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"tlaternet-templates",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1632266297,
|
||||||
|
"narHash": "sha256-J1yeJk6Gud9ef2pEf6aKQemrfg1pVngYDSh+SAY94xk=",
|
||||||
|
"owner": "nmattia",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "ee7edec50b49ab6d69b06d62f1de554efccb1ccd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -37,11 +73,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655200170,
|
"lastModified": 1660318005,
|
||||||
"narHash": "sha256-/yzkX+10sJhYNIcTtZ5ObS+nh/HrJp01XLaubzbRDcU=",
|
"narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9ff91ce2e4c5d70551d4c8fd8830931c6c6b26b8",
|
"rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -51,29 +87,43 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1632408697,
|
||||||
|
"narHash": "sha256-JqTfu361AwFmV0WszXLAjfukqGxBbHRopRgdp9A2w8s=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "a13824fe5e38187fbc75cd598b5c06bdcc13501f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-20.09",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"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": {
|
"inputs": {
|
||||||
"flake-utils": [
|
"flake-utils": "flake-utils",
|
||||||
"flake-utils"
|
|
||||||
],
|
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655261370,
|
"lastModified": 1660358625,
|
||||||
"narHash": "sha256-AxKkHEuOgV/PyK+T6NOE4QyDHmZO+/XVyp0AtmrIoV0=",
|
"narHash": "sha256-uv+ZtOAEeM5tw78CLdRQmbZyDZYc0piSflthG2kNnrc=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "d62021584e798dd9e169f543dd3f1296f5216d0c",
|
"rev": "18354cce8137aaef0d505d6f677e9bbdd542020d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -81,6 +131,52 @@
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay_2": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": [
|
||||||
|
"tlaternet-templates",
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"tlaternet-templates",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1633400100,
|
||||||
|
"narHash": "sha256-kHQV7jZ2vVHVI9sfda1mUROVBbQbdfKcbIpKG9WdqGo=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "9c2fc6a62ccbc6f420d71ecac6bf0b84dbbee64f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"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",
|
||||||
|
|
116
flake.nix
116
flake.nix
|
@ -3,70 +3,80 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
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;
|
||||||
|
};
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
openssl
|
||||||
|
];
|
||||||
|
in {
|
||||||
|
packages.${system} = rec {
|
||||||
|
tlaternet-webserver = naersk-lib.buildPackage {
|
||||||
|
inherit buildInputs;
|
||||||
|
pname = "tlaternet-webserver";
|
||||||
|
root = pkgs.lib.cleanSource self;
|
||||||
|
};
|
||||||
|
default = tlaternet-webserver;
|
||||||
|
};
|
||||||
|
|
||||||
# The rust build lib, set to use the toolchain
|
apps.${system} = {
|
||||||
naersk-lib = naersk.lib.${prev.system}.override {
|
run-with-templates = let
|
||||||
cargo = toolchain;
|
script = pkgs.writeShellScriptBin "run-with-templates" ''
|
||||||
rustc = toolchain;
|
export ROCKET_TEMPLATE_DIR=${tlaternet-templates.packages.${system}.tlaternet-templates}
|
||||||
};
|
${self.packages.${system}.tlaternet-webserver}/bin/tlaternet-webserver
|
||||||
|
'';
|
||||||
# pkg-config, needed to include many native libs
|
in {
|
||||||
nativeBuildInputs = [ prev.pkgconfig ];
|
type = "app";
|
||||||
|
program = "${script}/bin/run-with-templates";
|
||||||
# Native libs
|
|
||||||
buildInputs = [ prev.openssl ];
|
|
||||||
|
|
||||||
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;
|
|
||||||
nativeBuildInputs = nativeBuildInputs ++ [
|
|
||||||
(toolchain.override {
|
|
||||||
extensions =
|
|
||||||
[ "rust-src" "rust-analysis" "rust-analyzer-preview" ];
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
devShells.${system} = {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
packages = builtins.concatLists [
|
||||||
|
buildInputs
|
||||||
|
[
|
||||||
|
(rust-toolchain.override {
|
||||||
|
extensions = ["rust-src" "rust-analysis" "rust-analyzer-preview"];
|
||||||
|
})
|
||||||
|
]
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue