Skip to content

Commit

Permalink
Add Nix and Flakes support
Browse files Browse the repository at this point in the history
Split off from the refactor branch.

Signed-off-by: Dom Rodriguez <[email protected]>
  • Loading branch information
shymega committed Feb 17, 2024
1 parent 3ec6244 commit 066e45d
Show file tree
Hide file tree
Showing 4 changed files with 154 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;
};
}
10 changes: 10 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -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
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 066e45d

Please sign in to comment.