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;
|
fish.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
deployment = {
|
kyouma.tags = [ "all" ];
|
||||||
tags = [ "all" ];
|
# deployment = {
|
||||||
targetHost = mkDefault config.networking.fqdn;
|
# tags = [ "all" ];
|
||||||
targetPort = mkDefault 22;
|
# targetHost = mkDefault config.networking.fqdn;
|
||||||
targetUser = mkDefault null;
|
# targetPort = mkDefault 22;
|
||||||
};
|
# targetUser = mkDefault null;
|
||||||
|
# };
|
||||||
|
|
||||||
security.dhparams.defaultBitSize = 4096;
|
security.dhparams.defaultBitSize = 4096;
|
||||||
|
|
||||||
|
|
38
flake.nix
38
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";
|
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: {
|
outputs = { self, nixpkgs, flake-utils, ... }@inputs: let
|
||||||
colmena = let
|
shinyflakes = import ./lib/shinyflakes inputs;
|
||||||
hosts = builtins.filter (name: name != "base") (
|
in {
|
||||||
builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") (
|
hosts = shinyflakes.mapHosts {
|
||||||
builtins.readDir ./config/hosts)));
|
lain = { system = "aarch64-linux"; };
|
||||||
hostCfg = hostname: {
|
};
|
||||||
imports = [
|
|
||||||
(./config/hosts/${hostname}/configuration.nix)
|
colmena = shinyflakes.mapColmenaCfg {
|
||||||
({ ... }: {
|
|
||||||
nixpkgs.overlays = [ self.overlays.kyouma ];
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
meta = {
|
meta = {
|
||||||
allowApplyAll = false;
|
allowApplyAll = false;
|
||||||
machinesFile = ./config/files/builders;
|
machinesFile = ./config/files/builders;
|
||||||
nixpkgs = nixpkgs.legacyPackages.x86_64-linux;
|
nixpkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
nodeNixpkgs = {
|
|
||||||
lain = nixpkgs.legacyPackages.aarch64-linux;
|
|
||||||
};
|
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
};
|
};
|
||||||
} // nixpkgs.lib.attrsets.genAttrs hosts (hostCfg);
|
};
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = shinyflakes.mapNixosCfg {
|
||||||
ryuuko = nixpkgs.lib.nixosSystem {
|
ryuuko-minimal = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = [
|
modules = [
|
||||||
./config/hosts/base/configuration.nix
|
./config/hosts/_minimal/configuration.nix
|
||||||
./config/hosts/ryuuko/disko.nix
|
./config/hosts/ryuuko/disko.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
lain = nixpkgs.lib.nixosSystem {
|
lain-minimal = nixpkgs.lib.nixosSystem {
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = [
|
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 = {
|
overlays = {
|
||||||
kyouma = import ./pkgs/overlay.nix;
|
kyouma = import ./pkgs/overlay.nix;
|
||||||
default = self.overlays.kyouma;
|
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 = [
|
imports = [
|
||||||
./vhost
|
|
||||||
./machine-type
|
./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