83 lines
2.5 KiB
Nix
83 lines
2.5 KiB
Nix
{
|
|
description = "Memes";
|
|
|
|
inputs.deploy-rs.url = "github:serokell/deploy-rs";
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
inputs.serokell-nix.url = "github:serokell/serokell.nix";
|
|
|
|
outputs = { self, nixpkgs, deploy-rs, serokell-nix }@inputs:
|
|
let
|
|
# Add default system
|
|
system = "x86_64-linux";
|
|
|
|
# Make a config
|
|
mkConfig = { name, lxc ? true }:
|
|
nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
modules = (if lxc then
|
|
[ "${nixpkgs}/nixos/modules/virtualisation/lxc-container.nix" ]
|
|
else
|
|
# this is probably the ugliest fix ever, but it
|
|
# makes both nix/deploy.rs and the formatter work so it's fine
|
|
[ ]) ++ [ "${./.}/hosts/${name}/configuration.nix" ];
|
|
specialArgs = { inputs = inputs; };
|
|
};
|
|
|
|
# create a deployment
|
|
mkDeploy = profile: {
|
|
hostname = "${profile}.voidlocal";
|
|
fastConnection = true;
|
|
profiles.system = {
|
|
user = "root";
|
|
path = deploy-rs.lib.${system}.activate.nixos
|
|
self.nixosConfigurations.${profile};
|
|
};
|
|
};
|
|
|
|
# art starts here :D
|
|
hosts' = import ./hosts;
|
|
|
|
# we only want nix hosts for this part, not all of the defined ones...
|
|
nixHosts = (builtins.filter ({ nix ? true, ... }: nix) hosts');
|
|
|
|
# We can't do partial application with //, so this solves it i guess...
|
|
merge = a: b: a // b;
|
|
|
|
# Convert a host from hosts.nix to something nixosConfigurations understands
|
|
hostToConfig = z@{ hostname, nixname ? hostname, lxc ? true, ... }:
|
|
merge {
|
|
${nixname} = mkConfig {
|
|
name = nixname;
|
|
lxc = lxc;
|
|
};
|
|
};
|
|
|
|
# Same as above, but for the nodes part of deploy.
|
|
hostToDeploy = z@{ hostname, nixname ? hostname, lxc ? true, ... }:
|
|
merge { ${nixname} = mkDeploy nixname; };
|
|
|
|
# And actually make the two sets.
|
|
configs = nixpkgs.lib.foldr hostToConfig { } nixHosts;
|
|
nodes = nixpkgs.lib.foldr hostToDeploy { } nixHosts;
|
|
in {
|
|
|
|
nixosConfigurations = configs;
|
|
|
|
deploy.nodes = nodes;
|
|
|
|
devShell.${system} = let
|
|
pkgs = serokell-nix.lib.pkgsWith nixpkgs.legacyPackages.${system} [ ];
|
|
in pkgs.mkShell {
|
|
buildInputs = [
|
|
deploy-rs.packages.${system}.deploy-rs
|
|
pkgs.vault
|
|
pkgs.nixUnstable
|
|
];
|
|
};
|
|
|
|
checks = builtins.mapAttrs
|
|
(system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
|
|
|
};
|
|
}
|