nix-infra/flake.nix

66 lines
2.1 KiB
Nix
Raw Normal View History

2023-12-17 13:33:15 +00:00
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable";
2024-03-24 18:02:28 +00:00
flake-utils.url = "github:numtide/flake-utils";
2023-12-17 13:33:15 +00:00
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
2024-03-24 18:02:29 +00:00
outputs =
2024-03-24 18:02:30 +00:00
inputs @ { self, nixpkgs, nixpkgs-unstable, home-manager, ... }:
2024-03-24 18:02:29 +00:00
let
inherit (self) outputs;
2024-03-24 18:02:30 +00:00
systems = [ "aarch64-linux" "i686-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
2024-03-24 18:02:29 +00:00
forEachSystem = f: lib.genAttrs systems (system: f);
forAllSystems = lib.genAttrs systems;
lib = nixpkgs.lib // home-manager.lib;
2024-03-24 18:02:30 +00:00
mkHost = { hostname, user ? "sammy", }: {
imports = [ ./hosts/${hostname}/configuration.nix ./modules/nixos/common.nix (import "${home-manager}/nixos") ];
2024-03-24 18:02:27 +00:00
2024-03-24 18:02:30 +00:00
deployment = {
targetUser = user;
allowLocalDeployment = true;
2024-03-24 18:02:29 +00:00
};
2024-03-24 18:02:30 +00:00
};
2024-03-24 18:02:29 +00:00
in
{
inherit lib;
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
2024-03-24 18:02:29 +00:00
devShells = forAllSystems (system:
let pkgs = import nixpkgs { system = system; }; in
{
2024-03-24 18:02:30 +00:00
default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ nix colmena git pkgs.home-manager ]; };
});
2024-03-24 18:02:30 +00:00
colmena = {
meta = {
description = "All my NixoS machines";
specialArgs = { inherit inputs outputs; };
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
2024-03-24 18:02:29 +00:00
};
2024-03-24 18:02:25 +00:00
2024-03-24 18:02:30 +00:00
bengal = mkHost { hostname = "bengal"; };
maine-coon = mkHost { hostname = "maine-coon"; };
};
2024-03-24 18:02:29 +00:00
nixosConfigurations.test = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
2024-03-24 18:02:30 +00:00
specialArgs = { inherit inputs outputs; };
modules = [ ./modules ./hosts/test-vm/configuration.nix (import "${home-manager}/nixos") ];
2024-03-24 18:02:23 +00:00
};
2024-03-24 18:02:30 +00:00
homeConfigurations.sammy =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./modules/users/sammy.nix ];
};
2023-12-17 13:33:15 +00:00
};
}