diff options
author | Paweł Dybiec <pawel@dybiec.info> | 2023-08-22 22:37:40 +0100 |
---|---|---|
committer | Paweł Dybiec <pawel@dybiec.info> | 2023-08-22 22:37:40 +0100 |
commit | c38445d412a4437a727105b8e72416026532dc03 (patch) | |
tree | 68c772df19459ab01a2fd68b8ff2383763317fba | |
parent | Handle pings and protocol errors (diff) |
Nix config
-rw-r--r-- | flake.lock | 129 | ||||
-rw-r--r-- | flake.nix | 71 |
2 files changed, 200 insertions, 0 deletions
diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..79f866b --- /dev/null +++ b/flake.lock @@ -0,0 +1,129 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": [ + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1691803597, + "narHash": "sha256-khWW1Owzselq5o816Lb7x624d6QGnv+kpronK3ndkr4=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7809d369710abb17767b624f9e72b500373580bc", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1692587767, + "narHash": "sha256-J1ZaJEWgUoT4zfNnhKukYLjel67bQyNHL1FqQ/kqCLo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "57492e92b9829946d866b700c101d9a5cc8d749e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692670201, + "narHash": "sha256-WbCKJRfh1Zb7N7g8Fzq7/Hg6i6yCbvaa0OAi4cSHk1w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "bf5196c27545735374376d96d41f209bae3643e1", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2326526 --- /dev/null +++ b/flake.nix @@ -0,0 +1,71 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + flake-utils.url = "github:numtide/flake-utils"; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + crane = { + url = "github:ipetkov/crane"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + rust-overlay.follows = "rust-overlay"; + }; + }; + }; + outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }: + flake-utils.lib.eachDefaultSystem + (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + craneLib = crane.lib.${system}; + src = craneLib.cleanCargoSource (craneLib.path ./.); + nativeBuildInputs = with pkgs; [ rust-bin.stable.latest.default pkg-config ]; + buildInputs = with pkgs; [ openssl sqlite ]; + commonArgs = { + inherit src nativeBuildInputs buildInputs; + }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + bin = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); + dockerImage = pkgs.dockerTools.streamLayeredImage { + name = "vavbot"; + tag = "latest"; + contents = [ bin pkgs.cacert ]; + config = { + Cmd = [ "${bin}/bin/vavbot" ]; + }; + }; + in + with pkgs; + { + checks = { + inherit bin; + fmt = craneLib.cargoFmt { inherit src; }; + tests = craneLib.cargoNextest (commonArgs // { + inherit cargoArtifacts; + }); + clippy = craneLib.cargoClippy (commonArgs // { + inherit cargoArtifacts; + }); + }; + packages = { + inherit bin dockerImage; + default = bin; + }; + devShells.default = mkShell { + inputsFrom = [ bin ]; + buildInputs = [ pkgs.cargo-nextest pkgs.dive pkgs.docker ]; + }; + } + ); +} + |