From f768d214da9f2d83a18696265622efd9d8b57c1a Mon Sep 17 00:00:00 2001 From: Soispha Date: Sun, 9 Jul 2023 07:13:32 +0200 Subject: [PATCH] Build(flake): Initialize the flake A nix flake is a reproducible way to describe the building process to [nix](1). See [the nix download page](1), on how to install nix. Afterwards running `nix build` in the repository will result in a successful build. Flakes and nix-commands are still experimental so they must be enabled as described in [the corresponding wiki entry](2) [1]: https://nixos.org/download.html#nix [2]: https://nixos.wiki/wiki/Flakes#Enable_flakes. --- flake.lock | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 89 ++++++++++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f639470 --- /dev/null +++ b/flake.lock @@ -0,0 +1,132 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": [ + "flake-compat" + ], + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": [ + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1688772518, + "narHash": "sha256-ol7gZxwvgLnxNSZwFTDJJ49xVY5teaSvF7lzlo3YQfM=", + "owner": "ipetkov", + "repo": "crane", + "rev": "8b08e96c9af8c6e3a2b69af5a7fa168750fcf88e", + "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": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1688829822, + "narHash": "sha256-hv56yK1fPHPt7SU2DboxBtdSbIuv9nym7Dss7Cn2jic=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ed6afb10dfdfc97b6bcf0703f1bad8118e9e961b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688870171, + "narHash": "sha256-8tD8fheWPa7TaJoxzcU3iHkCrQQpOpdMN+HYqgZ1N5A=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "5a932f10ac4bd59047d6e8b5780750ec76ea988a", + "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..d6c1db1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,89 @@ +{ + description = "A terminal UI client for the matrix chat protocol"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + # inputs for following + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + crane = { + url = "github:ipetkov/crane"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-compat.follows = "flake-compat"; + flake-utils.follows = "flake-utils"; + rust-overlay.follows = "rust-overlay"; + }; + }; + flake-utils = { + url = "github:numtide/flake-utils"; + inputs = {}; + }; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + }; + + outputs = { + self, + nixpkgs, + crane, + flake-utils, + rust-overlay, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + overlays = [(import rust-overlay)]; + }; + + #rust-nightly = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default); + rust-stable = pkgs.rust-bin.stable.latest.default; + + craneLib = (crane.mkLib pkgs).overrideToolchain rust-stable; + + nativeBuildInputs = with pkgs; [ + pkg-config + ]; + buildInputs = with pkgs; [ + openssl + ]; + + craneBuild = craneLib.buildPackage { + src = craneLib.cleanCargoSource ./.; + + doCheck = true; + inherit nativeBuildInputs buildInputs; + }; + in { + packages.default = craneBuild; + + app.default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/trinitix"; + }; + + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + nil + alejandra + statix + ltex-ls + + rust-stable + rust-analyzer + cargo-edit + ]; + }; + }); +} +# vim: ts=2 +