summary refs log tree commit diff stats
path: root/flake.nix
blob: bc989d6c5ca3d6e418464c8bb8424577714b5c27 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# rocie - An enterprise grocery management system - Web app
#
# 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>.
{
  description = "rocie";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";

    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };
    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };
    crane.url = "github:ipetkov/crane";
  };

  outputs = {
    self,
    nixpkgs,
    treefmt-nix,
    rust-overlay,
    crane,
  }: let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      overlays = [(import rust-overlay)];
    };

    buildInputs = [
      pkgs.openssl
    ];

    nativeBuildInputs = [
      pkgs.pkg-config
    ];

    rust =
      pkgs.rust-bin.stable.latest.default.override {
          targets = ["wasm32-unknown-unknown"];
      };

    # NB: we don't need to overlay our custom toolchain for the *entire*
    # pkgs (which would require rebuidling anything else which uses rust).
    # Instead, we just want to update the scope that crane will use by appending
    # our specific toolchain there.
    craneLib = (crane.mkLib pkgs).overrideToolchain (
      p:
        p.rust-bin.stable.latest.default.override {
          targets = ["wasm32-unknown-unknown"];
        }
    );

    rocie = pkgs.callPackage ./nix/package.nix {inherit craneLib;};

    treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
  in {
    packages."${system}" = {
      inherit rocie;
      default = self.packages.${system}.rocie;
    };

    checks."${system}" = {
      inherit rocie;
      formatting = treefmtEval.config.build.check self;
    };

    formatter."${system}" = treefmtEval.config.build.wrapper;

    devShells."${system}".default = pkgs.mkShell {
      inherit buildInputs nativeBuildInputs;

      packages = [
        # rust stuff
        rust
        pkgs.mold

        pkgs.cargo-edit
        pkgs.cargo-expand
        pkgs.cargo-flamegraph

        # Mobile app
        pkgs.trunk
        pkgs.wasm-bindgen-cli
        pkgs.dart-sass
        pkgs.tailwindcss

        # Releng
        pkgs.git-bug
        pkgs.reuse
        pkgs.cocogitto
      ];
    };
  };
}