Merge pull request 'Add Nix flake. :3' (#1) from doll154621/addflake into mistress

yay :3

Reviewed-on: https://git.gay/ika4422/dolltool/pulls/1
This commit is contained in:
jaiden 2026-07-28 01:29:06 +02:00 • committed by git.gay
commit 4fb78242ae
No known key found for this signature in database
GPG key ID: BDA2A7586B5E1432
2 changed files with 75 additions and 0 deletions

2
.gitignore vendored
View file

@ -5,3 +5,5 @@ pkg/*.pkg.tar.zst
pkg/*.tar.gz
pkg/pkg/
pkg/src/
result/
flake.lock

73
flake.nix Normal file
View file

@ -0,0 +1,73 @@
{
description = "A simple dollcode encoder, decoder, and generator inside your terminal :3";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, crane, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
craneLib = crane.mkLib pkgs;
# Common build inputs / env shared across derivations.
# crane's default cargo source filter drops LICENSE, but main.rs does
# `include_str!("../LICENSE")`, so we keep it alongside cargo sources.
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
craneLib.filterCargoSources path type
|| baseNameOf path == "LICENSE";
};
strictDeps = true;
};
# Build *just* the dependencies so they can be cached and reused
# across source changes. (Edition 2024 needs Rust >= 1.85, which
# nixpkgs-unstable ships by default.)
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
dolltool = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
doCheck = true;
});
in
{
packages = {
default = dolltool;
inherit dolltool;
};
apps.default = flake-utils.lib.mkApp {
drv = dolltool;
name = "dolltool";
};
devShells.default = pkgs.mkShell {
inputsFrom = [ dolltool ];
packages = with pkgs; [
rustc
cargo
cargo-edit
rustfmt
clippy
];
};
checks = {
inherit dolltool;
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
fmt = craneLib.cargoFmt (commonArgs // {
inherit cargoArtifacts;
});
};
});
}