diff --git a/README.md b/README.md index e09a948..d88f8a0 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,24 @@ Or just the package, without the repository and so without updates: the `.deb` files are on the [release page](https://github.com/clainstone/cbirds/releases/latest), for `sudo apt install ./cbirds_*.deb`. +### Nix flake + +Linux on x86_64 and aarch64, macOS on Apple silicon. With Nix and the +`nix-command` and `flakes` experimental features enabled, run directly from +this repository: + +```sh +nix run github:clainstone/cbirds +``` + +Pass cbirds options after `--`, for example for sprites in Kitty or Ghostty: + +```sh +nix run github:clainstone/cbirds -- --render kitty --hawks 2 --color ice +``` + +From a local checkout of this repository, use `nix run .`. + ### From source ``` diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..416bfe1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1791456040, + "narHash": "sha256-H83yz/do+hjOO0uujHyH8RgtIQP2v7Mw+cLwcZK/xKc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e7439b6b14ad3cc35d05608ebca9bce01a25f5f8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "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..9d08e1b --- /dev/null +++ b/flake.nix @@ -0,0 +1,59 @@ +{ + description = "A flock of birds in your terminal"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + # The version cbirds --version prints, so it moves with each release + version = nixpkgs.lib.pipe ./boids.c [ + builtins.readFile + (nixpkgs.lib.splitString "\n") + (map (builtins.match "#define CBIRDS_VERSION \"(.*)\"")) + (nixpkgs.lib.findFirst (m: m != null) null) + builtins.head + ]; + in + { + packages = forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = self.packages.${system}.cbirds; + + cbirds = pkgs.stdenv.mkDerivation { + pname = "cbirds"; + inherit version; + src = pkgs.lib.cleanSource self; + + nativeBuildInputs = [ pkgs.installShellFiles ]; + makeFlags = [ "PREFIX=$(out)" ]; + + doCheck = true; + checkTarget = "test"; + + postInstall = '' + installShellCompletion --cmd cbirds \ + --bash <($out/bin/cbirds --completion bash) \ + --zsh <($out/bin/cbirds --completion zsh) \ + --fish <($out/bin/cbirds --completion fish) + ''; + + meta = { + description = "A flock of birds in your terminal"; + homepage = "https://github.com/clainstone/cbirds"; + license = pkgs.lib.licenses.mit; + mainProgram = "cbirds"; + platforms = systems; + }; + }; + }); + }; +}