-
Notifications
You must be signed in to change notification settings - Fork 27
/
flake.nix
230 lines (200 loc) · 7.18 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat = {
url = "github:nix-community/flake-compat";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
nixpkgs-stable,
rust-overlay,
...
}:
let
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
rustPlatformFor =
pkgs:
if nixpkgs.lib.versionAtLeast pkgs.rustc.version "1.80.0" then
pkgs.rustPlatform
else
let
rust-bin = rust-overlay.lib.mkRustBin { } pkgs;
in
pkgs.makeRustPlatform {
cargo = rust-bin.stable.latest.default;
rustc = rust-bin.stable.latest.default;
};
in
{
lib = {
packagesFor =
pkgs:
import ./pkgs {
inherit pkgs;
rustPlatform = rustPlatformFor pkgs;
};
};
packages = forAllSystems (system: self.lib.packagesFor nixpkgs.legacyPackages.${system});
overlays = {
default =
final: prev:
import ./pkgs {
inherit final prev;
rustPlatform = rustPlatformFor prev;
};
};
nixosModules = {
default = import ./nixos { cosmicOverlay = self.overlays.default; };
};
legacyPackages = forAllSystems (
system:
let
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system};
in
{
update = pkgs.writeShellApplication {
name = "cosmic-unstable-update";
text = lib.concatStringsSep "\n" (
lib.mapAttrsToList (
attr: drv:
if drv ? updateScript && (lib.isList drv.updateScript) && (lib.length drv.updateScript) > 0 then
lib.escapeShellArgs (
if (lib.match "nix-update|.*/nix-update" (lib.head drv.updateScript) != null) then
[ (lib.getExe pkgs.nix-update) ]
++ (lib.tail drv.updateScript)
++ [
"--version"
"branch=HEAD"
"--commit"
attr
]
else
drv.updateScript
)
else
builtins.toString drv.updateScript or ""
) (self.lib.packagesFor pkgs)
);
};
vm = nixpkgs.lib.makeOverridable (
{ nixpkgs }:
let
nixosConfig = nixpkgs.lib.nixosSystem {
modules = [
(
{
lib,
pkgs,
modulesPath,
...
}:
{
imports = [
self.nixosModules.default
"${builtins.toString modulesPath}/virtualisation/qemu-vm.nix"
];
services.desktopManager.cosmic.enable = true;
services.displayManager.cosmic-greeter.enable = true;
services.flatpak.enable = true;
services.gnome.gnome-keyring.enable = true;
environment.systemPackages = with pkgs; [
chronos
cosmic-ext-applet-clipboard-manager
cosmic-ext-applet-emoji-selector
cosmic-ext-applet-external-monitor-brightness
cosmic-ext-calculator
cosmic-ext-examine
cosmic-ext-forecast
cosmic-ext-tasks
cosmic-ext-tweaks
(lib.lowPrio cosmic-comp)
cosmic-player
cosmic-reader
drm_info
firefox
quick-webapps
stellarshot
] ++ lib.optionals pkgs.stdenv.hostPlatform.isx86 [
cosmic-ext-observatory
];
environment.sessionVariables = {
COSMIC_DATA_CONTROL_ENABLED = "1";
};
boot.kernelParams = [
"quiet"
"udev.log_level=3"
];
boot.initrd.kernelModules = [ "bochs" ];
boot.initrd.verbose = false;
boot.initrd.systemd.enable = true;
boot.loader.systemd-boot.enable = true;
boot.loader.timeout = 0;
boot.plymouth.enable = true;
boot.plymouth.theme = "nixos-bgrt";
boot.plymouth.themePackages = [ pkgs.nixos-bgrt-plymouth ];
services.openssh = {
enable = true;
settings.PermitRootLogin = "yes";
};
documentation.nixos.enable = false;
users.mutableUsers = false;
users.users.root.password = "meow";
users.users.user = {
isNormalUser = true;
password = "meow";
};
virtualisation.useBootLoader = true;
virtualisation.useEFIBoot = true;
virtualisation.mountHostNixStore = true;
virtualisation.memorySize = 4096;
# TODO: below option can be removed once NixOS/nixpkgs#279009 is merged
virtualisation.qemu.options = [
"-vga none"
"-device virtio-gpu-gl-pci"
"-display default,gl=on"
];
virtualisation.forwardPorts = [
{
from = "host";
host.port = 2222;
guest.port = 22;
}
];
nixpkgs.config.allowAliases = false;
nixpkgs.hostPlatform = system;
system.stateVersion = lib.trivial.release;
}
)
];
};
in
nixosConfig.config.system.build.vm
// {
closure = nixosConfig.config.system.build.toplevel;
inherit (nixosConfig) config pkgs;
}
) { inherit nixpkgs; };
vm-stable = self.legacyPackages.${system}.vm.override { nixpkgs = nixpkgs-stable; };
}
);
checks = forAllSystems (system: {
vm = self.legacyPackages.${system}.vm.closure;
vm-stable = self.legacyPackages.${system}.vm-stable.closure;
});
};
}