From 5a15c0e9e7e70be872e274a6cf776c95390f1607 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 10 Apr 2021 03:24:44 +0200 Subject: [PATCH] flake: setup flake.nix --- .gitignore | 1 + flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index ea8c4bf..d787b70 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..53b953b --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1606424373, + "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1617631617, + "narHash": "sha256-PARRCz55qN3gy07VJZIlFeOX420d0nGF0RzGI/9hVlw=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b2c27d1a81b0dc266270fa8aeecebbd1807fc610", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1617929752, + "narHash": "sha256-ji0nqJUZp2bfHvO0sKxD24cW6Nk7LyjbPPMxjbJHji0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6fc2b7ecc2a167ce6a6902d5417daf1fa5cac777", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7779985 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + defaultPackage = pkgs.rustPlatform.buildRustPackage { + pname = "bad-news"; + version = "0.1.0"; + + src = ./.; + + cargoSha256 = "sha256-nWEWOY1F0TsVW5DHm2p8eOABF97Wku7Grw0Vsd79syU="; + + meta = with pkgs.lib; { + description = "A Matrix bot, bringer of bad news"; + homepage = "https://github.com/alarsyo/bad-news"; + license = with licenses; [ mit asl20 ]; + platforms = platforms.unix; + }; + + nativeBuildInputs = with pkgs; [ pkg-config cmake ]; + buildInputs = with pkgs; [ systemd openssl ]; + }; + + defaultApp = flake-utils.lib.mkApp { + drv = self.defaultPackage."${system}"; + }; + + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + cargo + clippy + nixpkgs-fmt + rustPackages.clippy + rustc + rustfmt + + pkg-config + cmake + systemd + openssl + ]; + + RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; + }; + }); +}