From 03f35f0b355e7a1065d677caf2bde922a0613ecf Mon Sep 17 00:00:00 2001 From: Doll154621 <154621@softkittypa.ws> Date: Mon, 27 Jul 2026 21:20:57 +1000 Subject: [PATCH] Add Nix flake. :3 --- .gitignore | 2 ++ flake.nix | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index f5064dd..c744ab9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ pkg/*.pkg.tar.zst pkg/*.tar.gz pkg/pkg/ pkg/src/ +result/ +flake.lock diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..96520ea --- /dev/null +++ b/flake.nix @@ -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; + }); + }; + }); +} \ No newline at end of file