From f1d2e59b89d1e0912fb74df7a2524670a76fb2c9 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Wed, 9 Aug 2023 18:21:45 -0700 Subject: [PATCH] Switch to flakes --- .envrc | 2 +- .gitignore | 1 + flake.lock | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 44 ++++++++++++++++++ shell.nix | 21 --------- 5 files changed, 175 insertions(+), 22 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.nix 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 ea8c4bf..2d5df85 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..962069c --- /dev/null +++ b/flake.lock @@ -0,0 +1,129 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "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": 1691472822, + "narHash": "sha256-XVfYZ2oB3lNPVq6sHCY9WkdQ8lHoIDzzbpg8bB6oBxA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "41c7605718399dcfa53dd7083793b6ae3bc969ff", + "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": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1691591308, + "narHash": "sha256-eeErUrPWCQwFHESL3vpNwkl8oyJPV6SRrVS9cPTEvYI=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "094512d7a7573ae2cb6db1a5ce4745a69b16fa46", + "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" + } + }, + "systems_2": { + "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..2331931 --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "Miscellaneous utility APIs hosted on jichan.org"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils }: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit overlays; + system = "x86_64-linux"; + }; + rustSettings = with pkgs; { + src = ./.; + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl ]; + cargoHash = nixpkgs.lib.fakeHash; + }; + in + with pkgs; rec { + devShells.x86_64-linux.default = mkShell { + packages = [ bacon ]; + inputsFrom = [ + packages.x86_64-linux.tatoeba + packages.x86_64-linux.images + ]; + }; + packages.x86_64-linux.tatoeba = rustPlatform.buildRustPackage (rustSettings // { + pname = "tatoeba"; + version = "0.1.0"; + buildAndTestSubdir = "tatoeba"; + cargoHash = "sha256-74Jq3saaUyPvNm/0croVOBuMtpN8xT3S4z37nutJdw4="; + }); + packages.x86_64-linux.images = rustPlatform.buildRustPackage (rustSettings // { + pname = "images"; + version = "0.1.0"; + buildAndTestSubdir = "images"; + cargoHash = "sha256-fKmTZTcJj/eYCQE9cjiXB/Pt6BdJNZ/e5cSRgbuPIJs="; + }); + }; +} 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 - ]; -}