aboutsummaryrefslogtreecommitdiff
path: root/hw/clef/flake.nix
blob: f20b1b861490050f140134737a594def03c934b3 (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
# vim: ft=nix :
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
    flake-utils.url = "github:numtide/flake-utils/main";
    nix-filter.url = "github:numtide/nix-filter/main";

    cq = {
      url = "github:vinszent/cq-flake/main";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-utils.follows = "flake-utils";
    };
  };

  description = "clef: kicad shared data and utils";

  outputs = { self, nixpkgs, flake-utils, ... } @ inputs: (flake-utils.lib.eachDefaultSystem (system: {
      packages = let
        packages = nixpkgs.legacyPackages.${system}.callPackages ./nix/pkgs {};

        pkgs = import nixpkgs {
          inherit system;

          overlays = with self.overlays; [
            kicad
            nix-filter

            (final: prev: packages)
          ];
        };

        clef = pkgs.callPackage ./nix;
      in packages // {
        inherit clef;
        default = clef;
      };

      devShells.default = let 
        pkgs = import nixpkgs {
          inherit system;

          overlays = with self.overlays; [
            kicad
          ];
        };

      in pkgs.mkShell {
        name = "devshell";
        version = self.rev or "dirty";

        packages = with pkgs; [
          kicad
          kikit
        ];
      };
    }
  )) // {
    overlays = let
      base = (import ./overlays.nix { inherit inputs; });

    in base // {
      # clef built against its own nixpkgs import with its required overlay
      # deps (kicad, occt).
      # 
      # _This will cause another evaluation of nixpkgs_, which is generally
      # undesirable. However, this provides for the most hassle-free way to
      # use clef, as you don't need to include all of the overlay dependencies
      # in your nixpkgs.
      default = final: prev: {
        inherit (self.packages.${prev.system}) clef;
      };

      # No overlay dependencies included -- clef will not work by default.
      # You can replicate overlays.default with:
      #
      #   import nixpkgs { overlays = with clef.overlays; [ freestanding kicad nix-filter ]; }
      # 
      # Assuming you've pinned clef's nixpkgs to the same version as yours.
      # This functionality is provided to give you an option
      freestanding = final: prev: (prev.callPackage ./nix/pkgs {}) {
        clef = prev.callPackage ./nix;
      };
    };
  };
}