nixfiles/lib/shinyflakes/default.nix
emily 1de66b3795
fixed deployment
weird thing happen when you try to copy things from a binary cache to
a local store
2024-05-14 16:23:51 +02:00

55 lines
2.1 KiB
Nix

{ self, nixpkgs, ... }@inputs: let
mapDir = dir: builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") (
builtins.readDir ../../${dir}));
filterDir = filterBy: dir: builtins.filter (name: name != filterBy) (mapDir dir);
filterSuffix = suffix: attr: nixpkgs.lib.filterAttrs (name: v: !(nixpkgs.lib.hasSuffix suffix name)) attr;
genColmenaCfg = name: host: {
deployment = {
allowLocalDeployment = builtins.any (hostName: hostName == name) [ "ryuuko" ];
buildOnTarget = true;
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
inputs.sops-nix.nixosModules.sops
({ ... }: {
nixpkgs.overlays = [ self.overlays.kyouma self.overlays.otherPkgs ];
nixpkgs.hostPlatform.system = system;
kyouma.deployment.auto-upgrade.hostName = hostname;
})
];
};
in {
mapHosts = hostCfg: nixpkgs.lib.recursiveUpdate (
nixpkgs.lib.genAttrs (filterDir "_minimal" "config/hosts") (host: { hostname = host; })) hostCfg;
mapColmenaCfg = extraColmenaCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (genColmenaCfg) (
filterSuffix "-minimal" self.nixosConfigurations)) extraColmenaCfg;
mapNixosCfg = extraNixosCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (name: value:
genNixosCfg value) self.hosts) extraNixosCfg;
mapPackages = overlayPkgs: otherPackages: nixpkgs.lib.recursiveUpdate (
nixpkgs.lib.genAttrs (mapDir "pkgs") (name: overlayPkgs.${name})) otherPackages;
mapHydraHosts = hosts: builtins.mapAttrs (name: host: host.config.system.build.toplevel) hosts;
}