nixos/flake.nix
2024-03-26 20:49:28 -04:00

161 lines
5.3 KiB
Nix

{
description = "Your new nix config";
inputs = {
# Nixpkgs (usually unstable)
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# nixpkgs-master.url = "github:nixos/nixpkgs/master";
# Home manageKr
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# Darwin & Apple Silicon tools
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
apple-silicon.url = "github:tpwrules/nixos-apple-silicon";
# Secrets
sops-nix.url = "github:Mic92/sops-nix";
#sops-nix-darwin.url = "github:Kloenk/sops-nix?ref=darwin";
# Fancy stuff
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# Pro gamer move
nixos-generators.url = "github:nix-community/nixos-generators";
# Iceshrimpy
iceshrimp = {
url = "git+https://iceshrimp.dev/iceshrimp/packaging";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# Self
noe-sh = {
url = "git+https://codeberg.org/noe/personal-site";
inputs.nixpkgs.follows = "nixpkgs";
};
doll-repair = {
url = "git+https://codeberg.org/noe/doll.repair";
inputs.nixpkgs.follows = "nixpkgs";
};
tachikoma-fe = {
url = "git+https://codeberg.org/tachikoma/tachikoma-fe";
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig = {
extra-substituters = [
"https://nix-community.cachix.org"
"https://0uptime.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"0uptime.cachix.org-1:ctw8yknBLg9cZBdqss+5krAem0sHYdISkw/IFdRbYdE="
];
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
inherit (self) outputs;
forAllSystems = nixpkgs.lib.genAttrs [
"aarch64-linux"
"i686-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
mkNixos = modules: nixpkgs.lib.nixosSystem {
inherit modules;
specialArgs = { inherit inputs outputs; };
};
mkDarwin = system: modules: inputs.darwin.lib.darwinSystem {
inherit modules system inputs;
specialArgs = { inherit inputs outputs; };
};
mkHome = modules: pkgs: home-manager.lib.homeManagerConfiguration {
inherit modules pkgs;
extraSpecialArgs = { inherit inputs outputs; };
};
in {
# Your custom packages
# Acessible through 'nix build', 'nix shell', etc
packages = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in import ./pkgs { inherit pkgs; } //
{
proxmox-lxc = inputs.nixos-generators.nixosGenerate {
inherit system pkgs;
modules = [
./nixos/templates/proxmox-lxc.nix
];
format = "proxmox-lxc";
};
}
);
# Devshell for bootstrapping
# Acessible through 'nix develop' or 'nix-shell' (legacy)
devShells = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in import ./shell.nix { inherit pkgs; }
);
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays { inherit inputs; };
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
nixosModules = import ./modules/nixos;
# Reusable home-manager modules you might want to export
# These are usually stuff you would upstream into home-manager
homeManagerModules = import ./modules/home-manager;
# Reusable nix-darwin packages you might want to export
# These are usually hacks!
darwinModules = import ./modules/darwin;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
aerial = mkNixos [ ./nixos/hosts/aerial ]; # desktop
cider = mkNixos [ ./nixos/hosts/cider ]; # asahi m2 mba
drone = mkNixos [ ./nixos/hosts/drone ]; # spectre x360
ingress-proxy = mkNixos [ ./nixos/hosts/ingress-proxy ]; # nginx edge proxy
keylime = mkNixos [ ./nixos/hosts/keylime ]; # lab jump
monitoring = mkNixos [ ./nixos/hosts/monitoring ]; # Grafana, Prometheus, Jaeger, etc
ps2live = mkNixos [ ./nixos/hosts/ps2live ]; # PS2.LIVE stack + planetside stuff
thonkpad = mkNixos [ ./nixos/hosts/thonkpad ]; # t480
sapphic-engineer = mkNixos [ ./nixos/hosts/sapphic-engineer ]; # Akkoma, sapphic.engineer
porcelain-doll-repair = mkNixos [ ./nixos/hosts/porcelain-doll-repair ]; # Iceshrimp+Withdrawl, porcelain.doll.repair
};
darwinConfigurations = {
# in asahi => noe-air = mkDarwin "aarch64-darwin" [ ./darwin/hosts/noe-air ];
AMERMACC02G65A8MD6T = mkDarwin "x86_64-darwin" [ ./darwin/hosts/work-mac ];
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = {
# TODO: add generic standalone home-manager config
};
};
}