Skip to content

Commit

Permalink
Merge pull request #5 from michaelvanstraten/initial-nixos-configs
Browse files Browse the repository at this point in the history
Add initial nixos configuration for first rack machine
  • Loading branch information
michaelvanstraten authored Sep 1, 2024
2 parents 15e1cf2 + 6dc08c6 commit fdecf62
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 0 deletions.
22 changes: 22 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@
...
}@inputs:
{
nixosConfigurations =
let
lib = nixpkgs.lib;
hostConfigurations = lib.filesystem.listFilesRecursive ./nixos/hosts;
in
lib.mergeAttrsList (
builtins.map (
hostConfiguration:
let
nixosConfiguration = nixpkgs.lib.nixosSystem {
modules = [ hostConfiguration ];
specialArgs = {
make-disk-image = import "${nixpkgs}/nixos/lib/make-disk-image.nix";
};
};
in
{
${nixosConfiguration.config.networking.hostName} = nixosConfiguration;
}
) hostConfigurations
);

# apps = nixinate.nixinate.aarch64-linux self;
}
// flake-utils.lib.eachDefaultSystem (
Expand Down
19 changes: 19 additions & 0 deletions nixos/hosts/rack-01/k8s-master-nuc-01.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ ... }:
{
imports = [
../../modules
../../modules/hardware/intel-nuc.nix
../../modules/roles/k8s-master.nix
../../modules/format/raw-efi.nix
];

networking.hostName = "rack-01-k8s-master-nuc-01";

_module.args.nixinate = {
host = "tarox-1";
sshUser = "michael";
buildOn = "remote";
substituteOnTarget = true;
hermetic = false;
};
}
12 changes: 12 additions & 0 deletions nixos/modules/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ ... }:
{
system.stateVersion = "25.11";

console.keyMap = "de";

imports = [
./nix.nix
./ssh.nix
./users.nix
];
}
14 changes: 14 additions & 0 deletions nixos/modules/format/raw-efi.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
config,
lib,
pkgs,
make-disk-image,
...
}:
{
system.build.disk-image = make-disk-image {
inherit config lib pkgs;
partitionTableType = "efi";
format = "raw";
};
}
30 changes: 30 additions & 0 deletions nixos/modules/hardware/intel-nuc.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ lib, ... }:
{
nixpkgs.hostPlatform = "x86_64-linux";

boot = {
growPartition = true;
kernelParams = [ "console=tty0" ];
initrd.availableKernelModules = [ "uas" ];
};

fileSystems."/boot" = {
device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};

boot.loader = {
timeout = lib.mkDefault 3;
grub = {
device = "nodev";
efiSupport = true;
efiInstallAsRemovable = true;
};
};

fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
autoResize = true;
fsType = "ext4";
};
}
13 changes: 13 additions & 0 deletions nixos/modules/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs, ... }:
{
nix = {
package = pkgs.nix;
settings = {
experimental-features = [
"nix-command"
"flakes"
];
trusted-users = [ "@wheel" ];
};
};
}
10 changes: 10 additions & 0 deletions nixos/modules/roles/k8s-master.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ lib, ... }:
{
services.etcd.enable = true;
# services.kubernetes = {
# apiserver.enable = lib.mkDefault true;
# scheduler.enable = lib.mkDefault true;
# controllerManager.enable = true;
# kubelet.enable = true;
# };
}
11 changes: 11 additions & 0 deletions nixos/modules/ssh.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ ... }:
{
services.openssh = {
enable = true;
ports = [ 62518 ];
settings = {
PasswordAuthentication = false;
PermitRootLogin = "no";
};
};
}
11 changes: 11 additions & 0 deletions nixos/modules/users.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ ... }:
{
users.users.michael = {
extraGroups = [ "wheel" ];
isNormalUser = true;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF8OCYTaHjQy7Y7bRmxzVwNBgnD9P21UQPzVpJ3NKwVV"
];
initialPassword = "fsbEh&PzR9Eo";
};
}

0 comments on commit fdecf62

Please sign in to comment.