diff --git a/nix/homelab/configuration.nix b/nix/homelab/configuration.nix new file mode 100644 index 0000000..b2f8cd4 --- /dev/null +++ b/nix/homelab/configuration.nix @@ -0,0 +1,54 @@ +{ + config, + lib, + pkgs, + meta, + ... +}: + +{ + imports = [ + ./hardware-configuration.nix + ./disk-config.nix + ]; + + boot.loader.grub.enable = true; + boot.loader.grub.efiSupport = true; + boot.loader.grub.efiInstallAsRemovable = true; + boot.loader.grub.device = "/dev/nvme0n1"; + + networking.hostName = meta.hostname; + networking.networkmanager.enable = true; + + time.timeZone = "America/Vancouver"; + + services.k3s = { + enable = true; + role = "server"; + token = /var/lib/rancher/k3s/server/token; + clusterInit = true; + extraFlags = toString ([ + "--write-kubeconfig-mode \"0644\"" + ]); + }; + + users.users.luca = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + packages = with pkgs; [ + tree + ]; + hashedPassword = "$6$BZKOzqbNgj8F2JDm$KVpnMK1inaM0tnHSw6dIlA1oZ7sT/j7RQL4u5wa9RHYeHcqEFILTqi0HGKCYIwhCEWuJIhBv3h.tjSCZ/j6yw/"; + }; + + environment.systemPackages = with pkgs; [ + neovim + wget + curl + ]; + + services.openssh.enable = true; + + system.stateVersion = "25.05"; + +} diff --git a/nix/homelab/disk-config.nix b/nix/homelab/disk-config.nix new file mode 100644 index 0000000..1c60656 --- /dev/null +++ b/nix/homelab/disk-config.nix @@ -0,0 +1,50 @@ +{ + disko.devices = { + disk = { + disk1 = { + device = "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + size = "1M"; + type = "EF02"; + }; + ESP = { + type = "EF00"; + size = "512M"; + content = { + type = "filesystem"; + mountpoint = "/boot"; + format = "vfat"; + }; + }; + primary = { + size = "100%"; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + }; + }; + }; + }; + }; + lvm_vg = { + pool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%FREE"; + content = { + type = "filesystem"; + format = "btrfs"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; +} diff --git a/nix/homelab/flake.lock b/nix/homelab/flake.lock new file mode 100644 index 0000000..479be5a --- /dev/null +++ b/nix/homelab/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743598667, + "narHash": "sha256-ViE7NoFWytYO2uJONTAX35eGsvTYXNHjWALeHAg8OQY=", + "owner": "nix-community", + "repo": "disko", + "rev": "329d3d7e8bc63dd30c39e14e6076db590a6eabe6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1743964447, + "narHash": "sha256-nEo1t3Q0F+0jQ36HJfbJtiRU4OI+/0jX/iITURKe3EE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "063dece00c5a77e4a0ea24e5e5a5bd75232806f8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/homelab/flake.nix b/nix/homelab/flake.nix new file mode 100644 index 0000000..682f602 --- /dev/null +++ b/nix/homelab/flake.nix @@ -0,0 +1,33 @@ +{ + description = "Homelab-test"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { + self, + nixpkgs, + disko, + }: + { + nixosConfigurations = { + main = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + meta = { + hostname = "kube"; + }; + }; + modules = [ + disko.nixosModules.disko + ./configuration.nix + ./hardware-configuration.nix + ]; + }; + }; + }; +} diff --git a/nix/homelab/hardware-configuration.nix b/nix/homelab/hardware-configuration.nix new file mode 100644 index 0000000..bf63b42 --- /dev/null +++ b/nix/homelab/hardware-configuration.nix @@ -0,0 +1,22 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "ehci_pci" "nvme" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.ens33.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}