diff --git a/.envrc b/.envrc index 1d953f4..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use nix +use flake diff --git a/.gitignore b/.gitignore index 5932a3b..f5dff47 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ .env guilds.json *.old +.direnv +result \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9a04ea5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1692913444, + "narHash": "sha256-1SvMQm2DwofNxXVtNWWtIcTh7GctEVrS/Xel/mdc6iY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18324978d632ffc55ef1d928e81630c620f4f447", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1692929460, + "narHash": "sha256-zdN6UVtEml7t0WQHVy0avsE+TWJLklXnqJyiPaOa8u0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "673e2d3d2a3951adc6f5e3351c9fce6ad130baed", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "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..0041cc5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +/* +Some utility commands: +- `nix flake update --commit-lock-file` +- `nix flake lock update-input ` +- `nix build .#ji-chan` or `nix build .` +- `nix run .#ji-chan` or `nix run .` +*/ + +{ + description = "Discord bot for the Tegaki Tuesday handwriting challenge"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + + outputs = { self, nixpkgs, rust-overlay }: + let + overlays = [ (import rust-overlay) ]; + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system overlays; + }; + in { + devShells.${system}.default = with pkgs; mkShell { + packages = [ + (pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" ]; + }) + cargo-edit + bacon + ]; + inputsFrom = with self.packages.${system}; [ ji-chan ]; + }; + packages.${system} = { + default = self.packages.${system}.ji-chan; + ji-chan = pkgs.rustPlatform.buildRustPackage { + src = ./.; + pname = "ji-chan"; + version = "0.1.0"; + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ openssl ]; + cargoHash = "sha256-3I1fK+dZNVkzo+PAQiJaQdI7KrXUXZl7tWbK1dybpt8="; + meta = with nixpkgs.lib; { + homepage = "https://tegakituesday.com"; + description = "Discord bot for the Tegaki Tuesday handwriting challenge"; + license = [ licenses.gpl3 ]; + platforms = [ system ]; + maintainers = with maintainers; [ elnudev ]; + }; + }; + }; + }; +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index e04cd2a..0000000 --- a/shell.nix +++ /dev/null @@ -1,21 +0,0 @@ -# -{ pkgs ? import {}}: - -let - rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"); - pkgs = import { overlays = [ rust_overlay ]; }; - ruststable = (pkgs.rust-bin.stable.latest.default.override { - extensions = [ - "rust-src" - ]; - }); -in -pkgs.mkShell { - buildInputs = with pkgs; [ - ruststable - rust-analyzer - bacon - pkg-config - openssl - ]; -}