about summary refs log tree commit diff stats
path: root/flake.nix
blob: 687ca255b58f4957cf5d5a2ec477419e1aa6d21b (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
# Back - An extremely simple git bug visualization system. Inspired by TVL's
# panettone.
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This file is part of Back.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/agpl.txt>.
{
  description = "An extremely simple git bug visualization system. Inspired by TVL's panettone.";

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

    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };

    systems = {
      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
    };
    flake-utils = {
      url = "github:numtide/flake-utils";
      inputs = {
        systems.follows = "systems";
      };
    };
  };

  outputs = {
    self,
    nixpkgs,
    flake-utils,
    treefmt-nix,
    ...
  }: let
    pkgs = nixpkgs.legacyPackages."x86_64-linux";

    back = pkgs.callPackage ./nix/package.nix {};
    module = import ./nix/module.nix {extraPackages = {inherit back;};};
  in
    (flake-utils.lib.eachDefaultSystem (system: let
      treefmtEval = import ./treefmt.nix {
        inherit treefmt-nix pkgs;
      };

      nixos-lib = import (nixpkgs + "/nixos/lib") {};

      rustfmt = pkgs.writeShellScriptBin "rustfmt" ''
        # Avoid the duplicated edition flag, that rust-analyzer passes.
        if [ "$1" = "--edition" ] && [ "$2" == "2024" ]; then
            shift 2
        fi

        ${pkgs.lib.getExe pkgs.rustfmt} ${builtins.concatStringsSep " " treefmtEval.config.settings.formatter.rustfmt.options} "$@"
      '';
    in {
      checks = {
        formatting = treefmtEval.config.build.check self;
        nixos = pkgs.callPackage ./tests/base.nix {inherit module nixos-lib;};
      };

      formatter = treefmtEval.config.build.wrapper;

      packages = {
        inherit back;
        default = back;
      };

      devShells.default = pkgs.mkShell {
        packages = [
          pkgs.cocogitto
          pkgs.git-bug

          pkgs.rustc
          pkgs.cargo
          pkgs.clippy
          rustfmt
          pkgs.cargo-edit

          pkgs.reuse
        ];
      };
    }))
    // {
      nixosModules.default = module;
    };
}
# vim: ts=2