Skip to content

Commit

Permalink
build: add nix flake (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: uncenter <47499684+uncenter@users.noreply.github.com>
  • Loading branch information
isabelroses and uncenter authored Feb 7, 2024
1 parent 0da638d commit 86507f1
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
target/
result/
22 changes: 22 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
pkgs ? import <nixpkgs> {},
lib ? pkgs.lib,
version ? "latest",
...
}:
pkgs.rustPlatform.buildRustPackage {
pname = "kittysay";
inherit version;

src = ./.;
cargoLock.lockFile = ./Cargo.lock;

doCheck = false;

meta = with lib; {
description = "The cutest successor of cowsay.";
homepage = "https://github.com/uncenter/kittysay";
license = licenses.mit;
maintainers = [maintainers.uncenter];
};
}
27 changes: 27 additions & 0 deletions flake.lock

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

24 changes: 24 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
description = "kittysay";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";

outputs = {
self,
nixpkgs,
...
}: let
forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin"];
pkgsForEach = nixpkgs.legacyPackages;
version = self.shortRev or "dirty";
in {
packages = forAllSystems (system: rec {
default = pkgsForEach.${system}.callPackage ./default.nix {inherit version;};
kittysay = default;
});

devShells = forAllSystems (system: {
default = pkgsForEach.${system}.callPackage ./shell.nix {};
});
};
}
17 changes: 17 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
callPackage,
rust-analyzer,
rustfmt,
clippy,
}: let
mainPkg = callPackage ./default.nix {version = "debug";};
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs =
[
rust-analyzer
rustfmt
clippy
]
++ (oa.nativeBuildInputs or []);
})

0 comments on commit 86507f1

Please sign in to comment.