-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
158 lines (138 loc) · 5.12 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
description = "Determinate Nix";
inputs = {
nix.url = "https://flakehub.com/f/NixOS/nix/=2.24.10";
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*";
};
outputs = { self, nix, nixpkgs, ... }:
let
lib = nixpkgs.lib;
targetedSystems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
"i686-linux" # Not supported by Determinate Nix Installer
];
forSystems = s: f: lib.genAttrs s (system: f rec {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
});
forAllSystems = forSystems targetedSystems;
in
{
closures = forAllSystems ({ system, ... }: nix.packages."${system}".default);
tarballs_indirect = forAllSystems ({ system, ... }: nix.checks."${system}".binaryTarball);
tarballs_direct = forAllSystems ({ system, ... }: "${nix.checks."${system}".binaryTarball}/nix-${nix.packages."${system}".default.version}-${system}.tar.xz");
checks = forAllSystems ({ system, ... }: {
closure = nix.packages."${system}".default;
tarball = nix.checks."${system}".binaryTarball;
});
packages = forAllSystems ({ system, pkgs, ... }: {
default = nix.packages."${system}".default;
tarballs_json = pkgs.runCommand "tarballs.json"
{
buildInputs = [ pkgs.jq ];
passAsFile = [ "json" ];
json = builtins.toJSON (self.tarballs_direct);
} ''
cat "$jsonPath" | jq . > $out
'';
closures_json = pkgs.runCommand "versions.json"
{
buildInputs = [ pkgs.jq ];
passAsFile = [ "json" ];
json = builtins.toJSON (self.closures);
} ''
cat "$jsonPath" | jq . > $out
'';
closures_nix = pkgs.runCommand "versions.nix"
{
buildInputs = [ pkgs.jq ];
passAsFile = [ "template" ];
jsonPath = self.packages.${system}.closures_json;
template = ''
# Generated by https://github.com/DeterminateSystems/nix-upgrade based on the
# flake at https://flakehub.com/flake/NixOS/nix, which is a mirror of the
# upstream NixOS/nix project.
builtins.fromJSON('''@closures@''')
'';
} ''
export closures=$(cat "$jsonPath");
substituteAll "$templatePath" "$out"
'';
});
darwinModules.default = { lib, config, pkgs, ... }: {
nix = {
package = self.packages.${pkgs.stdenv.system}.default;
registry.nixpkgs = {
exact = true;
from = {
type = "indirect";
id = "nixpkgs";
};
to = {
type = "tarball";
url = "https://flakehub.com/f/DeterminateSystems/nixpkgs-weekly/0.1.0.tar.gz";
};
};
settings = {
always-allow-substitutes = true;
bash-prompt-prefix = "(nix:$name)\\040";
experimental-features = [ "nix-command" "flakes" ];
extra-nix-path = [ "nixpkgs=flake:nixpkgs" ];
upgrade-nix-store-path-url = "https://install.determinate.systems/nix-upgrade/stable/universal";
};
};
services.nix-daemon.enable = true;
};
nixosModules.default = { lib, config, pkgs, ... }: {
nix = {
package = self.packages.${pkgs.stdenv.system}.default;
registry.nixpkgs = {
exact = true;
from = {
type = "indirect";
id = "nixpkgs";
};
to = {
type = "tarball";
url = "https://flakehub.com/f/DeterminateSystems/nixpkgs-weekly/0.1.0.tar.gz";
};
};
settings = {
always-allow-substitutes = true;
bash-prompt-prefix = "(nix:$name)\\040";
experimental-features = [ "nix-command" "flakes" ];
extra-nix-path = [ "nixpkgs=flake:nixpkgs" ];
upgrade-nix-store-path-url = "https://install.determinate.systems/nix-upgrade/stable/universal";
};
};
};
homeModules.default = { lib, config, pkgs, ... }: {
nix = {
package = self.packages.${pkgs.stdenv.system}.default;
registry.nixpkgs = {
exact = true;
from = {
type = "indirect";
id = "nixpkgs";
};
to = {
type = "tarball";
url = "https://flakehub.com/f/DeterminateSystems/nixpkgs-weekly/0.1.0.tar.gz";
};
};
settings = {
# Note: home-manager configures the user's environment, so only set unrestricted Nix options.
bash-prompt-prefix = "(nix:$name)\\040";
experimental-features = [ "nix-command" "flakes" ];
extra-nix-path = [ "nixpkgs=flake:nixpkgs" ];
};
};
};
# homeModules is preferred but this ensures compatibility for anyone
# currently using nix.homeManagerModules.default in their config
homeManagerModules.default = self.homeModules.default;
};
}