{ outputs = { self, nixpkgs, ... }@inputs: let lib = import ./lib { inherit nixpkgs; }; inherit (lib) forEachSupportedSystem pkgsFor; systems = let inherit (inputs) home-manager lanzaboote nix-darwin nixpkgs ; inherit (nixpkgs.lib) flatten hasSuffix mkAliasOptionModule strings ; systemFn = system: if hasSuffix "darwin" system then nix-darwin.lib.darwinSystem else if hasSuffix "linux" system then nixpkgs.lib.nixosSystem else throw "System: ${system} not supported."; homeModule = system: if hasSuffix "darwin" system then home-manager.darwinModules.home-manager else if hasSuffix "linux" system then home-manager.nixosModules.home-manager else throw "System: ${system} not supported."; in { mkSystem = system: { profile ? "minimal", machine ? { }, modules ? [ ], specialArgs ? { }, }: systemFn system { inherit specialArgs; modules = flatten ( modules ++ [ ( if hasSuffix "darwin" system then home-manager.darwinModules.home-manager else if hasSuffix "linux" system then [ home-manager.nixosModules.home-manager lanzaboote.nixosModules.lanzaboote ] else throw "System: ${system} not supported." ) ./modules/machine.nix ./profiles/${strings.concatStrings (lib.drop 1 (strings.splitString "-" system))}/${profile}.nix ./machines/${machine.hostName}/system.nix { imports = [ (mkAliasOptionModule [ "hm" ] [ "home-manager" "users" "${machine.mainUser}" ] ) ]; config = { machine = machine; home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; } // lib.optionalAttrs (lib.hasSuffix "linux" system) { hm.home.homeDirectory = "/home/${machine.mainUser}"; } // lib.optionalAttrs (lib.hasSuffix "darwin" system) { users.users.${machine.mainUser}.home = "/Users/pml"; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "obsidian" ]; }; } ] ); }; }; mkDarwinSystem = { modules ? [ ], machine, specialArgs ? { }, system ? { }, home ? { }, }: inputs.nix-darwin.lib.darwinSystem { specialArgs = specialArgs // { inherit inputs; }; modules = [ { system.configurationRevision = self.rev or self.dirtyRev or null; } inputs.home-manager.darwinModules.home-manager ./modules/machine.nix ./machines/${machine.hostName}/system.nix { config.machine = machine; } { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; environment.etc = { "1password" = { target = "1password/custom_allowed_browsers"; enable = true; text = '' firefox brave ''; # mode = "0755"; }; }; } ( { config, ... }: { users.users.pml.home = "/Users/pml"; hm.home.username = "pml"; } ) ] ++ modules; }; in { nixosConfigurations."persephone" = systems.mkSystem "x86_64-linux" { profile = "desktop"; machine = { hostName = "persephone"; mainUser = "pml"; filesystem.uuid = { boot = "cb03cf78-715e-4030-ba82-189ff8897eaf"; esp = "4E4C-1139"; luks = "0cf52ea1-16d1-4dec-a69a-bdac82bbcf25"; cryptroot = "6fb9ce3c-c870-4eb7-8199-6536ff898701"; }; }; modules = [ ./home.nix ]; }; darwinConfigurations."hermes" = systems.mkSystem "aarch64-darwin" { profile = "desktop"; machine = { hostName = "hermes"; mainUser = "pml"; }; modules = [ ./home.nix ]; }; devShells = forEachSupportedSystem ( { pkgs, system }: { default = pkgs.mkShellNoCC { packages = with pkgs; [ self.formatter.${system} nixd ]; }; } ); formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style); }; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11"; nix-darwin.url = "github:nix-darwin/nix-darwin?ref=nix-darwin-25.11"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; home-manager.url = "github:nix-community/home-manager?ref=release-25.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; lanzaboote.url = "github:nix-community/lanzaboote?ref=master"; lanzaboote.inputs.nixpkgs.follows = "nixpkgs"; }; }