depot/flake.nix

97 lines
2.8 KiB
Nix
Raw Normal View History

2021-06-05 23:59:06 +03:00
{
description = "Private Void system configurations";
inputs = {
2021-12-02 21:52:45 +02:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
2021-06-05 23:59:06 +03:00
2021-08-23 20:27:12 +03:00
nix-super.url = "git+https://git.privatevoid.net/max/nix-super";
nix-super.inputs.nix.follows = "nix-super-unstable-repin";
nix-super-unstable-repin.url = "github:NixOS/nix";
nix-super-unstable-repin.inputs.nixpkgs.follows = "nixpkgs";
2021-06-05 23:59:06 +03:00
home-manager.url = "github:nix-community/home-manager/master";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
2021-11-25 21:09:15 +02:00
deploy-rs.url = "git+https://git.privatevoid.net/max/deploy-rs";
2021-06-05 23:59:06 +03:00
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
2021-10-16 21:24:25 +03:00
2021-12-11 17:00:09 +02:00
nar-serve.url = "github:numtide/nar-serve/v0.5.0";
2021-10-16 21:24:25 +03:00
nar-serve.inputs.nixpkgs.follows = "nixpkgs";
2022-01-11 21:58:10 +02:00
dream2nix.url = "github:nix-community/dream2nix";
dream2nix.inputs.nixpkgs.follows = "nixpkgs";
2021-06-05 23:59:06 +03:00
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
2022-02-03 21:20:59 +02:00
systems = [ "x86_64-linux" "aarch64-linux" ];
forSystems = nixpkgs.lib.genAttrs systems;
nixpkgsFor = system: import nixpkgs {
2021-06-05 23:59:06 +03:00
inherit system;
};
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';
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";
modules = [ host.nixos ./tools/inject.nix ];
2021-06-05 23:59:06 +03:00
};
mkNixOS = mkNixOS' lib;
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-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-02-03 21:20:59 +02:00
in {
nixosModules = aspect.modules;
2022-01-11 21:58:10 +02:00
2022-02-03 21:20:59 +02:00
nixosConfigurations = lib.genAttrs nixosHosts mkNixOS;
deploy.nodes = mkDeployments nixosHosts {};
packages = forSystems (system: import ./packages {
inherit inputs;
pkgs = nixpkgsFor system;
});
apps = forSystems (system: {
dream2nix = inputs.dream2nix.defaultApp.${system};
});
2021-06-05 23:59:06 +03:00
hydraJobs = {
2022-02-03 21:20:59 +02:00
systems = lib.mapAttrs (_: x: x.config.system.build.toplevel) self.nixosConfigurations;
2021-06-05 23:59:06 +03:00
packages = self.packages;
};
};
}