-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
70 lines (67 loc) · 2.38 KB
/
flake.nix
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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
xc = {
url = "github:joerdav/xc";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, xc, ... }:
let
pkgsForSystem = system: import nixpkgs {
inherit system;
overlays = [
(final: prev: { xc = xc.packages.${system}.xc; })
];
};
flakeClosureRefForSystem = { system, pkgs }: (import ./flakeClosureRef.nix {
pkgs = pkgs;
lib = nixpkgs.lib;
});
listFlakeInputsForSystem = { system, pkgs }: pkgs.writeShellScriptBin "list-flake-inputs" ''
cat ${((flakeClosureRefForSystem { inherit system pkgs; }) self)}
'';
allSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
system = system;
pkgs = pkgsForSystem system;
});
in
{
# Add the flake input reference to the output set so that we can see it in the repl.
#
# Load the repl with:
# nix repl
# Inside the repl, load the flake:
# :lf .
# View the derivation:
# outputs.flakeInputReference.x86_64-linux
# Then build it.
# :b outputs.flakeInputReference.x86_64-linux
#
# The store path will be printed.
#
# cat the store path to see the contents. If you inspect the directories, you'll see
# that the directories contain the source code of all flake inputs.
flakeInputReference = forAllSystems ({ system, pkgs }: {
default = ((flakeClosureRefForSystem { inherit system pkgs; }) self);
});
# `nix develop` provides a shell containing development tools.
devShells = forAllSystems ({ system, pkgs }: {
default = pkgs.mkShell {
buildInputs = [
# Bring in xc as an overlay applied within pkgsForSystem.
# So instead of xc.packages.${system}.xc, we can use pkgs.xc.
pkgs.xc
# Ensure that the recursive tree of flake inputs are added to the Nix store.
# You can list the flake inputs with the `list-flake-inputs` command.
(listFlakeInputsForSystem { inherit system pkgs; })
];
};
});
};
}