add nix flake

This commit is contained in:
Joseph Goulden 2024-06-29 19:45:17 +01:00 committed by Greg Heartsfield
parent 07198b2cb9
commit 0d04b5eefa
2 changed files with 126 additions and 0 deletions

82
flake.lock Normal file
View File

@ -0,0 +1,82 @@
{
"nodes": {
"crane": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1719249093,
"narHash": "sha256-0q1haa3sw6GbmJ+WhogMnducZGjEaCa/iR6hF2vq80I=",
"owner": "ipetkov",
"repo": "crane",
"rev": "9791c77eb7e98b8d8ac5b0305d47282f994411ca",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1719254875,
"narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"crane": "crane",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"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
}

44
flake.nix Normal file
View File

@ -0,0 +1,44 @@
{
description = "Nostr Relay written in Rust";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, ... }:
inputs.flake-utils.lib.eachDefaultSystem (system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
craneLib = inputs.crane.mkLib pkgs;
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
(pkgs.lib.hasSuffix "\.proto" path) ||
# Default filter from crane (allow .rs files)
(craneLib.filterCargoSources path type)
;
};
crate = craneLib.buildPackage {
name = "nostr-rs-relay";
inherit src;
nativeBuildInputs = [ pkgs.pkg-config pkgs.protobuf ];
};
in
{
checks = {
inherit crate;
};
packages.default = crate;
formatter = pkgs.nixpkgs-fmt;
devShells.default = craneLib.devShell {
checks = self.checks.${system};
};
});
}