-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
153 lines (138 loc) · 4.7 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
{
inputs = {
# flake inputs can be overriden eg
# --override-input nixpkgs /home/danielbarter/nixpkgs
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
hosts.url = "github:StevenBlack/hosts";
# unify nixpkgs across inputs
hosts.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
hosts,
}:
{
nixosConfigurations =
let
core-modules = [
./base.nix
./packages.nix
./networking.nix
./users.nix
./nix-config.nix
{ nix.nixPath = [ "nixpkgs=${nixpkgs.outPath}" ]; }
];
in
{
jasper = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = core-modules ++ [
./jasper.nix
./sway-gui.nix
./sound.nix
./intel-gpu.nix
];
};
punky = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = core-modules ++ [
./punky.nix
hosts.nixosModule
{
networking.stevenBlackHosts = {
enable = true;
blockFakenews = true;
blockGambling = true;
blockPorn = true;
blockSocial = true;
};
}
./intel-gpu.nix
./sound.nix
];
};
rupert = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = core-modules ++ [ ./rupert.nix ];
};
x86_64-replicant = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = core-modules ++ [
./replicant.nix
# we are probably going to be running on some intel chip,
# so make sure that we have VA-API drivers so firefox is happy
./intel-gpu.nix
./sway-gui.nix
./sound.nix
];
};
aarch64-replicant-cross = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = core-modules ++ [
./replicant.nix
{
nixpkgs.buildPlatform.system = "x86_64-linux";
nixpkgs.hostPlatform.system = "aarch64-linux";
}
];
};
aarch64-replicant = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = core-modules ++ [
./replicant.nix
./sway-gui.nix
./sound.nix
];
};
};
packages."x86_64-linux" =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
x86_64-vm =
image:
pkgs.writeScriptBin "x86_64-run-nixos-vm" ''
#!${pkgs.runtimeShell}
cp ${image}/image.raw /dev/shm/image.raw
chmod +w /dev/shm/image.raw
${pkgs.qemu}/bin/qemu-kvm \
-smp $(nproc) \
-bios ${pkgs.OVMF.fd}/FV/OVMF.fd \
-drive file=/dev/shm/image.raw,format=raw \
-nographic \
-m 8G
rm /dev/shm/image.raw
'';
aarch64-vm =
image:
let
drive-flags = "format=raw,readonly=on";
efi-flash = "${pkgs.pkgsCross.aarch64-multiplatform.OVMF.fd}/AAVMF/QEMU_EFI-pflash.raw";
in
pkgs.writeScriptBin "aarch64-run-nixos-vm" ''
#!${pkgs.runtimeShell}
cp ${image}/image.raw /dev/shm/image.raw
chmod +w /dev/shm/image.raw
${pkgs.qemu}/bin/qemu-system-aarch64 \
-machine virt \
-cpu cortex-a57 \
-m 2G \
-smp 4 \
-nographic \
-drive if=pflash,file=${efi-flash},${drive-flags} \
-drive file=/dev/shm/image.raw,${drive-flags}
rm /dev/shm/image.raw
'';
in
{
# before building run ./utils/pack_etc_nixos.sh
x86_64-replicant-image = self.nixosConfigurations.x86_64-replicant.config.system.build.image;
x86_64-replicant-vm = x86_64-vm self.packages."x86_64-linux".x86_64-replicant-image;
aarch64-replicant-image = self.nixosConfigurations.aarch64-replicant.config.system.build.image;
aarch64-replicant-vm = aarch64-vm self.packages."x86_64-linux".aarch64-replicant-image;
aarch64-replicant-cross-image = self.nixosConfigurations.aarch64-replicant-cross.config.system.build.image;
aarch64-replicant-cross-vm = aarch64-vm self.packages."x86_64-linux".aarch64-replicant-cross-image;
};
};
}