{ flake-lib, inputs, inputs', self', theme, stdenv, lib, }: let inherit (stdenv) isDarwin isLinux; username = flake-lib.const.user; darwin-specific = [ inputs.home-manager.darwinModules.home-manager { services.nix-daemon.enable = true; security.pam.enableSudoTouchIdAuth = true; users.users.${username}.home = "/Users/${username}"; } ]; linux-specific = [ inputs.home-manager.nixosModules.home-manager { programs.mosh.enable = true; system.stateVersion = "22.05"; users.users.${username} = { isNormalUser = true; extraGroups = ["wheel"]; home = "/home/${username}"; group = username; }; } ]; # TODO: Make those overridable builder = if isDarwin then inputs.darwin.lib.darwinSystem else if isLinux then inputs.nixpkgs.lib.nixosSystem else throw "Unsupported system"; in { system ? {}, user ? {}, }: builder { system = stdenv.system; modules = [ system ({ lib, pkgs, ... }: { _module.args = { inherit inputs' self' theme; user = username; # nix-darwin already declares inputs attribute (thanks nix-darwin)< # but since we're passing all flake inputs this should be fine inputs = lib.mkForce inputs; }; nix = { package = pkgs.nixVersions.stable; registry = lib.mapAttrs (_: flake: {inherit flake;}) inputs; settings = { experimental-features = ["nix-command" "flakes"]; trusted-users = [username]; }; }; programs.fish.enable = true; environment.shells = [pkgs.fish]; users.users.${username}.shell = pkgs.fish; home-manager = { useGlobalPkgs = true; useUserPackages = true; users.${username} = flake-lib.mkHome user; }; time.timeZone = "Europe/Warsaw"; }) ] ++ (lib.optionals isDarwin darwin-specific) ++ (lib.optionals isLinux linux-specific); }