summaryrefslogtreecommitdiff
path: root/templates/basic/flake.nix
blob: 1840cb154e0c64ffe2c47711122204c562ffe7c3 (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
{
  description = "";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
  };

  outputs =
    { self, nixpkgs, ... }:
    let
      systems = [
        "x86_64-linux"
        "aarch64-linux"
        "x86_64-darwin"
        "aarch64-darwin"
      ];

      forAllSystems = fn: nixpkgs.lib.genAttrs systems (sys: fn nixpkgs.legacyPackages.${sys});
      version = self.shortRev or self.dirtyShortRev or "unknown";
    in
    {
      devShells = forAllSystems (
        { pkgs, system, ... }:
        {
          default = pkgs.mkShell {
            packages = with pkgs; [ bash ];

            inputsFrom = [ self.packages.${system}.hello ];
          };
        }
      );

      formatter = forAllSystems (pkgs: pkgs.alejandra);

      packages = forAllSystems (
        { pkgs, system, ... }:
        {
          hello = pkgs.callPackage ./. { inherit version; };
          default = self.packages.${system}.hello;
        }
      );

      overlays.default = _: prev: { hello = prev.callPackage ./. { inherit version; }; };
    };
}