nixos/flake.nix
2025-03-13 01:29:44 +01:00

93 lines
2.4 KiB
Nix

{
description = "Main Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url = "github:nix-community/impermanence";
stylix = {
url = "github:danth/stylix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
home-manager.follows = "home-manager";
};
};
ags = {
url = "github:aylur/ags";
inputs.nixpkgs.follows = "nixpkgs";
inputs.astal = {
url = "github:aylur/astal";
inputs.nixpkgs.follows = "nixpkgs";
};
};
matshell = {
url = "github:Neurarian/matshell";
inputs.nixpkgs.follows = "nixpkgs";
inputs.ags.follows = "ags";
};
};
outputs = {
self,
nixpkgs,
home-manager,
...
} @ inputs: let
inherit (nixpkgs) lib;
systemFromHardwareConf =
hostname:
let
hardware = import ./hosts/${hostname}/hardware-configuration.nix;
args = builtins.functionArgs hardware // { lib.mkDefault = lib.id; };
in
(hardware args).nixpkgs.hostPlatform;
importNixpkgs = system: nixpkgs:
let
config.allowUnfreePredicate =
pkg:
builtins.elem (lib.getName pkg) (import ./unfree.nix).allowed;
in
import nixpkgs { inherit system config; };
makeHost = host: system:
lib.nixosSystem {
system = system;
pkgs = importNixpkgs system nixpkgs;
specialArgs = inputs;
modules = [
./hosts/${host}/default.nix
./hosts/${host}/hardware-configuration.nix
./system
{networking.hostName = host;}
./home
];
};
in {
nixosConfigurations = lib.pipe ./hosts [
builtins.readDir
(lib.filterAttrs (_: type: type == "directory"))
# (lib.filterAttrs (name: _: builtins.pathExists ./hosts/${name}/default.nix && builtins.pathExists ./hosts/${name}/hardware.nix && builtins.pathExists ./hosts/${name}/config.nix))
(builtins.mapAttrs (name: _: makeHost name (systemFromHardwareConf name)))
];
};
}