config/flake.nix

346 lines
10 KiB
Nix
Raw Normal View History

2023-03-29 17:50:55 +03:00
{
2023-03-30 16:33:03 +03:00
description = "motiejus/config";
2023-03-29 17:50:55 +03:00
inputs = {
2023-11-27 12:07:19 +02:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
2023-04-05 14:46:57 +03:00
flake-utils.url = "github:numtide/flake-utils";
2023-10-01 22:45:00 +03:00
flake-compat.url = "github:nix-community/flake-compat";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
2023-10-02 00:05:57 +03:00
nur.url = "github:nix-community/NUR";
2023-04-05 14:46:57 +03:00
2023-11-27 18:17:27 +02:00
zigpkgs = {
url = "github:mitchellh/zig-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
};
};
2023-10-09 12:15:07 +03:00
2023-11-27 12:07:19 +02:00
home-manager.url = "github:nix-community/home-manager/release-23.11";
2023-08-18 13:47:27 +03:00
home-manager.inputs.nixpkgs.follows = "nixpkgs";
2023-05-30 10:03:21 +03:00
2023-11-27 18:17:27 +02:00
agenix = {
url = "github:ryantm/agenix";
inputs = {
nixpkgs.follows = "nixpkgs";
home-manager.follows = "home-manager";
darwin.follows = "";
};
};
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-compat.follows = "flake-compat";
utils.follows = "flake-utils";
};
};
2023-09-15 14:39:04 +03:00
2023-12-14 10:10:00 +02:00
nixgl = {
url = "github:guibou/nixGL";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
2023-09-21 06:06:10 +03:00
nix-index-database.url = "github:Mic92/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
2023-10-02 00:05:57 +03:00
gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs";
2023-11-27 18:17:27 +02:00
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs";
flake-compat.follows = "flake-compat";
flake-utils.follows = "flake-utils";
gitignore.follows = "gitignore";
};
};
2023-04-05 14:46:57 +03:00
};
2023-04-05 09:15:02 +03:00
2023-04-05 14:46:57 +03:00
nixConfig = {
trusted-substituters = "https://cache.nixos.org/";
trusted-public-keys = "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=";
2023-11-30 16:44:11 +02:00
extra-experimental-features = "nix-command flakes";
2023-03-29 17:50:55 +03:00
};
2023-04-03 16:50:52 +03:00
outputs = {
self,
nixpkgs,
2023-04-14 14:12:45 +03:00
agenix,
2023-04-03 16:50:52 +03:00
deploy-rs,
flake-utils,
2023-08-18 13:47:27 +03:00
home-manager,
2023-09-14 21:46:01 +03:00
nixos-hardware,
2023-09-21 06:06:10 +03:00
nix-index-database,
2023-10-01 22:45:00 +03:00
pre-commit-hooks,
2023-10-09 12:15:07 +03:00
zigpkgs,
2023-09-15 14:39:04 +03:00
nur,
2023-12-14 10:10:00 +02:00
nixgl,
2023-10-01 22:45:00 +03:00
...
2023-04-05 23:19:56 +03:00
} @ inputs: let
2023-04-05 09:15:02 +03:00
myData = import ./data.nix;
2023-10-01 22:29:59 +03:00
mkDeployPkgs = system:
import nixpkgs {
2023-10-01 23:14:05 +03:00
inherit system;
2023-10-01 22:29:59 +03:00
overlays = [
deploy-rs.overlay
(_self: super: {
deploy-rs = {
2023-10-01 23:14:05 +03:00
inherit (import nixpkgs {inherit system;}) deploy-rs;
inherit (super.deploy-rs) lib;
2023-10-01 22:29:59 +03:00
};
})
];
};
deployPkgsIA64 = mkDeployPkgs "x86_64-linux";
deployPkgsArm64 = mkDeployPkgs "aarch64-linux";
2023-11-27 12:07:19 +02:00
# accepting "system" argument in case we need to construct
# nixpkgs-unstable. See git log around the switch from 23.05 to 23.11.
mkOverlays = _: [
2023-11-15 09:20:23 +02:00
nur.overlay
zigpkgs.overlays.default
];
2023-04-05 09:15:02 +03:00
in
2023-04-03 16:50:52 +03:00
{
2023-07-22 16:05:44 +03:00
#nixosConfigurations.vm = nixpkgs.lib.nixosSystem {
# system = "x86_64-linux";
# modules = [
# ./hosts/vm/configuration.nix
# ./modules
# ];
2023-07-17 16:35:45 +03:00
2023-07-22 16:05:44 +03:00
# specialArgs = {inherit myData;} // inputs;
#};
2023-07-17 16:35:45 +03:00
2023-11-27 18:17:27 +02:00
nixosConfigurations = {
vno1-oh2 = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
{nixpkgs.overlays = mkOverlays system;}
./hosts/vno1-oh2/configuration.nix
./modules
agenix.nixosModules.default
home-manager.nixosModules.home-manager
{
age.secrets = {
motiejus-passwd-hash.file = ./secrets/motiejus_passwd_hash.age;
root-passwd-hash.file = ./secrets/root_passwd_hash.age;
zfs-passphrase-fra1-a.file = ./secrets/fra1-a/zfs-passphrase.age;
headscale-client-oidc.file = ./secrets/headscale/oidc_client_secret2.age;
sasl-passwd.file = ./secrets/postfix_sasl_passwd.age;
borgbackup-password.file = ./secrets/vno1-oh2/borgbackup/password.age;
grafana-oidc.file = ./secrets/grafana.jakstys.lt/oidc.age;
letsencrypt-account-key.file = ./secrets/letsencrypt/account.key.age;
vaultwarden-secrets-env.file = ./secrets/vaultwarden/secrets.env.age;
synapse-jakstys-signing-key.file = ./secrets/synapse/jakstys_lt_signing_key.age;
synapse-registration-shared-secret.file = ./secrets/synapse/registration_shared_secret.age;
synapse-macaroon-secret-key.file = ./secrets/synapse/macaroon_secret_key.age;
};
}
];
2023-07-22 16:05:44 +03:00
2023-11-27 18:17:27 +02:00
specialArgs = {inherit myData;} // inputs;
};
2023-07-22 16:05:44 +03:00
2023-11-27 18:17:27 +02:00
fwminex = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
{nixpkgs.overlays = mkOverlays system;}
./hosts/fwminex/configuration.nix
./modules
./modules/profiles/desktop
nur.nixosModules.nur
agenix.nixosModules.default
home-manager.nixosModules.home-manager
nixos-hardware.nixosModules.framework-12th-gen-intel
nix-index-database.nixosModules.nix-index
{
age.secrets = {
motiejus-passwd-hash.file = ./secrets/motiejus_passwd_hash.age;
root-passwd-hash.file = ./secrets/root_passwd_hash.age;
sasl-passwd.file = ./secrets/postfix_sasl_passwd.age;
};
}
];
2023-09-13 12:17:43 +03:00
2023-11-27 18:17:27 +02:00
specialArgs = {inherit myData;} // inputs;
};
2023-09-13 12:17:43 +03:00
2023-11-27 18:17:27 +02:00
vno3-rp3b = nixpkgs.lib.nixosSystem rec {
system = "aarch64-linux";
modules = [
{nixpkgs.overlays = mkOverlays system;}
./hosts/vno3-rp3b/configuration.nix
2023-08-15 07:09:11 +03:00
2023-11-27 18:17:27 +02:00
./modules
2023-08-15 07:09:11 +03:00
2023-11-27 18:17:27 +02:00
agenix.nixosModules.default
home-manager.nixosModules.home-manager
2023-08-15 07:09:11 +03:00
2023-11-27 18:17:27 +02:00
{
age.secrets = {
motiejus-passwd-hash.file = ./secrets/motiejus_passwd_hash.age;
root-passwd-hash.file = ./secrets/root_passwd_hash.age;
sasl-passwd.file = ./secrets/postfix_sasl_passwd.age;
2023-11-27 18:17:27 +02:00
datapool-passphrase.file = ./secrets/vno3-rp3b/datapool-passphrase.age;
};
}
];
2023-08-15 07:09:11 +03:00
2023-11-27 18:17:27 +02:00
specialArgs = {inherit myData;} // inputs;
};
2023-08-15 07:09:11 +03:00
2023-11-27 18:17:27 +02:00
fra1-a = nixpkgs.lib.nixosSystem rec {
system = "aarch64-linux";
modules = [
{nixpkgs.overlays = mkOverlays system;}
./hosts/fra1-a/configuration.nix
2023-08-26 07:18:27 +03:00
2023-11-27 18:17:27 +02:00
./modules
2023-08-26 07:18:27 +03:00
2023-11-27 18:17:27 +02:00
agenix.nixosModules.default
home-manager.nixosModules.home-manager
2023-08-26 07:18:27 +03:00
2023-11-27 18:17:27 +02:00
{
age.secrets = {
zfs-passphrase-vno1-oh2.file = ./secrets/vno1-oh2/zfs-passphrase.age;
motiejus-passwd-hash.file = ./secrets/motiejus_passwd_hash.age;
root-passwd-hash.file = ./secrets/root_passwd_hash.age;
sasl-passwd.file = ./secrets/postfix_sasl_passwd.age;
};
}
];
2023-08-26 07:18:27 +03:00
2023-11-27 18:17:27 +02:00
specialArgs = {inherit myData;} // inputs;
};
2023-08-26 07:18:27 +03:00
};
2023-11-27 18:17:27 +02:00
deploy.nodes = {
vno1-oh2 = {
hostname = myData.hosts."vno1-oh2.servers.jakst".jakstIP;
profiles = {
system = {
sshUser = "motiejus";
path =
deployPkgsIA64.deploy-rs.lib.activate.nixos self.nixosConfigurations.vno1-oh2;
user = "root";
};
2023-07-22 16:05:44 +03:00
};
};
2023-11-27 18:17:27 +02:00
fwminex = {
hostname = myData.hosts."fwminex.motiejus.jakst".jakstIP;
profiles = {
system = {
sshUser = "motiejus";
path =
deployPkgsIA64.deploy-rs.lib.activate.nixos self.nixosConfigurations.fwminex;
user = "root";
};
2023-09-15 15:05:25 +03:00
};
};
2023-11-27 18:17:27 +02:00
vno3-rp3b = {
hostname = myData.hosts."vno3-rp3b.servers.jakst".jakstIP;
profiles = {
system = {
sshUser = "motiejus";
path =
deployPkgsArm64.deploy-rs.lib.activate.nixos self.nixosConfigurations.vno3-rp3b;
user = "root";
};
2023-08-16 15:58:35 +03:00
};
};
2023-08-15 07:09:11 +03:00
2023-11-27 18:17:27 +02:00
fra1-a = {
hostname = myData.hosts."fra1-a.servers.jakst".jakstIP;
profiles = {
system = {
sshUser = "motiejus";
path =
deployPkgsArm64.deploy-rs.lib.activate.nixos self.nixosConfigurations.fra1-a;
user = "root";
};
2023-08-26 07:18:27 +03:00
};
};
};
2023-10-01 22:45:00 +03:00
checks =
2023-10-01 22:51:53 +03:00
builtins.mapAttrs (
system: deployLib:
deployLib.deployChecks self.deploy
2023-10-07 09:45:01 +03:00
#// self.homeConfigurations.${system}.motiejusja.activationPackage
2023-10-01 22:51:53 +03:00
// {
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
deadnix.enable = true;
2023-11-27 17:54:44 +02:00
statix.enable = true;
2023-10-01 22:51:53 +03:00
};
};
}
)
deploy-rs.lib;
2023-04-03 16:50:52 +03:00
}
// flake-utils.lib.eachDefaultSystem (system: let
2023-10-09 12:15:07 +03:00
pkgs = import nixpkgs {
inherit system;
overlays = [
2023-12-11 08:50:50 +02:00
nur.overlay
2023-12-14 10:10:00 +02:00
nixgl.overlay
2023-10-09 12:15:07 +03:00
(_final: prev: {
zigpkgs = import zigpkgs {
inherit (prev) pkgs;
inherit system;
};
})
];
};
2023-04-03 16:50:52 +03:00
in {
homeConfigurations.motiejusja = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
shared/home
];
2023-10-06 14:32:52 +03:00
extraSpecialArgs = {
stateVersion = "23.05";
email = "motiejusja@wix.com";
2023-12-11 20:05:32 +02:00
fullDesktop = true;
2023-10-27 10:31:00 +03:00
hmOnly = true;
2023-10-06 14:32:52 +03:00
};
};
2023-09-30 16:55:45 +03:00
devShells.default = pkgs.mkShellNoCC {
packages = [
pkgs.rage
pkgs.ssh-to-age
pkgs.age-plugin-yubikey
pkgs.deploy-rs
agenix.packages.${system}.agenix
];
2023-10-01 22:51:53 +03:00
inherit (inputs.self.checks.${system}.pre-commit-check) shellHook;
2023-09-30 16:55:45 +03:00
};
2023-04-03 16:50:52 +03:00
formatter = pkgs.alejandra;
2023-04-03 16:43:34 +03:00
});
2023-03-29 17:50:55 +03:00
}