summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 115a9d10cf593b5bd949a5dba433b0d5db9a0386 (plain)
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
#──────────────────────────────────────────────────────────────────────────────┐
# SPDX-FileCopyrightText: 2025 toastal <https://toast.al/contact/>             │
# SPDX-License-Identifier: LGPL-2.1-or-later                                   │
#──────────────────────────────────────────────────────────────────────────────┘
{
  description = "Nixtamal - A Nix version pinning tool with first-class support for Darcs, Pijul, and other VCS systems";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/16c7794d0a28b5a37904d55bcca36003b9109aaa";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [
            (import ./nix/overlay/default.nix)
            (import ./nix/overlay/development.nix)
            (import ./nix/overlay/check.nix)
          ];
        };
        
        # Build nixtamal package using callPackage
        nixtamalPkg = pkgs.callPackage ./nix/package/nixtamal.nix {
          nixtamal = null; # Prevent infinite recursion
        };
        
        # Development shell using the same approach as shell.nix
        devShell = pkgs.mkShell {
          buildInputs = nixtamalPkg.buildInputs or [];
          nativeBuildInputs = nixtamalPkg.nativeBuildInputs or [];
        };
      in
      {
        # Package outputs
        packages = {
          nixtamal = nixtamalPkg;
          default = nixtamalPkg;
        };

        # Development shell
        devShells.default = devShell;

        # Test suite integration
        checks = {
          # Basic check that the package builds
          nixtamal-build = nixtamalPkg;
        };

        # Library outputs for ecosystem integration
        lib = {
          # Expose the nixtamal package for flake consumption
          nixtamal = nixtamalPkg;
          
          # Helper functions for hybrid workflows
          makeHybridInputs = { 
            extraInputs ? {}
          }: {
            inherit nixtamalPkg;
          } // extraInputs;

          # Utility to create flake-compatible inputs from nixtamal projects
          fromNixtamalProject = projectPath: 
            import (projectPath + "/nix/tamal") { 
              inherit system; 
              nixpkgs = pkgs;
            };
        };

        # App output for running nixtamal directly
        apps = {
          nixtamal = {
            type = "app";
            program = "${nixtamalPkg}/bin/nixtamal";
          };
          default = self.apps.${system}.nixtamal;
        };
      });
}