1
0
Fork 0
forked from emily/nixfiles
nixfiles-emily/lib/shinyflakes/default.nix

55 lines
2.1 KiB
Nix
Raw Permalink Normal View History

2024-04-27 19:34:17 +02:00
{ self, nixpkgs, ... }@inputs: let
2024-05-06 13:55:42 +02:00
mapDir = dir: builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") (
builtins.readDir ../../${dir}));
2024-04-27 19:34:17 +02:00
2024-05-06 13:55:42 +02:00
filterDir = filterBy: dir: builtins.filter (name: name != filterBy) (mapDir dir);
filterSuffix = suffix: attr: nixpkgs.lib.filterAttrs (name: v: !(nixpkgs.lib.hasSuffix suffix name)) attr;
2024-04-27 19:34:17 +02:00
genColmenaCfg = name: host: {
deployment = {
allowLocalDeployment = builtins.any (hostName: hostName == name) [ "ryuuko" ];
2024-05-10 20:09:39 +02:00
buildOnTarget = true;
2024-04-27 19:34:17 +02:00
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"
2024-04-29 15:22:48 +02:00
}:
nixpkgs.lib.nixosSystem {
2024-04-27 19:34:17 +02:00
system = system;
specialArgs = { inherit inputs; };
modules = [
../../config/hosts/${hostname}/configuration.nix
2024-05-09 16:41:01 +02:00
inputs.sops-nix.nixosModules.sops
2024-04-27 19:34:17 +02:00
({ ... }: {
2024-05-14 03:08:06 +02:00
nixpkgs.overlays = [ self.overlays.kyouma self.overlays.otherPkgs ];
2024-05-12 19:54:39 +02:00
nixpkgs.hostPlatform.system = system;
kyouma.deployment.auto-upgrade.hostName = hostname;
2024-04-27 19:34:17 +02:00
})
];
};
in {
mapHosts = hostCfg: nixpkgs.lib.recursiveUpdate (
2024-05-06 13:55:42 +02:00
nixpkgs.lib.genAttrs (filterDir "_minimal" "config/hosts") (host: { hostname = host; })) hostCfg;
2024-04-27 19:34:17 +02:00
mapColmenaCfg = extraColmenaCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (genColmenaCfg) (
2024-05-06 13:55:42 +02:00
filterSuffix "-minimal" self.nixosConfigurations)) extraColmenaCfg;
2024-04-27 19:34:17 +02:00
mapNixosCfg = extraNixosCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (name: value:
genNixosCfg value) self.hosts) extraNixosCfg;
2024-05-06 13:55:42 +02:00
mapPackages = overlayPkgs: otherPackages: nixpkgs.lib.recursiveUpdate (
nixpkgs.lib.genAttrs (mapDir "pkgs") (name: overlayPkgs.${name})) otherPackages;
2024-05-06 20:41:11 +02:00
mapHydraHosts = hosts: builtins.mapAttrs (name: host: host.config.system.build.toplevel) hosts;
2024-04-27 19:34:17 +02:00
}