diff --git a/flake.nix b/flake.nix index 4bb16e9..679d075 100644 --- a/flake.nix +++ b/flake.nix @@ -18,12 +18,16 @@ fs = pkgs.lib.fileset; st = pkgs.lib.strings; - hostConfig = extraModules: nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; + hostConfig = hostname: hostpath: nixpkgs.lib.nixosSystem { + specialArgs = { + inherit inputs; + inherit hostname; + }; system = system; modules = [ ./nixosModules - ] ++ extraModules; + hostpath + ]; }; hosts = let hostFilter = { name, ...}: name == "host.nix"; @@ -39,12 +43,16 @@ name = extractHostName path; }) hostPaths); - userConfig = extraModules: home-manager.lib.homeManagerConfiguration { + userConfig = usernameAtHostname: userpath: home-manager.lib.homeManagerConfiguration { inherit pkgs; - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = { + inherit inputs; + inherit usernameAtHostname; + }; modules = [ ./hmModules - ] ++ extraModules; + userpath + ]; }; users = let userFilter = { name, ...}: name == "user.nix"; @@ -63,7 +71,7 @@ } ) userPaths); in { - nixosConfigurations = builtins.mapAttrs (name: path: hostConfig [ path ]) hosts; - homeConfigurations = builtins.mapAttrs (name: path: userConfig [ path ]) users; + nixosConfigurations = builtins.mapAttrs (name: path: hostConfig name path) hosts; + homeConfigurations = builtins.mapAttrs (name: path: userConfig name path) users; }; } diff --git a/hosts/jibril/host.nix b/hosts/jibril/host.nix index 840328b..249e9aa 100644 --- a/hosts/jibril/host.nix +++ b/hosts/jibril/host.nix @@ -4,9 +4,14 @@ imports = [ ./hardware.nix ]; - networking.hostName = "jibril"; - nixpkgs.config.allowUnfree = true; - system.stateVersion = "23.05"; + pipewire.enable = true; + polkit.enable = true; + bluetooth.enable = true; + wireless = { + enable = true; + networks = builtins.fromTOML (builtins.readFile ./networks.toml); + secretsFile = config.sops.secrets.wireless.path; + }; sops-nix = { enable = true; @@ -17,15 +22,6 @@ }; }; - pipewire.enable = true; - polkit.enable = true; - bluetooth.enable = true; - wireless = { - enable = true; - networks = builtins.fromTOML (builtins.readFile ./networks.toml); - secretsFile = config.sops.secrets.wireless.path; - }; - user.name = "pan"; user.timezone = "America/Los_Angeles"; diff --git a/hosts/onizuka/host.nix b/hosts/onizuka/host.nix index 5d3e23f..2fdaf05 100644 --- a/hosts/onizuka/host.nix +++ b/hosts/onizuka/host.nix @@ -4,10 +4,6 @@ imports = [ ./hardware.nix ]; - networking.hostName = "onizuka"; - nixpkgs.config.allowUnfree = true; - system.stateVersion = "23.05"; - nvidia.enable = true; pipewire.enable = true; polkit.enable = true; diff --git a/nixosModules/services/system/default.nix b/nixosModules/services/system/default.nix index 0f4bb75..5780ea3 100644 --- a/nixosModules/services/system/default.nix +++ b/nixosModules/services/system/default.nix @@ -1,4 +1,4 @@ -{ config, inputs, pkgs, lib, ... }: +{ config, inputs, pkgs, lib, hostname, ... }: { options = { @@ -15,6 +15,10 @@ boot.loader.timeout = 1; boot.loader.efi.canTouchEfiVariables = true; + networking.hostName = hostname; + nixpkgs.config.allowUnfree = true; + system.stateVersion = "23.05"; + time.timeZone = config.user.timezone; i18n.defaultLocale = "en_US.UTF-8"; @@ -29,7 +33,7 @@ # XDG Compliance xdg.portal.config.common.default = "*"; - environment.sessionVariables = rec { + environment.sessionVariables = { XDG_CONFIG_HOME = "\${HOME}/.config"; XDG_CACHE_HOME = "\${HOME}/.cache"; XDG_STATE_HOME = "\${HOME}/.local/state";