Files
nixos/flake.nix
T
2026-11-20 13:49:35 -08:00

236 lines
7.1 KiB
Nix

{
description = "NixOS config flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-25.11-darwin";
nix-darwin.url = "github:LnL7/nix-darwin/nix-darwin-25.11";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs-darwin";
nixgl.url = "github:nix-community/nixGL";
nixgl.inputs.nixpkgs.follows = "nixpkgs";
# Secrets management.
sops-nix = {
url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager-unstable = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# Declarative flatpaks.
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
ghostty = {
url = "github:ghostty-org/ghostty";
};
# Wayland app-launcher
walker = {
url = "github:abenz1267/walker/v0.12.23";
};
# ssh-agent forwarder for linux.
ssh-agent-switcher = {
url = "github:AYM1607/ssh-agent-switcher/6cd7ce973cf08656d42e475945216d8c0f0b0c7b";
};
opencode-tunneler = {
url = "github:AYM1607/opencode-tunneler";
inputs.nixpkgs.follows = "nixpkgs-unstable"; # Use same nixpkgs
};
godig = {
url = "github:AYM1607/godig/v0.2.0";
inputs.nixpkgs.follows = "nixpkgs-unstable"; # Use same nixpkgs
};
# Zen browser.
zen-browser = {
url = "github:0xc000022070/zen-browser-flake";
inputs = {
# IMPORTANT: we're using "libgbm" and is only available in unstable so ensure
# to have it up-to-date or simply don't specify the nixpkgs input
nixpkgs.follows = "nixpkgs-unstable";
home-manager.follows = "home-manager";
};
};
};
outputs = {
self,
nixpkgs,
nixpkgs-unstable,
nix-darwin,
home-manager,
ghostty,
nixgl,
ssh-agent-switcher,
opencode-tunneler,
godig,
...
}@inputs: {
nixosConfigurations = {
devbox = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs ghostty;
};
modules = [
./hosts/devbox/configuration.nix
home-manager.nixosModules.home-manager
({ config, ... }: {
home-manager.extraSpecialArgs = {
inherit inputs ssh-agent-switcher;
inherit (config) user;
homeConfigurationName = "devbox";
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jmug = import ./hosts/devbox/home.nix;
home-manager.users.root = import ./hosts/devbox/home-root.nix;
})
];
};
nixbox = let
pkgs-unstable_x86_64-linux = import nixpkgs-unstable {
system = "x86_64-linux";
config = {
allowUnfree = true;
};
};
in nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs ghostty;
};
modules = [
./hosts/nixbox/configuration.nix
home-manager.nixosModules.home-manager
({config, ...}: {
home-manager.extraSpecialArgs = {
pkgs-unstable = pkgs-unstable_x86_64-linux;
inherit inputs;
inherit ssh-agent-switcher;
inherit (config) user;
homeConfigurationName = "nixbox";
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jmug = import ./hosts/nixbox/home.nix;
})
];
};
};
# Build darwin flake using:
# $ darwin-rebuild build --flake .#macbook
darwinConfigurations = let
pkgs-unstable_aarch64-darwin = import nixpkgs-unstable {
system = "aarch64-darwin";
config = {
allowUnfree = true;
};
};
in {
"macbook" = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
specialArgs = {
inherit inputs ghostty self;
};
modules = [
./hosts/macbook/configuration.nix
home-manager.darwinModules.home-manager
({ config, ... }: {
home-manager.extraSpecialArgs = {
pkgs-unstable = pkgs-unstable_aarch64-darwin;
inherit (config) user;
inherit opencode-tunneler;
inherit godig;
homeConfigurationName = "macbook";
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jmug.imports = [ ./hosts/macbook/home.nix ];
})
];
};
};
homeConfigurations = let
pkgs-unstable_x86_64-linux = import nixpkgs-unstable {
system = "x86_64-linux";
config = {
allowUnfree = true;
};
};
pkgs-unstable_aarch64-linux = import nixpkgs-unstable {
system = "aarch64-linux";
config = {
allowUnfree = true;
};
};
in {
alarm = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."aarch64-linux";
modules = [
./users/alarm/home.nix
];
};
# Ubuntu desktop.
# Apply with ./ubuntu/bootstrap.sh on first install (safe to rerun to sync).
ubuntu = let
pkgs = import nixpkgs-unstable {
system = "x86_64-linux";
config.allowUnfree = true;
overlays = [
# Use the host's flatpak. Ubuntu sets
# kernel.apparmor_restrict_unprivileged_userns=1 so so nixpkgs'
# flatpak can't sandbox extra-data installs (e.g. Slack's apply_extra).
(final: prev: {
flatpak = final.writeShellScriptBin "flatpak" ''exec /usr/bin/flatpak "$@"'';
})
];
};
in inputs.home-manager-unstable.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {
inherit inputs;
homeConfigurationName = "ubuntu";
# Shared modules take a pkgs-unstable arg, for this config pkgs-unstable and pkgs are the same.
pkgs-unstable = pkgs;
};
modules = [
./hosts/ubuntu/home.nix
];
};
# For machines that don't run NixOS.
devbox = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."x86_64-linux";
extraSpecialArgs = {
homeConfigurationName = "devbox";
pkgs-unstable = pkgs-unstable_x86_64-linux;
};
modules = [
./users/devbox/home.nix
];
};
armdevbox = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."aarch64-linux";
extraSpecialArgs = {
homeConfigurationName = "armdevbox";
pkgs-unstable = pkgs-unstable_aarch64-linux;
};
modules = [
./users/devbox/home.nix
];
};
};
};
}