@@ -262,4 +262,90 @@ rec {
262
262
shell = pkgs . mkShellNoCC {
263
263
packages = [ ] ;
264
264
} ;
265
+
266
+ demo-system =
267
+ module :
268
+ let
269
+ nixosSystem =
270
+ args :
271
+ import ( sources . nixpkgs + "/nixos/lib/eval-config.nix" ) (
272
+ {
273
+ inherit lib ;
274
+ system = null ;
275
+ }
276
+ // args
277
+ ) ;
278
+ in
279
+ nixosSystem {
280
+ system = "x86_64-linux" ;
281
+ modules = [
282
+ module
283
+ ( sources . nixpkgs + "/nixos/modules/profiles/qemu-guest.nix" )
284
+ ( sources . nixpkgs + "/nixos/modules/virtualisation/qemu-vm.nix" )
285
+ (
286
+ { config , ... } :
287
+ {
288
+ users . users . nixos = {
289
+ isNormalUser = true ;
290
+ extraGroups = [ "wheel" ] ;
291
+ initialPassword = "nixos" ;
292
+ } ;
293
+
294
+ users . users . root = {
295
+ initialPassword = "root" ;
296
+ } ;
297
+
298
+ security . sudo . wheelNeedsPassword = false ;
299
+
300
+ services . getty . autologinUser = "nixos" ;
301
+ services . getty . helpLine = ''
302
+
303
+ Welcome to NGIpkgs!
304
+ '' ;
305
+
306
+ services . openssh = {
307
+ enable = true ;
308
+ settings = {
309
+ PasswordAuthentication = true ;
310
+ PermitEmptyPasswords = "yes" ;
311
+ PermitRootLogin = "yes" ;
312
+ } ;
313
+ } ;
314
+
315
+ system . stateVersion = "25.05" ;
316
+
317
+ networking . firewall . enable = false ;
318
+
319
+ virtualisation = {
320
+ memorySize = 4096 ;
321
+ cores = 4 ;
322
+ graphics = false ;
323
+
324
+ qemu . options = [
325
+ "-cpu host"
326
+ "-enable-kvm"
327
+ ] ;
328
+
329
+ # ssh + open service ports
330
+ forwardPorts = map ( port : {
331
+ from = "host" ;
332
+ guest . port = port ;
333
+ host . port = port + 10000 ;
334
+ proto = "tcp" ;
335
+ } ) config . networking . firewall . allowedTCPPorts ;
336
+ } ;
337
+ }
338
+ )
339
+ ] ++ extendedNixosModules ;
340
+ } ;
341
+
342
+ demo =
343
+ module :
344
+ pkgs . writeShellScript "demo-vm" ''
345
+ exec ${ ( demo-system module ) . config . system . build . vm } /bin/run-nixos-vm "$@"
346
+ '' ;
347
+
348
+ # $ nix-build . -A demo-test
349
+ # $ ./result
350
+ demo-test = demo ./projects/Cryptpad/demo.nix ;
265
351
}
0 commit comments