flake.nix: cleanup, generalize hosts

This commit is contained in:
Lgmrszd 2024-05-30 20:33:20 +03:00
parent d8b7ee6918
commit ee29846e7a
No known key found for this signature in database
GPG key ID: 9396B8BA6FBB14DE

View file

@ -3,9 +3,6 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# separate inputs to lock some packages
# fresh - mostly desktop apps
# nixpkgs-fresh.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11"; nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
@ -42,7 +39,6 @@
outputs = inputs@{ outputs = inputs@{
nixpkgs, nixpkgs,
# nixpkgs-fresh,
nixpkgs-stable, nixpkgs-stable,
home-manager, home-manager,
sops-nix, sops-nix,
@ -52,39 +48,41 @@
}: }:
let let
system = "x86_64-linux"; system = "x86_64-linux";
# overlay-fresh = final: prev: { # overlay-stable = final: prev: {
# fresh = import nixpkgs-fresh { # stable = import nixpkgs-stable {
# inherit system; # inherit system;
# config.allowUnfree = true; # config.allowUnfree = true;
# }; # };
# }; # };
overlay-stable = final: prev: {
stable = import nixpkgs-stable {
inherit system;
config.allowUnfree = true;
};
};
overlay-vaapiIntel = final: prev: { overlay-vaapiIntel = final: prev: {
vaapiIntel = prev.vaapiIntel.override { enableHybridCodec = true; }; vaapiIntel = prev.vaapiIntel.override { enableHybridCodec = true; };
}; };
my-overlays = [ my-overlays = [
# overlay-fresh
# overlay-stable # overlay-stable
overlay-vaapiIntel overlay-vaapiIntel
]; ];
inherit (inputs.nix-cfg-extra.lib) extra-data; inherit (inputs.nix-cfg-extra.lib) extra-data;
mkHostConfig = ({ host, extraModules ? [] }:
let
data = import ./hosts/${host}/data // (if extra-data ? host then extra-data.host else {});
in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit data; };
modules = [
{ nixpkgs.overlays = my-overlays; }
./hosts/${host}/configuration.nix
./hosts/${host}/hardware-configuration.nix
sops-nix.nixosModules.sops
] ++ extraModules;
});
in in
{ {
nixosConfigurations.lgm-nixos = nixpkgs.lib.nixosSystem rec { nixosConfigurations.lgm-nixos = mkHostConfig {
inherit system; host = "laptop";
modules = [ extraModules = [
({ config, pkgs, ... }: { nixpkgs.overlays = my-overlays; })
./hosts/laptop/configuration.nix
./hosts/laptop/hardware-configuration.nix
./hosts/laptop/mounts.nix ./hosts/laptop/mounts.nix
# nix-index-database.nixosModules.nix-index
sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
@ -93,19 +91,11 @@
} }
]; ];
}; };
nixosConfigurations.lgm-vps1 = let nixosConfigurations.lgm-vps1 = mkHostConfig {
data = import ./hosts/vps1/data // (if extra-data ? vps1 then extra-data.vps1 else {}); host = "vps1";
in extraModules = [
nixpkgs.lib.nixosSystem rec {
inherit system;
specialArgs = { inherit data; };
modules = [
({ config, pkgs, ... }: { nixpkgs.overlays = my-overlays; })
mailserver.nixosModule mailserver.nixosModule
authentik-nix.nixosModules.default authentik-nix.nixosModules.default
./hosts/vps1/configuration.nix
./hosts/vps1/hardware-configuration.nix
sops-nix.nixosModules.sops
]; ];
}; };
}; };