2021-06-05 23:59:06 +03:00
|
|
|
{
|
|
|
|
description = "Private Void system configurations";
|
2022-07-31 21:08:19 +03:00
|
|
|
nixConfig = {
|
|
|
|
allow-import-from-derivation = true;
|
|
|
|
extra-substituters = "https://cache.privatevoid.net";
|
|
|
|
extra-trusted-public-keys = "cache.privatevoid.net:SErQ8bvNWANeAvtsOESUwVYr2VJynfuc9JRwlzTTkVg=";
|
|
|
|
};
|
2021-06-05 23:59:06 +03:00
|
|
|
|
2022-07-31 15:26:18 +03:00
|
|
|
outputs = { self, nixpkgs, flake-parts, ... }@inputs:
|
2021-06-05 23:59:06 +03:00
|
|
|
let
|
2022-02-03 21:20:59 +02:00
|
|
|
systems = [ "x86_64-linux" "aarch64-linux" ];
|
|
|
|
|
2022-07-31 22:26:12 +03:00
|
|
|
nixpkgsFor = nixpkgs.legacyPackages;
|
2021-06-05 23:59:06 +03:00
|
|
|
|
2022-02-03 21:20:59 +02:00
|
|
|
inherit (nixpkgs) lib;
|
2021-06-05 23:59:06 +03:00
|
|
|
|
|
|
|
aspect = import ./modules inputs;
|
|
|
|
hosts = import ./hosts;
|
2022-02-03 21:20:59 +02:00
|
|
|
|
|
|
|
nixosHosts' = lib.filterAttrs (_: host: host ? nixos) hosts;
|
|
|
|
|
|
|
|
nixosHosts = lib.attrNames nixosHosts';
|
|
|
|
|
2022-05-28 22:49:16 +03:00
|
|
|
deployableNixosHosts' = lib.filterAttrs (_: host: host ? container -> !host.container) nixosHosts';
|
|
|
|
|
|
|
|
deployableNixosHosts = lib.attrNames deployableNixosHosts';
|
|
|
|
|
2022-02-03 21:20:59 +02:00
|
|
|
meta = import ./tools/meta.nix;
|
|
|
|
|
2021-10-16 18:00:47 +03:00
|
|
|
specialArgs = {
|
|
|
|
inherit inputs hosts aspect;
|
|
|
|
toolsets = import ./tools;
|
|
|
|
};
|
2022-02-03 21:20:59 +02:00
|
|
|
mkNixOS' = lib: name: let host = hosts.${name}; in lib.nixosSystem {
|
2021-06-05 23:59:06 +03:00
|
|
|
inherit specialArgs;
|
2022-02-03 21:20:59 +02:00
|
|
|
system = "${host.arch}-linux";
|
2022-06-23 21:13:28 +03:00
|
|
|
modules = [ host.nixos ./tools/inject.nix (import ./cluster/inject.nix name) ];
|
2021-06-05 23:59:06 +03:00
|
|
|
};
|
|
|
|
mkNixOS = mkNixOS' lib;
|
2022-02-03 21:20:59 +02:00
|
|
|
|
2022-05-25 10:42:45 +03:00
|
|
|
mkDeployEffect = branch: name: host: let
|
2022-05-25 10:50:13 +03:00
|
|
|
subdomain = host.enterprise.subdomain or "services";
|
2022-05-25 10:42:45 +03:00
|
|
|
hostname = "${lib.toLower name}.${subdomain}.${meta.domain}";
|
2022-05-25 12:11:41 +03:00
|
|
|
in effects.runIf (branch == "master" || branch == "staging") (effects.runNixOS {
|
2022-05-25 10:42:45 +03:00
|
|
|
requiredSystemFeatures = [ "hci-deploy-agent-nixos" ];
|
2022-05-25 19:45:19 +03:00
|
|
|
inherit (self.nixosConfigurations.${name}) config;
|
2022-05-25 10:42:45 +03:00
|
|
|
secretsMap.ssh = "deploy-ssh";
|
|
|
|
|
|
|
|
userSetupScript = ''
|
|
|
|
writeSSHKey ssh
|
|
|
|
cat >>~/.ssh/known_hosts <<EOF
|
|
|
|
${hostname} ${host.ssh.id.publicKey}
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
ssh.destination = "root@${hostname}";
|
|
|
|
});
|
|
|
|
|
|
|
|
mkDeployEffects = branch: hostnames: lib.genAttrs hostnames
|
|
|
|
(name: mkDeployEffect branch name hosts.${name});
|
|
|
|
|
2022-02-03 21:20:59 +02:00
|
|
|
mkDeploy = name: let
|
|
|
|
host = hosts.${name};
|
|
|
|
subdomain = host.enterprise.subdomain or "services";
|
|
|
|
deploy-rs = inputs.deploy-rs.lib."${host.arch}-linux";
|
|
|
|
in {
|
|
|
|
hostname = "${lib.toLower name}.${subdomain}.${meta.domain}";
|
|
|
|
profiles.system = {
|
|
|
|
user = "root";
|
|
|
|
sshUser = "deploy";
|
|
|
|
path = deploy-rs.activate.nixos self.nixosConfigurations.${name};
|
2021-10-16 19:34:11 +03:00
|
|
|
};
|
2021-06-05 23:59:06 +03:00
|
|
|
};
|
|
|
|
|
2022-02-03 21:20:59 +02:00
|
|
|
mkDeployments = hosts: overrides: lib.genAttrs hosts
|
|
|
|
(host: mkDeploy host // (overrides.${host} or {}) );
|
2021-06-05 23:59:06 +03:00
|
|
|
|
2022-07-31 22:26:12 +03:00
|
|
|
effects = inputs.hercules-ci-effects.lib.withPkgs (nixpkgsFor.x86_64-linux);
|
2022-07-31 16:09:40 +03:00
|
|
|
in flake-parts.lib.mkFlake { inherit self; } {
|
|
|
|
inherit systems;
|
|
|
|
flake = {
|
|
|
|
nixosModules = aspect.modules;
|
2022-02-03 21:20:59 +02:00
|
|
|
|
2022-07-31 16:09:40 +03:00
|
|
|
nixosConfigurations = lib.genAttrs nixosHosts mkNixOS;
|
2022-03-14 00:13:53 +02:00
|
|
|
|
2022-07-31 16:09:40 +03:00
|
|
|
deploy.nodes = mkDeployments deployableNixosHosts {};
|
2022-05-31 12:38:38 +03:00
|
|
|
|
2022-07-31 16:09:40 +03:00
|
|
|
effects = { branch, ... }: mkDeployEffects branch deployableNixosHosts;
|
|
|
|
};
|
|
|
|
imports = [
|
|
|
|
./packages/part.nix
|
|
|
|
];
|
2021-06-05 23:59:06 +03:00
|
|
|
};
|
2022-07-31 22:24:46 +03:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05-small";
|
2022-10-16 22:20:08 +03:00
|
|
|
nixpkgs-lib.url = "github:NixOS/nixpkgs/nixos-22.05-small?dir=lib";
|
2022-07-31 22:24:46 +03:00
|
|
|
|
|
|
|
nix-super = {
|
2022-09-04 14:20:30 +03:00
|
|
|
url = "gitlab:max/nix-super?host=git.privatevoid.net";
|
2022-10-16 22:59:11 +03:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
nixpkgs-regression.follows = "blank";
|
|
|
|
};
|
2022-07-31 22:24:46 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
deploy-rs = {
|
|
|
|
url = "gitlab:max/deploy-rs?host=git.privatevoid.net";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
2022-10-16 22:59:11 +03:00
|
|
|
flake-compat.follows = "blank";
|
2022-07-31 22:24:46 +03:00
|
|
|
utils.follows = "repin-flake-utils";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
agenix = {
|
|
|
|
url = "github:ryantm/agenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
nar-serve = {
|
|
|
|
url = "github:numtide/nar-serve/v0.5.0";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "repin-flake-utils";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
dream2nix = {
|
|
|
|
url = "github:nix-community/dream2nix";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
2022-10-16 22:59:11 +03:00
|
|
|
alejandra.follows = "blank";
|
|
|
|
all-cabal-json.follows = "blank";
|
|
|
|
crane.follows = "blank";
|
|
|
|
devshell.follows = "blank";
|
|
|
|
flake-utils-pre-commit.follows = "blank";
|
|
|
|
gomod2nix.follows = "blank";
|
|
|
|
mach-nix.follows = "blank";
|
|
|
|
poetry2nix.follows = "poetry2nix";
|
|
|
|
pre-commit-hooks.follows = "blank";
|
2022-07-31 22:24:46 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
devshell = {
|
|
|
|
url = "github:numtide/devshell";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "repin-flake-utils";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
mms = {
|
|
|
|
url = "github:mkaito/nixos-modded-minecraft-servers";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
nix.follows = "nix-super";
|
2022-10-16 22:59:11 +03:00
|
|
|
flake-compat.follows = "blank";
|
2022-07-31 22:24:46 +03:00
|
|
|
flake-utils.follows = "repin-flake-utils";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
hercules-ci-agent = {
|
|
|
|
url = "github:hercules-ci/hercules-ci-agent";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-parts.follows = "flake-parts";
|
2022-10-16 22:59:11 +03:00
|
|
|
nix-darwin.follows = "blank";
|
2022-07-31 22:24:46 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
hercules-ci-effects = {
|
|
|
|
url = "github:hercules-ci/hercules-ci-effects";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
flake-parts = {
|
|
|
|
url = "github:hercules-ci/flake-parts";
|
2022-10-16 22:20:08 +03:00
|
|
|
inputs.nixpkgs-lib.follows = "nixpkgs-lib";
|
2022-07-31 22:24:46 +03:00
|
|
|
};
|
2022-09-25 17:37:24 +03:00
|
|
|
|
|
|
|
nix-filter.url = "github:numtide/nix-filter";
|
2022-07-31 22:24:46 +03:00
|
|
|
|
|
|
|
repin-flake-utils.url = "github:numtide/flake-utils";
|
2022-10-16 22:59:11 +03:00
|
|
|
|
|
|
|
blank.url = "github:divnix/blank";
|
|
|
|
|
|
|
|
poetry2nix = {
|
|
|
|
url = "github:nix-community/poetry2nix";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "repin-flake-utils";
|
|
|
|
};
|
|
|
|
};
|
2022-07-31 22:24:46 +03:00
|
|
|
};
|
2021-06-05 23:59:06 +03:00
|
|
|
}
|