blob: 2c000fcaa71ce1971af27b6ab8d6e61ac4016f58 (
plain) (
tree)
|
|
{
description = "personal NixOS configurations";
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixos-25.11/nixexprs.tar.xz";
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:lnl7/nix-darwin/nix-darwin-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware = {
url = "github:NixOS/nixos-hardware/master";
};
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
my-go-tools.url = "git+https://code.fcuny.net/x";
};
outputs =
inputs@{
self,
nixpkgs,
darwin,
home-manager,
disko,
agenix,
treefmt-nix,
pre-commit-hooks,
emacs-overlay,
nur,
my-go-tools,
...
}:
let
supportedSystems = [
"aarch64-darwin"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor =
system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
self.overlays.default
agenix.overlays.default
emacs-overlay.overlay
nur.overlays.default
my-go-tools.overlays.default
];
};
nixSettings = {
nix.registry.nixpkgs = {
flake = nixpkgs;
};
};
defaultModules = [
nixSettings
agenix.nixosModules.age
disko.nixosModules.disko
home-manager.nixosModules.home-manager
./modules/default.nix
];
# Default modules for Darwin hosts
darwinDefaultModules = [
nixSettings
agenix.darwinModules.age
home-manager.darwinModules.home-manager
./modules/default-darwin.nix
];
machines = {
nixos = {
rivendell = {
system = "x86_64-linux";
config = ./machines/nixos/x86_64-linux/rivendell.nix;
};
bree = {
system = "x86_64-linux";
config = ./machines/nixos/x86_64-linux/bree.nix;
};
argonath = {
system = "x86_64-linux";
config = ./machines/nixos/x86_64-linux/argonath.nix;
};
iso = {
system = "x86_64-linux";
config = ./machines/nixos/x86_64-linux/iso.nix;
};
};
darwin = {
mba-m2 = {
system = "aarch64-darwin";
config = ./machines/darwin/aarch64-darwin/mba-m2.nix;
};
HQ-KWNY2VH41P = {
system = "aarch64-darwin";
config = ./machines/darwin/aarch64-darwin/HQ-KWNY2VH41P.nix;
};
};
};
nixosConfigurations = nixpkgs.lib.mapAttrs (
name: machine:
let
pkgs = pkgsFor machine.system;
in
nixpkgs.lib.nixosSystem {
inherit (machine) system;
specialArgs = {
hostName = name;
inherit self inputs;
hostConfigurations = nixpkgs.lib.mapAttrs (_: conf: conf.config) nixosConfigurations;
};
modules = [
{
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
system.nixos.versionSuffix = nixpkgs.lib.mkForce "git.${builtins.substring 0 11 nixpkgs.rev}";
nixpkgs.pkgs = pkgs;
environment.systemPackages = [ pkgs.git ];
}
]
++ defaultModules
++ [
machine.config
my-go-tools.nixosModules.default
];
}
) machines.nixos;
darwinConfigurations = nixpkgs.lib.mapAttrs (
name: machine:
let
pkgs = pkgsFor machine.system;
in
darwin.lib.darwinSystem {
inherit (machine) system;
specialArgs = {
hostName = name;
inherit self inputs;
};
modules = [
{
nixpkgs.pkgs = pkgs;
nixpkgs.hostPlatform = machine.system;
system.stateVersion = 5;
environment.systemPackages = [ pkgs.git ];
}
]
++ darwinDefaultModules
++ [ machine.config ];
}
) machines.darwin;
in
{
# Host configurations
inherit nixosConfigurations darwinConfigurations;
# Overlays
overlays.default = _final: prev: {
sapi = prev.callPackage ./pkgs/sapi { };
hashi = prev.callPackage ./pkgs/hashi { };
};
devShells = forAllSystems (
system:
let
pkgs = pkgsFor system;
# Treefmt configuration
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
deadnix.enable = true;
};
};
# Pre-commit hooks
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
check-merge-conflicts.enable = true;
deadnix.enable = true;
detect-private-keys.enable = true;
end-of-file-fixer.enable = true;
mixed-line-endings.enable = true;
shellcheck = {
enable = true;
excludes = [ "\\.envrc$" ];
};
flake-checker.enable = true;
treefmt = {
enable = true;
entry = "${treefmtEval.config.build.wrapper}/bin/treefmt --ci";
};
trim-trailing-whitespace.enable = true;
};
};
# Import any custom scripts
scripts = import ./flake/scripts {
inherit pkgs system inputs;
};
in
{
default = pkgs.mkShellNoCC {
inherit (pre-commit-check) shellHook;
packages =
with pkgs;
[
nixos-rebuild
git
agenix.packages."${system}".default
]
++ scripts.all;
};
}
);
formatter = forAllSystems (
system:
let
pkgs = pkgsFor system;
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
deadnix.enable = true;
};
};
in
treefmtEval.config.build.wrapper
);
checks = forAllSystems (
system:
let
pkgs = pkgsFor system;
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
deadnix.enable = true;
};
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
check-merge-conflicts.enable = true;
deadnix.enable = true;
detect-private-keys.enable = true;
end-of-file-fixer.enable = true;
mixed-line-endings.enable = true;
shellcheck = {
enable = true;
excludes = [ "\\.envrc$" ];
};
flake-checker.enable = true;
treefmt = {
enable = true;
entry = "${treefmtEval.config.build.wrapper}/bin/treefmt --ci";
};
trim-trailing-whitespace.enable = true;
};
};
in
{
inherit pre-commit-check;
}
);
};
}
|