forked from emily/nixfiles
minor flake refactor
This commit is contained in:
parent
0a4b7c4458
commit
e4fd5ee179
6 changed files with 82 additions and 30 deletions
|
@ -28,12 +28,13 @@ with lib; {
|
|||
fish.enable = true;
|
||||
};
|
||||
|
||||
deployment = {
|
||||
tags = [ "all" ];
|
||||
targetHost = mkDefault config.networking.fqdn;
|
||||
targetPort = mkDefault 22;
|
||||
targetUser = mkDefault null;
|
||||
};
|
||||
kyouma.tags = [ "all" ];
|
||||
# deployment = {
|
||||
# tags = [ "all" ];
|
||||
# targetHost = mkDefault config.networking.fqdn;
|
||||
# targetPort = mkDefault 22;
|
||||
# targetUser = mkDefault null;
|
||||
# };
|
||||
|
||||
security.dhparams.defaultBitSize = 4096;
|
||||
|
||||
|
|
36
flake.nix
36
flake.nix
|
@ -48,41 +48,32 @@
|
|||
builders = "ssh://build@seras.kyouma.net x86_64-linux,aarch64-linux - 40 5 nixos-test,benchmark,big-parallel,kvm";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }@inputs: {
|
||||
colmena = let
|
||||
hosts = builtins.filter (name: name != "base") (
|
||||
builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") (
|
||||
builtins.readDir ./config/hosts)));
|
||||
hostCfg = hostname: {
|
||||
imports = [
|
||||
(./config/hosts/${hostname}/configuration.nix)
|
||||
({ ... }: {
|
||||
nixpkgs.overlays = [ self.overlays.kyouma ];
|
||||
})
|
||||
];
|
||||
};
|
||||
outputs = { self, nixpkgs, flake-utils, ... }@inputs: let
|
||||
shinyflakes = import ./lib/shinyflakes inputs;
|
||||
in {
|
||||
hosts = shinyflakes.mapHosts {
|
||||
lain = { system = "aarch64-linux"; };
|
||||
};
|
||||
|
||||
colmena = shinyflakes.mapColmenaCfg {
|
||||
meta = {
|
||||
allowApplyAll = false;
|
||||
machinesFile = ./config/files/builders;
|
||||
nixpkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
nodeNixpkgs = {
|
||||
lain = nixpkgs.legacyPackages.aarch64-linux;
|
||||
};
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
} // nixpkgs.lib.attrsets.genAttrs hosts (hostCfg);
|
||||
};
|
||||
|
||||
nixosConfigurations = {
|
||||
ryuuko = nixpkgs.lib.nixosSystem {
|
||||
nixosConfigurations = shinyflakes.mapNixosCfg {
|
||||
ryuuko-minimal = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
./config/hosts/base/configuration.nix
|
||||
./config/hosts/_minimal/configuration.nix
|
||||
./config/hosts/ryuuko/disko.nix
|
||||
];
|
||||
};
|
||||
lain = nixpkgs.lib.nixosSystem {
|
||||
lain-minimal = nixpkgs.lib.nixosSystem {
|
||||
system = "aarch64-linux";
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
|
@ -90,7 +81,8 @@
|
|||
];
|
||||
};
|
||||
};
|
||||
images.lain = self.nixosConfigurations.lain.config.system.build.sdImage;
|
||||
images.lain = self.nixosConfigurations.lain-minimal.config.system.build.sdImage;
|
||||
|
||||
overlays = {
|
||||
kyouma = import ./pkgs/overlay.nix;
|
||||
default = self.overlays.kyouma;
|
||||
|
|
44
lib/shinyflakes/default.nix
Normal file
44
lib/shinyflakes/default.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ self, nixpkgs, ... }@inputs: let
|
||||
readHostDir = builtins.filter (name: name != "_minimal") (
|
||||
builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") (
|
||||
builtins.readDir ../../config/hosts)));
|
||||
|
||||
filterMinimal = attr: nixpkgs.lib.filterAttrs (name: v: !(nixpkgs.lib.hasSuffix "-minimal" name)) attr;
|
||||
|
||||
genColmenaCfg = name: host: {
|
||||
deployment = {
|
||||
allowLocalDeployment = builtins.any (hostName: hostName == name) [ "ryuuko" ];
|
||||
targetHost = nixpkgs.lib.findFirst (el: el != null) host.config.networking.fqdn [ host.config.kyouma.deployment.targetHost ];
|
||||
targetPort = 22;
|
||||
# change back to null after switching ryuuko to nixos
|
||||
targetUser = "emily";
|
||||
tags = host.config.kyouma.deployment.tags;
|
||||
};
|
||||
imports = host._module.args.modules;
|
||||
nixpkgs.system = host.config.nixpkgs.system;
|
||||
};
|
||||
|
||||
genNixosCfg = {
|
||||
hostname,
|
||||
system ? "x86_64-linux"
|
||||
}:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
system = system;
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
../../config/hosts/${hostname}/configuration.nix
|
||||
({ ... }: {
|
||||
nixpkgs.overlays = [ self.overlays.kyouma ];
|
||||
})
|
||||
];
|
||||
};
|
||||
in {
|
||||
mapHosts = hostCfg: nixpkgs.lib.recursiveUpdate (
|
||||
nixpkgs.lib.genAttrs readHostDir (host: { hostname = host; })) hostCfg;
|
||||
|
||||
mapColmenaCfg = extraColmenaCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (genColmenaCfg) (
|
||||
filterMinimal self.nixosConfigurations)) extraColmenaCfg;
|
||||
|
||||
mapNixosCfg = extraNixosCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (name: value:
|
||||
genNixosCfg value) self.hosts) extraNixosCfg;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
{ ... }: {
|
||||
imports = [
|
||||
./vhost
|
||||
./machine-type
|
||||
./deployment
|
||||
./vhost
|
||||
];
|
||||
}
|
||||
|
|
14
modules/deployment/default.nix
Normal file
14
modules/deployment/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ lib, ... }: with lib; {
|
||||
options.kyouma.deployment = {
|
||||
tags = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "colmena deployment tags";
|
||||
};
|
||||
targetHost = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "colmena target host override";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue