Skip to content

Commit

Permalink
Add Nix Flakes support to project
Browse files Browse the repository at this point in the history
This commit adds support for Nix Flakes.

Signed-off-by: Dom Rodriguez <[email protected]>
  • Loading branch information
shymega committed Feb 17, 2024
1 parent 3ec6244 commit 0af7510
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .bestool.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ lib
, pkgs ? import <nixpkgs>
, 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;
};
}
78 changes: 78 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
}

0 comments on commit 0af7510

Please sign in to comment.