Files
cyper-nix/flake.nix
T

297 lines
8.3 KiB
Nix

{
description = "DerGrumpfs Nix Configuration";
inputs = {
# monorepo w/ recipes ("derivations")
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# declarative Configs
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
# NIX User Repositorys
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
# declarative Hyprland
hyprland = {
url = "github:hyprwm/Hyprland";
};
hyprland-plugins = {
url = "github:hyprwm/hyprland-plugins";
inputs.hyprland.follows = "hyprland";
};
hyprcursor = {
url = "github:hyprwm/hyprcursor";
inputs.nixpkgs.follows = "nixpkgs";
};
# system-level software and settings (macOS)
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
# declarative homebrew management
nix-homebrew = {
url = "github:zhaofengli/nix-homebrew";
};
# declarative Neovim
nixvim = {
url = "github:nix-community/nixvim";
};
# declarative Discord
nixcord = {
url = "github:kaylorben/nixcord";
inputs.nixpkgs.follows = "nixpkgs";
};
# declarative Spotify
spicetify-nix = {
url = "github:Gerg-L/spicetify-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# declarative Encryption
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# declarative Catppuccin
catppuccin = {
url = "github:catppuccin/nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
home-manager,
darwin,
nix-homebrew,
nixvim,
hyprland,
sops-nix,
nur,
...
}@inputs:
let
primaryUser = "phil";
/*
mkIso - Build a NixOS image for a given target.
Available targets (imageModule imageBuildAttr):
ISO (minimal) : "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" "isoImage"
ISO (graphical): "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix" "isoImage"
Amazon EC2 : "${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix" "amazonImage"
Linode : "${nixpkgs}/nixos/modules/virtualisation/linode-image.nix" "linodeImage"
Proxmox LXC : "${nixpkgs}/nixos/modules/virtualisation/proxmox-lxc.nix" "tarball"
Google Cloud : "${nixpkgs}/nixos/modules/virtualisation/google-compute-image.nix" "googleComputeImage"
Azure : "${nixpkgs}/nixos/modules/virtualisation/azure-image.nix" "azureImage"
QEMU (runnable): "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" "vm"
QEMU (headless): "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" "vmWithBootLoader"
- Claude Sonnet 4.6
*/
mkIso =
{
hostName,
isDarwin ? false,
isServer ? false,
imageModule ? "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix",
imageBuildAttr ? "isoImage",
}:
(nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit
inputs
primaryUser
self
hostName
isDarwin
isServer
;
};
modules = [
imageModule
{
nixpkgs.overlays = [
inputs.nur.overlays.default
(import ./overlays { inherit (inputs) nur; })
];
}
{ nixpkgs.config.allowUnfree = true; }
{ nixpkgs.hostPlatform = "x86_64-linux"; }
{ networking.hostName = hostName; }
./hosts/${hostName}/configuration.nix
./nixos
inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
extraSpecialArgs = {
inherit
inputs
primaryUser
self
hostName
isDarwin
isServer
;
};
users.${primaryUser} = import ./home;
backupFileExtension = "backup";
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [
{
programs.nixvim.nixpkgs.source = inputs.nixpkgs;
}
];
};
}
];
}).config.system.build.${imageBuildAttr};
mkSystem =
{
hostName,
system,
isDarwin ? false,
isServer ? false,
}:
let
systemFunc = if isDarwin then darwin.lib.darwinSystem else nixpkgs.lib.nixosSystem;
platformModuleSet = if isDarwin then "darwinModules" else "nixosModules";
sharedSpecialArgs = {
inherit
inputs
primaryUser
self
hostName
isDarwin
isServer
;
};
sharedModules = [
{ networking.hostName = hostName; }
{
nixpkgs = {
overlays = [ (import ./overlays { inherit (inputs) nur; }) ];
config.allowUnfree = true;
};
}
./hosts/${hostName}/configuration.nix
inputs.sops-nix.${platformModuleSet}.sops
inputs.home-manager.${platformModuleSet}.home-manager
{
home-manager = {
extraSpecialArgs = sharedSpecialArgs;
users.${primaryUser} = import ./home;
backupFileExtension = "hm-backup";
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [
{
programs.nixvim.nixpkgs.source = inputs.nixpkgs;
}
];
};
}
];
platformModules =
if isDarwin then
[
./darwin
inputs.nix-homebrew.darwinModules.nix-homebrew
]
else
[
{ nixpkgs.hostPlatform = system; }
./nixos
];
in
systemFunc {
inherit system;
modules = sharedModules ++ platformModules;
specialArgs = sharedSpecialArgs;
};
in
{
nixosConfigurations = {
"cyper-desktop" = mkSystem {
hostName = "cyper-desktop";
system = "x86_64-linux";
};
"cyper-controller" = mkSystem {
hostName = "cyper-controller";
system = "x86_64-linux";
isServer = true;
};
"cyper-proxy" = mkSystem {
hostName = "cyper-proxy";
system = "x86_64-linux";
isServer = true;
};
"cyper-node-1" = mkSystem {
hostName = "cyper-node-1";
system = "x86_64-linux";
isServer = true;
};
"cyper-node-2" = mkSystem {
hostName = "cyper-node-2";
system = "x86_64-linux";
isServer = true;
};
};
darwinConfigurations."cyper-mac" = mkSystem {
hostName = "cyper-mac";
system = "x86_64-darwin";
isDarwin = true;
};
packages.x86_64-linux = {
cyper-desktop-iso = mkIso { hostName = "cyper-desktop"; };
cyper-controller-iso = mkIso {
hostName = "cyper-controller";
isServer = true;
};
cyper-proxy-iso = mkIso {
hostName = "cyper-proxy";
isServer = true;
};
cyper-node-1-iso = mkIso {
hostName = "cyper-node-1";
isServer = true;
};
cyper-node-2-iso = mkIso {
hostName = "cyper-node-2";
isServer = true;
};
};
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-tree;
};
}