From 30f01f0e2018402c2a2c01e50d6d075f7acc80ec Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 9 Mar 2023 19:54:03 -0600 Subject: [PATCH] Add flake --- .gitignore | 2 ++ flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 21 +++++++++++++++++++++ pict-rs.nix | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 pict-rs.nix diff --git a/.gitignore b/.gitignore index c94c268..1c97d38 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /client-examples/javascript/node_modules /docker/object-storage/storage /docker/object-storage/pict-rs-garage.toml +/result +/.ash_history diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..44d8769 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678293141, + "narHash": "sha256-lLlQHaR0y+q6nd6kfpydPTGHhl1rS9nU9OQmztzKOYs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c90c4025bb6e0c4eaf438128a3b2640314b1c58d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..eefdbf6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,21 @@ +{ + description = "pict-rs"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + in + { + defaultPackage = pkgs.callPackage ./pict-rs.nix { + inherit (pkgs.darwin.apple_sdk.frameworks) Security; + }; + }); +} diff --git a/pict-rs.nix b/pict-rs.nix new file mode 100644 index 0000000..d3cfb34 --- /dev/null +++ b/pict-rs.nix @@ -0,0 +1,37 @@ +{ exiftool +, ffmpeg_5-full +, imagemagick +, lib +, makeWrapper +, nixosTests +, protobuf +, rustPlatform +, Security +, stdenv +}: + +rustPlatform.buildRustPackage { + pname = "pict-rs"; + version = "0.4.0-rc.1"; + src = ./.; + cargoSha256 = "Nsg386jz51jlQGTsmXFffzCrofUioHMEaiNwOuaOjKg="; + + PROTOC = "${protobuf}/bin/protoc"; + PROTOC_INCLUDE = "${protobuf}/include"; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = lib.optionals stdenv.isDarwin [ Security ]; + + postInstall = '' + wrapProgram $out/bin/pict-rs \ + --prefix PATH : "${lib.makeBinPath [ imagemagick ffmpeg_5-full exiftool ]}" + ''; + + passthru.tests = { inherit (nixosTests) pict-rs; }; + + meta = with lib; { + description = "A simple image hosting service"; + homepage = "https://git.asonix.dog/asonix/pict-rs"; + license = with licenses; [ agpl3Plus ]; + }; +}