181 lines
5.1 KiB
Nix

{
description = "Martin's NixOS configuration - Based on EmergentMind/nix-config";
inputs = {
#
# ========= Official NixOS and HM Package Sources =========
#
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
# The next two are for pinning to stable vs unstable regardless of what the above is set to
# This is particularly useful when an upcoming stable release is in beta because you can effectively
# keep 'nixpkgs-stable' set to stable for critical packages while setting 'nixpkgs' to the beta branch to
# get a jump start on deprecation changes.
# See also 'stable-packages' and 'unstable-packages' overlays at 'overlays/default.nix"
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
#
# ========= Utilities =========
#
# Secrets management
sops-nix = {
url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Catppuccin theming
catppuccin = {
url = "github:catppuccin/nix";
};
# vim
nixvim = {
url = "github:nix-community/nixvim/nixos-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
# Bar
hyprpanel = {
url = "github:Jas-SinghFSU/HyprPanel";
};
# Spotify
spicetify-nix = {
url = "github:Gerg-L/spicetify-nix";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# Browser
zen-browser.url = "github:0xc000022070/zen-browser-flake";
# Video aggregator
grayjay.url = "github:rishabh5321/grayjay-flake";
};
outputs =
{
self,
nixpkgs,
home-manager,
...
}@inputs:
let
inherit (self) outputs;
common = import ./shared/common.nix;
theme = import ./shared/theme.nix;
#
# ========= Architectures =========
#
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
# ========== Extend lib with lib.custom ==========
# NOTE: This approach allows lib.custom to propagate into hm
# see: https://github.com/nix-community/home-manager/pull/3454
customLib = (_self: _super: { custom = import ./lib { inherit (nixpkgs) lib; }; });
lib = nixpkgs.lib.extend customLib;
libHm = home-manager.lib.extend customLib;
systems = [
{
hostName = "desktop";
system = "x86_64-linux";
}
{
hostName = "thinkpad";
system = "x86_64-linux";
}
];
in
{
#
# ========= Overlays =========
#
# Custom modifications/overrides to upstream packages
overlays = import ./overlays.nix { inherit inputs; };
#
# ========= Host Configurations =========
#
nixosConfigurations = builtins.listToAttrs (
builtins.map (
{
hostName,
system,
user ? {
name = common.username;
password = "temp";
},
version ? common.version,
}:
{
name = hostName;
value = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit
outputs
inputs
common
theme
lib
hostName
version
;
isDarwin = false;
};
modules = [
./hosts/${hostName}
home-manager.nixosModules.home-manager
{
home-manager = {
# Backups conflicting files in case of error
backupFileExtension = "bkp";
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit
inputs
common
theme
libHm
hostName
version
;
};
users.${user.name} = import ./hosts/${hostName}/home-manager;
};
}
{
nixpkgs.overlays = with inputs; [
hyprpanel.overlay
];
}
];
};
}
) systems
);
#
# ========= Formatting =========
#
# Nix formatter available through 'nix fmt' https://github.com/NixOS/nixfmt
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
#
# ========= DevShell =========
#
# Custom shell for bootstrapping on new hosts, modifying nix-config, and secrets management
devShells = forAllSystems (
system:
import ./shell.nix {
pkgs = nixpkgs.legacyPackages.${system};
}
);
};
}