dev.fron.io rc / 13667a0
hosts: differentiate deploy system and target platform also bump nyxt and fix nixus Tony Olagbaiye 11 months ago
8 changed file(s) with 75 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
10191019 ]
10201020 },
10211021 "locked": {
1022 "lastModified": 1608989161,
1023 "narHash": "sha256-0ALlHZ49gcFw/s7MCOneHUOm/0FFL+Ybhr/eHt6+mHs=",
1022 "lastModified": 1609346110,
1023 "narHash": "sha256-sWrJ7MAdB+SJhdjO75ACHzwPZWEDTA22BZ1aoZoO1/Q=",
10241024 "owner": "atlas-engineer",
10251025 "repo": "nyxt",
1026 "rev": "9b0a0b0aa35ff0587856426b4d65cd3f019f679e",
1026 "rev": "9a531621ec4092aada58afbab050aafbb5f21bc6",
10271027 "type": "github"
10281028 },
10291029 "original": {
365365 defaultPackage = forAllSystems ({ pkgs, system, ... }:
366366 import ./deploy {
367367 nixpkgs = patchNixpkgs (channels.modules.legacyPackages.${system});
368 deploySystem = system;
368 deploySystem = system; # By habit, system is deployer, platform is target
369369 } ({ config, lib, ... }: let
370370 inherit (config) nodes;
371 system = {
372 deploy = system;
373 # no current exceptions
374 target = "x86_64-linux";
375 };
376371 in {
377372 defaults = { name, config, ... }: let
378 nixos = inputs.self.nixosModules.hosts.${system.target}.${name};
379
380 vmsystem = { modules, system, specialArgs, ... }: {
381 system.build.vm = (import "${patchNixpkgs pkgs}/nixos/lib/eval-config.nix" {
382 inherit system specialArgs;
373 evalConfig = import "${patchNixpkgs pkgs}/nixos/lib/eval-config.nix";
374
375 getPlatform = with lib.modules; { modules, specialArgs, ... }: let
376 args = { config = null; options = null; inherit lib; } // specialArgs;
377 in (mergeModules [] (collectModules "" modules args)).matchedOptions.platform.value;
378
379 nixos = with inputs.self.nixosModules;
380 let platform = (getPlatform hosts.${system}.${name});
381 in hosts.${platform}.${name};
382
383 vmsystem = { modules, pkgs, specialArgs, ... }: {
384 system.build.vm = (evalConfig {
385 inherit specialArgs;
386 inherit (pkgs) system;
383387 modules = modules ++ [
384388 (import "${channels.modules}/nixos/modules/virtualisation/qemu-vm.nix")
385389 ];
386390 }).config.system.build.toplevel;
387391 };
388392
389 linkage = let
390 inherit (inputs.self.defaultPackage.${system.deploy}.config) nodes;
393 linkage = { config, pkgs, ... }: let
394 systems = builtins.mapAttrs (host: _: with inputs.self;
395 let platform = getPlatform nixosModules.hosts.${system}.${host};
396 in defaultPackage.${platform}.config.nodes.${host}.configuration
397 ) nodes;
391398 in {
399 options.system.linkOtherSystems = lib.mkOption {
400 type = lib.types.bool;
401 default = true;
402 description = "Whether to link other flake nodes to the system derivation.";
403 };
404
392405 # Link raw hosts on each host (non-recursively)
393 system.extraSystemBuilderCmds = ''
394 mkdir -p $out/flake/hosts
395
396 # Link other hosts (nonrecursively)
397 ${lib.concatMapStringsSep "\n" ({ name, value }: ''
398 ln -s '${value.configuration.system.build.toplevel}' "$out/flake/hosts/${name}"
399 '') (lib.mapAttrsToList lib.nameValuePair nodes)}
400
401 # Link host containers
402 ${lib.concatMapStringsSep "\n" (host@{ name, value }: ''
403 mkdir -p $out/flake/container/${name}
404 ${lib.concatMapStringsSep "\n" (container@{ name, value }: ''
405 ln -s '${value.configuration.system.build.toplevel}' "$out/flake/container/${host.name}/${name}"
406 '') (lib.mapAttrsToList lib.nameValuePair value.configuration.containers)}
407 '') (lib.mapAttrsToList lib.nameValuePair nodes)}
408 '';
406 config.system = {
407 extraSystemBuilderCmds = lib.mkIf config.system.linkOtherSystems (''
408 mkdir -p $out/flake/hosts
409
410 # Link other hosts (nonrecursively)
411 ${lib.concatMapStringsSep "\n" ({ name, value }: ''
412 ln -s '${value.system.build.toplevel}' "$out/flake/hosts/${name}"
413 '') (lib.mapAttrsToList lib.nameValuePair systems)}
414
415 # Link host containers
416 ${lib.concatMapStringsSep "\n" (host@{ name, value }: ''
417 mkdir -p $out/flake/container/${name}
418 ${lib.concatMapStringsSep "\n" (container@{ name, value }: ''
419 ln -s '${value.config.system.build.toplevel}' "$out/flake/container/${host.name}/${name}"
420 '') (lib.mapAttrsToList lib.nameValuePair value.containers)}
421 '') (lib.mapAttrsToList lib.nameValuePair systems)}
422 '');
423 };
409424 };
410425 in {
411426 host = "root@${nixos.specialArgs.hosts.wireguard.${name}}";
412427
413 configuration = rec {
414 _module.args = nixos.specialArgs;
428 configuration = {
415429 imports = nixos.modules ++ [
416 #linkage
430 #linkage # TODO: figure out how to make this work
417431 vmsystem
418 { secrets.baseDirectory = "/var/lib/secrets/"; }
419432 ];
433 config = {
434 secrets.baseDirectory = "/var/lib/secrets/";
435 _module.args = nixos.specialArgs;
436 };
420437 };
421438
422439 # Filter out "added to list of known hosts" spam from output
459476 };
460477
461478 nodes = let
462 hosts = builtins.attrNames (builtins.removeAttrs inputs.self.nixosModules.hosts.${system.target} [
463 "image"
464 ]);
479 hosts = builtins.attrNames inputs.self.nixosModules.hosts.${system};
465480 in (lib.genAttrs hosts (_: {})) // {
466 zeta.panicAction = "false";
481 delta.hasFastConnection = true; # it's local!
482 image.enabled = false;
483 zeta.panicAction = "false"; # we shouldn't reboot this carelessly
467484 zeta.hasFastConnection = true;
468485 zeta.successTimeout = 240; # Zeta seems very slow...
469486 zeta.switchTimeout = 240; # maybe due to wireguard reloading?
3030 ./network.nix
3131 ./remote.nix
3232 ];
33
34 platform = "x86_64-linux";
3335
3436 # Use the systemd-boot EFI boot loader.
3537 boot.loader = {
1111 ../../profiles/sound/pulse.nix
1212 ../../users/leaf.nix
1313 ];
14
15 platform = "x86_64-linux";
1416
1517 # Use the systemd-boot EFI boot loader.
1618 boot.loader = {
3030 ./certificate.nix
3131 ];
3232
33 platform = "x86_64-linux";
34
3335 boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "sd_mod" ];
3436 boot.initrd.kernelModules = [ "btrfs" "ext4" ];
3537 boot.kernelModules = [ "kvm-intel" ];
00 [
11 ./emacs.nix
2 ./misc/platform.nix
23 ]
0 { lib, ... }:
1
2 {
3 options = {
4 platform = lib.mkOption {
5 type = lib.types.str;
6 description = "Target platform";
7 };
8 };
9 }
99 ./networking/namespacing.nix
1010 ./misc/headless.nix
1111 ./misc/attrmods.nix
12 ./misc/platform.nix
1213 ]