diff --git a/bestool.nix b/bestool.nix new file mode 100644 index 0000000..ddd6cb7 --- /dev/null +++ b/bestool.nix @@ -0,0 +1,25 @@ +{ lib +, pkgs ? import +, rustPlatform +, +}: +rustPlatform.buildRustPackage { + name = "bestool"; + + src = lib.cleanSource ./.; + + cargoLock = { + lockFile = ./Cargo.lock; + # Allow dependencies to be fetched from git and avoid having to set the outputHashes manually + 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/default.nix b/default.nix new file mode 100644 index 0000000..2cccff2 --- /dev/null +++ b/default.nix @@ -0,0 +1,10 @@ +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).defaultNix 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..a5ae183 --- /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; + }; + }; +}