From 2ce243c3213c5fb7b9b09a75a8a80a9d4493e620 Mon Sep 17 00:00:00 2001 From: Sveske-Juice Date: Tue, 27 May 2025 13:04:52 +0200 Subject: [PATCH] flake with HA --- .gitignore | 1 + configuration.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 ++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 .gitignore create mode 100644 configuration.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aab0f7b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nixos.qcow2 diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..7b409ad --- /dev/null +++ b/configuration.nix @@ -0,0 +1,58 @@ +{pkgs, ...}: { + system.stateVersion = "24.05"; + users.groups.admin = {}; + users.users = { + admin = { + isNormalUser = true; + extraGroups = ["wheel"]; + password = "admin"; + group = "admin"; + }; + }; + services.openssh = { + enable = true; + settings.PasswordAuthentication = true; + }; + + networking.firewall.allowedTCPPorts = [22 8123]; + environment.systemPackages = with pkgs; [ + htop + ]; + + virtualisation.vmVariant.virtualisation = { + forwardPorts = [ + # ssh + { + from = "host"; + host.port = 2221; + guest.port = 22; + } + # HA + { + from = "host"; + host.port = 8123; + guest.port = 8123; + } + ]; + }; + + services.home-assistant = { + enable = true; + extraComponents = [ + # Components required to complete the onboarding + "esphome" + "met" + "radio_browser" + "matter" + ]; + config = { + # Includes dependencies for a basic setup + # https://www.home-assistant.io/integrations/default_config/ + default_config = {}; + }; + extraPackages = python3Packages: + with python3Packages; [ + gtts + ]; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d072398 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1748190013, + "narHash": "sha256-R5HJFflOfsP5FBtk+zE8FpL8uqE7n62jqOsADvVshhE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "62b852f6c6742134ade1abdd2a21685fd617a291", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4fde7f5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + ... + } @ inputs: + inputs.flake-utils.lib.eachDefaultSystem (system: rec { + nixosConfigurations.test = nixpkgs.lib.nixosSystem { + inherit system; + specialArgs.inputs = inputs; + modules = [ + ./configuration.nix + ]; + }; + apps = { + default = { + type = "app"; + program = "${nixosConfigurations.test.config.system.build.vm}/bin/run-nixos-vm"; + }; + }; + }); +}