From 4d650c1566f0a4df4bd5e3fbcc647c2970246063 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 27 Jun 2024 00:07:12 +0300 Subject: [PATCH] add nix derivation and flake --- .gitignore | 1 + default.nix | 9 +++++ flake.lock | 61 +++++++++++++++++++++++++++++ flake.nix | 17 ++++++++ src/api/add_snapshot.rs | 1 + src/api/add_version.rs | 1 + src/api/get_child_version.rs | 1 + src/api/get_snapshot.rs | 1 + src/bin/taskchampion-sync-server.rs | 1 + src/lib.rs | 1 + src/server.rs | 1 + 11 files changed, 95 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 2f7896d..ff69d57 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target/ +result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..c546fb7 --- /dev/null +++ b/default.nix @@ -0,0 +1,9 @@ +{ lib, rustPlatform }: +rustPlatform.buildRustPackage rec { + pname = "taskchampion-sync-server"; + version = "0.4.1"; + + src = lib.cleanSource ./.; + + cargoHash = "sha256-UvVAZX8cfGO3twpBZ0nC6MQ01vcUtbDqJj3QZDqz+rs="; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..220acad --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1719253556, + "narHash": "sha256-A/76RFUVxZ/7Y8+OMVL1Lc8LRhBxZ8ZE2bpMnvZ1VpY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "fc07dc3bdf2956ddd64f24612ea7fc894933eb2e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "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..34244fe --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + description = "Fork of taskchampion-sync-server"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem(system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + packages.default = pkgs.callPackage ./. { }; + }); +} diff --git a/src/api/add_snapshot.rs b/src/api/add_snapshot.rs index c6ff011..7387ec3 100644 --- a/src/api/add_snapshot.rs +++ b/src/api/add_snapshot.rs @@ -82,6 +82,7 @@ pub(crate) async fn service( } #[cfg(test)] +#[cfg(debug_assertions)] mod test { use super::*; use crate::api::CLIENT_ID_HEADER; diff --git a/src/api/add_version.rs b/src/api/add_version.rs index 82359a4..2179a56 100644 --- a/src/api/add_version.rs +++ b/src/api/add_version.rs @@ -111,6 +111,7 @@ pub(crate) async fn service( } #[cfg(test)] +#[cfg(debug_assertions)] mod test { use crate::api::CLIENT_ID_HEADER; use crate::storage::{InMemoryStorage, Storage}; diff --git a/src/api/get_child_version.rs b/src/api/get_child_version.rs index cb0e74f..1a0a3b4 100644 --- a/src/api/get_child_version.rs +++ b/src/api/get_child_version.rs @@ -55,6 +55,7 @@ pub(crate) async fn service( } #[cfg(test)] +#[cfg(debug_assertions)] mod test { use crate::api::CLIENT_ID_HEADER; use crate::server::NIL_VERSION_ID; diff --git a/src/api/get_snapshot.rs b/src/api/get_snapshot.rs index 4135257..5049c66 100644 --- a/src/api/get_snapshot.rs +++ b/src/api/get_snapshot.rs @@ -40,6 +40,7 @@ pub(crate) async fn service( } #[cfg(test)] +#[cfg(debug_assertions)] mod test { use crate::api::CLIENT_ID_HEADER; use crate::storage::{InMemoryStorage, Snapshot, Storage}; diff --git a/src/bin/taskchampion-sync-server.rs b/src/bin/taskchampion-sync-server.rs index f99304c..3de9157 100644 --- a/src/bin/taskchampion-sync-server.rs +++ b/src/bin/taskchampion-sync-server.rs @@ -102,6 +102,7 @@ async fn main() -> anyhow::Result<()> { } #[cfg(test)] +#[cfg(debug_assertions)] mod test { use super::*; use actix_web::{test, App}; diff --git a/src/lib.rs b/src/lib.rs index 5ba4658..3db5549 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,6 +45,7 @@ impl Server { } #[cfg(test)] +#[cfg(debug_assertions)] mod test { use super::*; use crate::storage::InMemoryStorage; diff --git a/src/server.rs b/src/server.rs index 01dcc73..9fc74a1 100644 --- a/src/server.rs +++ b/src/server.rs @@ -309,6 +309,7 @@ pub(crate) fn get_snapshot<'a>( } #[cfg(test)] +#[cfg(debug_assertions)] mod test { use super::*; use crate::storage::{InMemoryStorage, Snapshot, Storage};