From 69243d4735e8dfb5a842c5772cf0c62983c7e7d9 Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 7 Feb 2024 11:18:35 +0000 Subject: [PATCH 1/8] feat: nix flake --- default.nix | 10 ++++++++++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 19 +++++++++++++++++++ shell.nix | 17 +++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..d8d5621 --- /dev/null +++ b/default.nix @@ -0,0 +1,10 @@ +{pkgs ? import {}}: +pkgs.rustPlatform.buildRustPackage { + pname = "kittysay"; + version = "0.2.0"; + + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + + doCheck = false; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a3468a9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1707091808, + "narHash": "sha256-LahKBAfGbY836gtpVNnWwBTIzN7yf/uYM/S0g393r0Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9f2ee8c91ac42da3ae6c6a1d21555f283458247e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..65f5193 --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "kittysay"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + + outputs = {nixpkgs, ...}: let + forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin"]; + pkgsForEach = nixpkgs.legacyPackages; + in { + packages = forAllSystems (system: { + default = pkgsForEach.${system}.callPackage ./default.nix {}; + kittysay = pkgsForEach.${system}.callPackage ./default.nix {}; + }); + + devShells = forAllSystems (system: { + default = pkgsForEach.${system}.callPackage ./shell.nix {}; + }); + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..dae9471 --- /dev/null +++ b/shell.nix @@ -0,0 +1,17 @@ +{ + callPackage, + rust-analyzer, + rustfmt, + clippy, +}: let + mainPkg = callPackage ./default.nix {}; +in + mainPkg.overrideAttrs (oa: { + nativeBuildInputs = + [ + rust-analyzer + rustfmt + clippy + ] + ++ (oa.nativeBuildInputs or []); + }) From 439845cae4c0b956497f9ffbc6e7ab5be1c744f2 Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 7 Feb 2024 20:38:45 +0000 Subject: [PATCH 2/8] chore: update version number --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index d8d5621..cf4da48 100644 --- a/default.nix +++ b/default.nix @@ -1,7 +1,7 @@ {pkgs ? import {}}: pkgs.rustPlatform.buildRustPackage { pname = "kittysay"; - version = "0.2.0"; + version = "0.3.0"; src = ./.; cargoLock.lockFile = ./Cargo.lock; From ddcd47ccbf0db49af4b0ba8196cc6c91fcbbceb6 Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 7 Feb 2024 20:39:11 +0000 Subject: [PATCH 3/8] feat: add meta data --- default.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index cf4da48..974594f 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,8 @@ -{pkgs ? import {}}: +{ + pkgs ? import {}, + lib ? pkgs.lib, + ... +}: pkgs.rustPlatform.buildRustPackage { pname = "kittysay"; version = "0.3.0"; @@ -7,4 +11,11 @@ pkgs.rustPlatform.buildRustPackage { 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]; + }; } From b75b5ace6d3285041b3ea86e390c68ae663b0931 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:50:08 -0500 Subject: [PATCH 4/8] fix: meta.description punctuation --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 974594f..f93b019 100644 --- a/default.nix +++ b/default.nix @@ -13,7 +13,7 @@ pkgs.rustPlatform.buildRustPackage { doCheck = false; meta = with lib; { - description = "The cutest successor of cowsay"; + description = "The cutest successor of cowsay."; homepage = "https://github.com/uncenter/kittysay"; license = licenses.mit; maintainers = [maintainers.uncenter]; From ad01b7d24538a85b8600f4e3a1c76b5fbf4f340c Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 7 Feb 2024 21:06:39 +0000 Subject: [PATCH 5/8] chore(git): ignore nix build artifacts --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ea8c4bf..07c12f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +result From b017002bca8ad7eb3333a8ef8cf5a3949f3d1236 Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 7 Feb 2024 21:11:23 +0000 Subject: [PATCH 6/8] style(gitignore): format directories with trailing slashes --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 07c12f2..fc41f92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/target -result +target/ +result/ From 69a56b391272bb8da26a5c9bc46309547d3764d4 Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 7 Feb 2024 21:47:04 +0000 Subject: [PATCH 7/8] refactor: use autogen versioning --- default.nix | 3 ++- flake.nix | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/default.nix b/default.nix index f93b019..8c55271 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,12 @@ { pkgs ? import {}, lib ? pkgs.lib, + version ? "latest", ... }: pkgs.rustPlatform.buildRustPackage { pname = "kittysay"; - version = "0.3.0"; + inherit version; src = ./.; cargoLock.lockFile = ./Cargo.lock; diff --git a/flake.nix b/flake.nix index 65f5193..d76a009 100644 --- a/flake.nix +++ b/flake.nix @@ -3,13 +3,18 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; - outputs = {nixpkgs, ...}: let + 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: { - default = pkgsForEach.${system}.callPackage ./default.nix {}; - kittysay = pkgsForEach.${system}.callPackage ./default.nix {}; + packages = forAllSystems (system: rec { + default = pkgsForEach.${system}.callPackage ./default.nix {inherit version;}; + kittysay = default; }); devShells = forAllSystems (system: { From df26c95ea846294c97ed9a1380d78d7638618328 Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 7 Feb 2024 21:57:29 +0000 Subject: [PATCH 8/8] chore(nix-shell): ensure users know they are using a dev build --- shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index dae9471..c66ca80 100644 --- a/shell.nix +++ b/shell.nix @@ -4,7 +4,7 @@ rustfmt, clippy, }: let - mainPkg = callPackage ./default.nix {}; + mainPkg = callPackage ./default.nix {version = "debug";}; in mainPkg.overrideAttrs (oa: { nativeBuildInputs =