From ee29846e7ad20b2a1f3efe372b72b90ce48b02ec Mon Sep 17 00:00:00 2001 From: Lgmrszd Date: Thu, 30 May 2024 20:33:20 +0300 Subject: [PATCH] flake.nix: cleanup, generalize hosts --- flake.nix | 56 +++++++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/flake.nix b/flake.nix index 2c9568d..112245f 100644 --- a/flake.nix +++ b/flake.nix @@ -3,9 +3,6 @@ inputs = { 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"; flake-parts.url = "github:hercules-ci/flake-parts"; @@ -42,7 +39,6 @@ outputs = inputs@{ nixpkgs, - # nixpkgs-fresh, nixpkgs-stable, home-manager, sops-nix, @@ -52,39 +48,41 @@ }: let system = "x86_64-linux"; - # overlay-fresh = final: prev: { - # fresh = import nixpkgs-fresh { + # overlay-stable = final: prev: { + # stable = import nixpkgs-stable { # inherit system; # config.allowUnfree = true; # }; # }; - overlay-stable = final: prev: { - stable = import nixpkgs-stable { - inherit system; - config.allowUnfree = true; - }; - }; overlay-vaapiIntel = final: prev: { vaapiIntel = prev.vaapiIntel.override { enableHybridCodec = true; }; }; my-overlays = [ - # overlay-fresh # overlay-stable overlay-vaapiIntel ]; 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 { - nixosConfigurations.lgm-nixos = nixpkgs.lib.nixosSystem rec { - inherit system; - modules = [ - ({ config, pkgs, ... }: { nixpkgs.overlays = my-overlays; }) - ./hosts/laptop/configuration.nix - ./hosts/laptop/hardware-configuration.nix + nixosConfigurations.lgm-nixos = mkHostConfig { + host = "laptop"; + extraModules = [ ./hosts/laptop/mounts.nix - # nix-index-database.nixosModules.nix-index - sops-nix.nixosModules.sops - home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -93,19 +91,11 @@ } ]; }; - nixosConfigurations.lgm-vps1 = let - data = import ./hosts/vps1/data // (if extra-data ? vps1 then extra-data.vps1 else {}); - in - nixpkgs.lib.nixosSystem rec { - inherit system; - specialArgs = { inherit data; }; - modules = [ - ({ config, pkgs, ... }: { nixpkgs.overlays = my-overlays; }) + nixosConfigurations.lgm-vps1 = mkHostConfig { + host = "vps1"; + extraModules = [ mailserver.nixosModule authentik-nix.nixosModules.default - ./hosts/vps1/configuration.nix - ./hosts/vps1/hardware-configuration.nix - sops-nix.nixosModules.sops ]; }; };