summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 3d8d9a52a89caae219386a73eb9272660554276a (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
#──────────────────────────────────────────────────────────────────────────────┐
# 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/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
        
        # Build nixtamal package using the traditional nix-build approach
        # This preserves the existing build infrastructure
        nixtamalPkg = pkgs.callPackage ./nix/package/nixtamal.nix {
          # Override dependencies as needed
          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;
        };
      });
}