From 66d38c26ec8bdd263fe79c05b0fa1b4dadf95322 Mon Sep 17 00:00:00 2001 From: Kalle Struik Date: Sun, 17 Nov 2024 20:28:14 +0100 Subject: [PATCH] Initial commit --- .gitignore | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 19 +++++++++++++++++++ services/sonarr.nix | 12 ++++++++++++ systems/base.nix | 14 ++++++++++++++ systems/nix-test.nix | 7 +++++++ utils.nix | 20 ++++++++++++++++++++ 7 files changed, 100 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 services/sonarr.nix create mode 100644 systems/base.nix create mode 100644 systems/nix-test.nix create mode 100644 utils.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b511ae1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.qcow2 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bf53ed2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1731676054, + "narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5573e95 --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "Homelab configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = + { self, nixpkgs, ... }@inputs: + let + outputs = self.outputs; + utils = import ./utils.nix { inherit nixpkgs inputs outputs; }; + in + { + nixosConfigurations = { + "nix-test" = utils.mkSystem ./systems/nix-test.nix; + }; + }; +} diff --git a/services/sonarr.nix b/services/sonarr.nix new file mode 100644 index 0000000..06ee078 --- /dev/null +++ b/services/sonarr.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + # Enable the sonarr service + services.sonarr = { + enable = true; + openFirewall = true; + group = "media"; + }; + + # Ensure that the media group exists + users.groups.media = { }; +} diff --git a/systems/base.nix b/systems/base.nix new file mode 100644 index 0000000..357664f --- /dev/null +++ b/systems/base.nix @@ -0,0 +1,14 @@ +{ ... }: +{ + nix.settings = { + # Enable flakes and new 'nix' command + experimental-features = "nix-command flakes"; + # Deduplicate and optimize nix store + auto-optimise-store = true; + }; + + services.openssh.enable = true; + + time.timeZone = "Europe/Amsterdam"; + i18n.defaultLocale = "en_US.UTF-8"; +} diff --git a/systems/nix-test.nix b/systems/nix-test.nix new file mode 100644 index 0000000..83fd5d3 --- /dev/null +++ b/systems/nix-test.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ ../services/sonarr.nix ]; + + networking.hostName = "nix-test"; + system.stateVersion = "24.05"; +} diff --git a/utils.nix b/utils.nix new file mode 100644 index 0000000..5ed2a44 --- /dev/null +++ b/utils.nix @@ -0,0 +1,20 @@ +{ + nixpkgs, + inputs, + outputs, + ... +}: +{ + mkSystem = + config: + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit inputs outputs; + }; + modules = [ + ./systems/base.nix + config + ]; + }; +}