flake-config/flake.nix
2025-11-26 13:20:46 -05:00

89 lines
2.8 KiB
Nix

{
description = "Nixos config flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-25.05";
unstable.url = "nixpkgs/nixos-unstable";
nid.url = "github:nix-community/nix-index-database";
nid.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
declarative-jellyfin.url = "github:Sveske-Juice/declarative-jellyfin";
declarative-jellyfin.inputs.nixpkgs.follows = "nixpkgs";
deploy-rs.url = "github:serokell/deploy-rs";
deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, unstable, ... }@inputs: let
base = [
# I've put these all here so that it's easier to see what's being
# imported by default
./modules/os.nix
./modules/server.nix
./modules/ssh.nix
./modules/time.nix
./modules/pkgs.nix
./modules/unstable.nix
./modules/zmotd.nix
./modules/sops.nix
./modules/users/admin.nix
./overlays
{ services.zmotd.enable = true; } # enable my motd service
{ programs.nix-ld.enable = true; } # use nix-ld cause nixos is a bit dumb
inputs.declarative-jellyfin.nixosModules.default # jellyfin :)
# use comma just in case I need to do some sysadmin stuff
inputs.nid.nixosModules.nix-index
{ programs.nix-index-database.comma.enable = true; }
# disko for completly declarative machines
inputs.disko.nixosModules.disko
];
# ts so DRY it makes me wanna cry
mkHosts = hosts:
(builtins.mapAttrs (name: modules:
nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = base ++ [
{ networking.hostName = name; }
./hosts/${name} # just specifying a directory uses default.nix
] ++ modules;
}
)) <| hosts;
mkNodes = nodes:
(builtins.mapAttrs (name: options:
nixpkgs.lib.attrsets.recursiveUpdate {
hostname = name;
profiles.system = {
user = "root";
sshUser = "crown";
path = inputs.deploy-rs.lib."x86_64-linux".activate.nixos self.nixosConfigurations.${name};
};
} options
)) <| nodes;
in {
# define all of my machines
nixosConfigurations = mkHosts {
blobercraft = [];
crayon = [];
};
# and where they get deployed to
deploy.nodes = mkNodes {
crayon = { hostname = "squi.bid"; };
};
# dev shell to deploy this flake
devShells."x86_64-linux".default = builtins.import ./shell.nix {
pkgs = nixpkgs.legacyPackages."x86_64-linux";
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
};
}