about summary refs log tree commit diff stats
path: root/nix/package.nix
blob: 11dcddf98d1cd0b3840f11d8bb74b7795f3d8d17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# rocie - An enterprise grocery management system
#
# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# Copyright (C) 2026 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of Rocie.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
  lib,
  rustPlatform,
  # nativeBuildInputs
  pkg-config,
  sqlite,
  fd,
}:
rustPlatform.buildRustPackage (finalAttrs: {
  pname = "rocie-server";
  inherit
    ((builtins.fromTOML (builtins.readFile
          ../Cargo.toml)).workspace.package)
    version
    ;

  src = lib.cleanSourceWith {
    src = lib.cleanSource ./..;
    filter = name: type:
      (type == "directory")
      || (builtins.elem (builtins.baseNameOf name) [
        "Cargo.toml"
        "Cargo.lock"
        "mkdb.sh"
      ])
      || (lib.strings.hasSuffix ".rs" (builtins.baseNameOf name))
      || (lib.strings.hasSuffix ".sql" (builtins.baseNameOf name));
  };

  nativeBuildInputs = [
    pkg-config

    # Needed for the `mkdb.sh`
    sqlite
    fd
  ];

  buildInputs = [
    sqlite.dev
  ];

  checkInputs = [
  ];

  env = {
    # Needed for the compile time sqlite checks.
    DATABASE_URL = "sqlite://database.sqlx";
  };

  doCheck = true;

  prePatch = ''
    # Generate the sqlite db, so that we can run the comp-time sqlite checks.
    bash ./scripts/mkdb.sh
  '';

  cargoLock = {
    lockFile = ../Cargo.lock;
  };

  meta = {
    mainProgram = "rocie-server";
  };
})