From 789ccd6d14d911c6caf9e87d29595b6324168a96 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 17 Feb 2024 23:02:23 +0000 Subject: [PATCH] Add Nix Flakes support to project This commit adds support for Nix Flakes. Signed-off-by: Dom Rodriguez --- .bestool.nix | 24 ++++++++++++++++ flake.lock | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 41 +++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 .bestool.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.bestool.nix b/.bestool.nix new file mode 100644 index 0000000..728aab9 --- /dev/null +++ b/.bestool.nix @@ -0,0 +1,24 @@ +{ lib +, pkgs ? import +, rustPlatform +, +}: +rustPlatform.buildRustPackage { + name = "bestool"; + + src = lib.cleanSource ./bestool; + + cargoLock = { + lockFile = ./bestool/Cargo.lock; + allowBuiltinFetchGit = true; + }; + + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ systemd.dev ]; + + meta = with lib; { + description = ""; + homepage = "https://github.com/Ralim/bestool"; + license = licenses.mit; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c53e5e4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,78 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708001613, + "narHash": "sha256-woOmAXW05XnqlLn7dKzCkRAEOSOdA/Z2ndVvKcjid94=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "085589047343aad800c4d305cf7b98e8a3d51ae2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7285a56 --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + 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 = nixpkgs.outputs.legacyPackages.${system}; + in + { + packages.bestool = pkgs.callPackage ./.bestool.nix { }; + packages.default = self.outputs.packages.${system}.bestool; + + devShells.default = self.packages.${system}.default.overrideAttrs (super: { + nativeBuildInputs = with pkgs; + super.nativeBuildInputs + ++ [ + cargo-edit + clippy + rustfmt + ]; + RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; + }); + }) + // { + overlays.default = final: prev: { + inherit (self.packages.${final.system}) bestool; + }; + }; +}