-
Notifications
You must be signed in to change notification settings - Fork 74
/
flake.nix
159 lines (135 loc) · 5.06 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
159
{
description = "Nix-enabled environment for your Android device";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
# for bootstrap zip ball creation and proot-termux builds, we use a fixed version of nixpkgs to ease maintanence.
# head of nixos-24.05 as of 2024-07-06
# note: when updating nixpkgs-for-bootstrap, update store paths of proot-termux in modules/environment/login/default.nix
nixpkgs-for-bootstrap.url = "github:NixOS/nixpkgs/49ee0e94463abada1de470c9c07bfc12b36dcf40";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-formatter-pack = {
url = "github:Gerschtli/nix-formatter-pack";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nmd.follows = "nmd";
};
nixpkgs-docs.url = "github:NixOS/nixpkgs/release-23.05";
nmd = {
url = "sourcehut:~rycee/nmd";
inputs.nixpkgs.follows = "nixpkgs-docs";
};
};
outputs = { self, nixpkgs, nixpkgs-for-bootstrap, home-manager, nix-formatter-pack, nmd, nixpkgs-docs }:
let
forEachSystem = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
overlay = nixpkgs.lib.composeManyExtensions (import ./overlays);
formatterPackArgsFor = forEachSystem (system: {
inherit nixpkgs system;
checkFiles = [ ./. ];
config.tools = {
deadnix = {
enable = true;
noLambdaPatternNames = true;
};
nixpkgs-fmt.enable = true;
statix.enable = true;
};
});
in
{
apps = forEachSystem (system: {
default = self.apps.${system}.nix-on-droid;
nix-on-droid = {
type = "app";
program = "${self.packages.${system}.nix-on-droid}/bin/nix-on-droid";
};
deploy = {
type = "app";
program = toString (import ./scripts/deploy.nix { inherit nixpkgs system; });
};
});
checks = forEachSystem (system: {
nix-formatter-pack-check = nix-formatter-pack.lib.mkCheck formatterPackArgsFor.${system};
});
formatter = forEachSystem (system: nix-formatter-pack.lib.mkFormatter formatterPackArgsFor.${system});
lib.nixOnDroidConfiguration =
{ pkgs
, modules ? [ ]
, extraSpecialArgs ? { }
, home-manager-path ? home-manager.outPath
# deprecated:
, config ? null
, extraModules ? null
, system ? null # pkgs.system is used to detect user's arch
}:
if ! (builtins.elem pkgs.system [ "aarch64-linux" "x86_64-linux" ]) then
throw
("${pkgs.system} is not supported; aarch64-linux / x86_64-linux " +
"are the only currently supported system types")
else
pkgs.lib.throwIf
(config != null || extraModules != null || system != null)
''
The 'nixOnDroidConfiguration' arguments
- 'config'
- 'extraModules'
- 'system'
have been removed.
Instead of 'extraModules' use the argument 'modules'.
The 'system' will be inferred by 'pkgs.system',
so pass a 'pkgs = import nixpkgs { system = "aarch64-linux"; };'
See the 22.11 release notes for more.
''
(import ./modules {
targetSystem = pkgs.system; # system to cross-compile to
inherit extraSpecialArgs home-manager-path pkgs;
config.imports = modules;
isFlake = true;
});
overlays.default = overlay;
packages = forEachSystem (system:
let
flattenArch = arch: derivationAttrset:
nixpkgs.lib.attrsets.mapAttrs'
(name: drv:
nixpkgs.lib.attrsets.nameValuePair (name + "-" + arch) drv
)
derivationAttrset;
perArchCustomPkgs = arch: flattenArch arch
(import ./pkgs {
_nativeSystem = system; # system to cross-compile from
system = "${arch}-linux"; # system to cross-compile to
nixpkgs = nixpkgs-for-bootstrap;
}).customPkgs;
docs = import ./docs {
inherit home-manager;
pkgs = nixpkgs-docs.legacyPackages.${system};
nmdSrc = nmd;
};
in
{
nix-on-droid = nixpkgs.legacyPackages.${system}.callPackage ./nix-on-droid { };
}
// (perArchCustomPkgs "aarch64")
// (perArchCustomPkgs "x86_64")
// docs
);
templates = {
default = self.templates.minimal;
minimal = {
path = ./templates/minimal;
description = "Minimal example of Nix-on-Droid system config.";
};
home-manager = {
path = ./templates/home-manager;
description = "Minimal example of Nix-on-Droid system config with home-manager.";
};
advanced = {
path = ./templates/advanced;
description = "Advanced example of Nix-on-Droid system config with home-manager.";
};
};
};
}