nix-conf/flake.nix
2024-10-27 01:36:51 -05:00

49 lines
1.6 KiB
Nix

{
description = "NixOS config";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
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";
};
};
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;
};
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;
};
modules = [ (users + "/${user}") ];
};}) (readDir users)
else {}
) (attrNames (readDir ./hosts)));
};
}