nix-conf/flake.nix
2025-01-19 00:44:22 -05:00

76 lines
2.1 KiB
Nix

{
description = "NixOS config";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.11";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-programs-sqlite = {
url = "github:wamserma/flake-programs-sqlite";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko/latest";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
nixpkgs-stable,
home-manager,
flake-programs-sqlite,
...
} @ inputs: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
pkgs-stable = nixpkgs-stable.legacyPackages.${system};
in
with builtins;
with nixpkgs.lib.attrsets; {
nixosConfigurations = mapAttrs' (host: _: {
name = host;
value = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit pkgs-stable;
inherit flake-programs-sqlite;
inherit inputs;
};
modules = [(./hosts + "/${host}")];
};
}) (readDir ./hosts);
homeConfigurations = foldl' (a: b: a // b) {} (map (
host: let
users = ./hosts + "/${host}/users";
in
if pathExists users
then
mapAttrs' (user: _: {
name = "${user}@${host}";
value = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {
inherit pkgs-stable;
inherit (inputs) nix-gaming;
inherit inputs;
};
modules = [(users + "/${user}")];
};
}) (readDir users)
else {}
) (attrNames (readDir ./hosts)));
};
}