-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathflake.nix
More file actions
110 lines (99 loc) · 4.27 KB
/
flake.nix
File metadata and controls
110 lines (99 loc) · 4.27 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#
# Nix flake.
#
# https://nix.dev/manual/nix/latest/command-ref/new-cli/nix3-flake#flake-format
# https://wiki.nixos.org/wiki/Flakes#Flake_schema
#
{
description = "Nix flake.";
inputs = {
# https://nixos.org/manual/nixpkgs/unstable
# https://search.nixos.org/packages?channel=unstable
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "refs/heads/nixos-unstable";
};
};
outputs =
inputs:
let
# Output systems.
#
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/lib/systems/flake-systems.nix
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
# Return an attribute set of system to the result of applying `f`.
#
# https://nixos.org/manual/nixpkgs/unstable#function-library-lib.attrsets.genAttrs
genSystemAttrs = f: inputs.nixpkgs.lib.attrsets.genAttrs systems f;
# Override inputs.
#
# https://nixos.org/manual/nixpkgs/unstable#function-library-lib.attrsets.recursiveUpdate
finalInputs = inputs.nixpkgs.lib.attrsets.recursiveUpdate inputs {
nixpkgs = {
# https://nixos.org/manual/nixpkgs/unstable#function-library-lib.attrsets.mapAttrs
legacyPackages = inputs.nixpkgs.lib.attrsets.mapAttrs (
localSystem: packages:
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/top-level/default.nix
import inputs.nixpkgs {
inherit localSystem;
overlays = [
inputs.self.overlays.default
];
}
) inputs.nixpkgs.legacyPackages;
};
};
in
{
# ────────────────────────────────────────────────────────────────────────────────────────────────────
#
# System-agnostic outputs.
#
# ────────────────────────────────────────────────────────────────────────────────────────────────────
# Overlays.
#
# Include dependency overlays with `inputs.nixpkgs.lib.fixedPoints.composeManyExtensions`.
#
# https://nixos.org/manual/nixpkgs/unstable#function-library-lib.fixedPoints.composeManyExtensions
overlays = {
default = final: prev: {
multi-storage-client = {
# Expose packages for other systems to support cross-compilation in development shells (e.g. macOS SDK).
nativePackages = finalInputs.nixpkgs.legacyPackages;
packages = final.lib.filesystem.packagesFromDirectoryRecursive {
inherit (final) callPackage;
directory = ./nix/packages;
};
devShells = final.lib.filesystem.packagesFromDirectoryRecursive {
inherit (final) callPackage;
directory = ./nix/devShells;
};
};
};
};
# ────────────────────────────────────────────────────────────────────────────────────────────────────
#
# System-specific outputs.
#
# ────────────────────────────────────────────────────────────────────────────────────────────────────
# Packages.
#
# For `nix build`.
packages = genSystemAttrs (
system: finalInputs.nixpkgs.legacyPackages.${system}.multi-storage-client.packages
);
# Development shells.
#
# For `nix develop` and direnv's `use flake`.
devShells = genSystemAttrs (
system: finalInputs.nixpkgs.legacyPackages.${system}.multi-storage-client.devShells
);
};
}