From 914d67a8ddb0ffa676da1530d64d3f391a17e56e Mon Sep 17 00:00:00 2001 From: Stephen D Date: Wed, 29 Jan 2025 17:14:22 -0500 Subject: [PATCH] nix packaging --- flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 32 ++++++++++++++++++++++++++ nix/package.nix | 26 +++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b639d44 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1738023785, + "narHash": "sha256-BPHmb3fUwdHkonHyHi1+x89eXB3kA1jffIpwPVJIVys=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2b4230bf03deb33103947e2528cac2ed516c5c89", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0630be5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + description = "Cargo wrapper that calls you a good girl if your commands succeed (but only after they fail)"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + packages = rec { + cargo-gg = pkgs.callPackage ./nix/package.nix { }; + default = cargo-gg; + }; + + devShells.default = pkgs.mkShell { + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + + inputsFrom = builtins.attrValues self.packages.${system}; + nativeBuildInputs = [ + pkgs.rustfmt + pkgs.clippy + ]; + }; + } + ); +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..cbd2b51 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,26 @@ +{ + lib, + rustPlatform, + protobuf, +}: +let + ignoredPaths = [ + "nix" + "flake.nix" + "flake.lock" + ]; +in +rustPlatform.buildRustPackage { + pname = "cargo-gg"; + version = "0.1.1"; + + src = lib.cleanSourceWith { + filter = name: _: !(builtins.elem (baseNameOf name) ignoredPaths); + src = lib.cleanSource ../.; + }; + cargoLock.lockFile = ../Cargo.lock; + + # skips rebuilding the whole thing with debug info + doCheck = false; +} +