[NixOS] Automatically add configurations for machine files

This commit is contained in:
Ivan Malison 2021-08-20 19:19:50 -06:00
parent 5b9febb4d8
commit 4fbef3f0a3
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
4 changed files with 37 additions and 58 deletions

View File

@ -51,32 +51,38 @@
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.imalison = import ./home-manager.nix; home-manager.users.imalison = import ./home-manager.nix;
}); });
mkNixosConfig = args@{ system ? "x86_64-linux", baseModules ? [ forAll ], modules ? [], specialArgs ? {}, ... }: mkConfig = args@{ system ? "x86_64-linux", baseModules ? [ forAll ], modules ? [], specialArgs ? {}, ... }:
nixpkgs.lib.nixosSystem (args // { nixpkgs.lib.nixosSystem (args // {
inherit system; inherit system;
modules = baseModules ++ modules; modules = baseModules ++ modules;
specialArgs = { inherit inputs; } // specialArgs; specialArgs = { inherit inputs; } // specialArgs;
}); });
in machineFilenames = builtins.attrNames (builtins.readDir ./machines);
{ machineNameFromFilename = filename: builtins.head (builtins.split "\\." filename);
nixosConfigurations = { mkConfigurationParams = filename: {
ivanm-dfinity-razer = mkNixosConfig { name = machineNameFromFilename filename;
modules = [ ./machines/ivanm-dfinity-razer.nix ]; value = {
}; modules = [ (./machines + ("/" + filename)) ];
ryzen-shine = mkNixosConfig {
modules = [ ./machines/ryzen-shine.nix ];
};
adele = mkNixosConfig {
modules = [ ./machines/adele.nix ];
};
biskcomp = mkNixosConfig {
system = "aarch64-linux";
modules = [ ./machines/biskcomp.nix ];
};
air-gapped-pi = mkNixosConfig {
system = "aarch64-linux";
modules = [ ./machines/air-gapped-pi.nix ];
};
}; };
}; };
defaultConfigurationParams =
builtins.listToAttrs (map mkConfigurationParams machineFilenames);
customParams = {
biskcomp = {
system = "aarch64-linux";
};
air-gapped-pi = {
system = "aarch64-linux";
};
};
in
{
nixosConfigurations = builtins.mapAttrs (machineName: params:
let machineParams =
if builtins.hasAttr machineName customParams
then (builtins.getAttr machineName customParams)
else {};
in mkConfig (params // machineParams)
) defaultConfigurationParams;
};
} }

View File

@ -7,7 +7,6 @@
networking.hostName = "air-gapped-pi"; networking.hostName = "air-gapped-pi";
hardware.video.hidpi.enable = true; hardware.video.hidpi.enable = true;
networking.enable = false;
system.stateVersion = "21.05"; system.stateVersion = "21.05";
} }

View File

@ -2,11 +2,12 @@
{ {
imports = [ imports = [
<nixpkgs/nixos/modules/installer/scan/not-detected.nix> ../users.nix
../full.nix ../full.nix
# ../cachix.nix
]; ];
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
@ -45,43 +46,15 @@
nix.maxJobs = lib.mkDefault 4; nix.maxJobs = lib.mkDefault 4;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
boot.initrd.luks.devices = [ # boot.initrd.luks.devices."cryptroot" = {
{ # name = "root";
name = "root"; # device = "/dev/sda3";
device = "/dev/sda3"; # preLVM = true;
preLVM = true; # };
}
];
networking.hostName = "imalison-home"; networking.hostName = "imalison-home";
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
services.samba = {
enable = true;
syncPasswordsByPam = true;
extraConfig = ''
workgroup = WORKGROUP
server string = smbnix
netbios name = smbnix
#use sendfile = yes
#max protocol = smb2
hosts allow = 192.168.0 localhost
hosts deny = 0.0.0.0/0
'';
shares = {
private = {
path = "/backups";
browseable = "yes";
"read only" = "no";
"guest ok" = "no";
"create mask" = "0644";
"directory mask" = "0755";
"force user" = "username";
"force group" = "groupname";
};
};
};
services.xserver = { services.xserver = {
screenSection = '' screenSection = ''
DefaultDepth 24 DefaultDepth 24

View File

@ -2,12 +2,13 @@
{ {
imports = [ imports = [
<nixpkgs/nixos/modules/installer/scan/not-detected.nix>
../full.nix ../full.nix
../games.nix ../games.nix
../extra.nix ../extra.nix
]; ];
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ pkgs.linuxPackages.rtl8814au ]; boot.extraModulePackages = [ pkgs.linuxPackages.rtl8814au ];