System, get hostname from directory structure

This commit is contained in:
Julia Lange 2024-11-25 13:21:06 -08:00
parent 0e5c6ab2c2
commit 6124a298eb
Signed by: Julia
SSH key fingerprint: SHA256:KI8YxpkPRbnDRkXPgCuQCVz181++Vy7NAvmQj8alOhM
4 changed files with 30 additions and 26 deletions

View file

@ -18,12 +18,16 @@
fs = pkgs.lib.fileset; fs = pkgs.lib.fileset;
st = pkgs.lib.strings; st = pkgs.lib.strings;
hostConfig = extraModules: nixpkgs.lib.nixosSystem { hostConfig = hostname: hostpath: nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; }; specialArgs = {
inherit inputs;
inherit hostname;
};
system = system; system = system;
modules = [ modules = [
./nixosModules ./nixosModules
] ++ extraModules; hostpath
];
}; };
hosts = let hosts = let
hostFilter = { name, ...}: name == "host.nix"; hostFilter = { name, ...}: name == "host.nix";
@ -39,12 +43,16 @@
name = extractHostName path; name = extractHostName path;
}) hostPaths); }) hostPaths);
userConfig = extraModules: home-manager.lib.homeManagerConfiguration { userConfig = usernameAtHostname: userpath: home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
extraSpecialArgs = { inherit inputs; }; extraSpecialArgs = {
inherit inputs;
inherit usernameAtHostname;
};
modules = [ modules = [
./hmModules ./hmModules
] ++ extraModules; userpath
];
}; };
users = let users = let
userFilter = { name, ...}: name == "user.nix"; userFilter = { name, ...}: name == "user.nix";
@ -63,7 +71,7 @@
} }
) userPaths); ) userPaths);
in { in {
nixosConfigurations = builtins.mapAttrs (name: path: hostConfig [ path ]) hosts; nixosConfigurations = builtins.mapAttrs (name: path: hostConfig name path) hosts;
homeConfigurations = builtins.mapAttrs (name: path: userConfig [ path ]) users; homeConfigurations = builtins.mapAttrs (name: path: userConfig name path) users;
}; };
} }

View file

@ -4,9 +4,14 @@
imports = [ imports = [
./hardware.nix ./hardware.nix
]; ];
networking.hostName = "jibril"; pipewire.enable = true;
nixpkgs.config.allowUnfree = true; polkit.enable = true;
system.stateVersion = "23.05"; bluetooth.enable = true;
wireless = {
enable = true;
networks = builtins.fromTOML (builtins.readFile ./networks.toml);
secretsFile = config.sops.secrets.wireless.path;
};
sops-nix = { sops-nix = {
enable = true; 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.name = "pan";
user.timezone = "America/Los_Angeles"; user.timezone = "America/Los_Angeles";

View file

@ -4,10 +4,6 @@
imports = [ imports = [
./hardware.nix ./hardware.nix
]; ];
networking.hostName = "onizuka";
nixpkgs.config.allowUnfree = true;
system.stateVersion = "23.05";
nvidia.enable = true; nvidia.enable = true;
pipewire.enable = true; pipewire.enable = true;
polkit.enable = true; polkit.enable = true;

View file

@ -1,4 +1,4 @@
{ config, inputs, pkgs, lib, ... }: { config, inputs, pkgs, lib, hostname, ... }:
{ {
options = { options = {
@ -15,6 +15,10 @@
boot.loader.timeout = 1; boot.loader.timeout = 1;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = hostname;
nixpkgs.config.allowUnfree = true;
system.stateVersion = "23.05";
time.timeZone = config.user.timezone; time.timeZone = config.user.timezone;
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";
@ -29,7 +33,7 @@
# XDG Compliance # XDG Compliance
xdg.portal.config.common.default = "*"; xdg.portal.config.common.default = "*";
environment.sessionVariables = rec { environment.sessionVariables = {
XDG_CONFIG_HOME = "\${HOME}/.config"; XDG_CONFIG_HOME = "\${HOME}/.config";
XDG_CACHE_HOME = "\${HOME}/.cache"; XDG_CACHE_HOME = "\${HOME}/.cache";
XDG_STATE_HOME = "\${HOME}/.local/state"; XDG_STATE_HOME = "\${HOME}/.local/state";