From 79db592b0a0fb9d694b6f2a065e7cc7b7cbde1ba Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 1 Apr 2019 01:24:54 +0200 Subject: [PATCH] refactor into lib/lxc-container,shared for grafana --- .gitmodules | 3 ++ hosts/storage-ng/grafana/configuration.nix | 32 ++-------------------- lib/lxc-container.nix | 30 ++++++++++++++++++++ lib/shared.nix | 11 ++++++++ secrets | 1 + 5 files changed, 47 insertions(+), 30 deletions(-) create mode 100644 .gitmodules create mode 100644 lib/lxc-container.nix create mode 100644 lib/shared.nix create mode 160000 secrets diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..3eb49ffe --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "secrets"] + path = secrets + url = ssh://git@gitea.c3d2.de:2222/c3d2-admins/secrets.git diff --git a/hosts/storage-ng/grafana/configuration.nix b/hosts/storage-ng/grafana/configuration.nix index 29332e60..8b5c567e 100644 --- a/hosts/storage-ng/grafana/configuration.nix +++ b/hosts/storage-ng/grafana/configuration.nix @@ -2,48 +2,20 @@ { imports = - [ + [ ../../../lib/lxc-container.nix + ../../../lib/shared.nix ]; - nix.useSandbox = false; - nix.maxJobs = lib.mkDefault 2; - nix.buildCores = lib.mkDefault 16; - - boot.isContainer = true; - # /sbin/init - boot.loader.initScript.enable = true; - boot.loader.grub.enable = false; - - fileSystems."/" = { fsType = "rootfs"; device = "rootfs"; }; networking.hostName = "grafana"; networking.useNetworkd = true; networking.defaultGateway = "172.22.99.4"; - # Set your time zone. - time.timeZone = "Europe/Berlin"; - # Select internationalisation properties. - i18n = { - defaultLocale = "en_US.UTF-8"; - supportedLocales = lib.mkForce [ "en_US.UTF-8/UTF-8" ]; - }; - # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ vim ]; - # Create a few files early before packing tarball for Proxmox - # architecture/OS detection. - system.extraSystemBuilderCmds = - '' - mkdir -m 0755 -p $out/bin - ln -s ${pkgs.bash}/bin/bash $out/bin/sh - mkdir -m 0755 -p $out/sbin - ln -s ../init $out/sbin/init - ''; - - # http https networking.firewall.allowedTCPPorts = [ 80 443 ]; # collectd diff --git a/lib/lxc-container.nix b/lib/lxc-container.nix new file mode 100644 index 00000000..091ef9c3 --- /dev/null +++ b/lib/lxc-container.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, ... }: + +{ + imports = + [ + ]; + nix.useSandbox = false; + nix.maxJobs = lib.mkDefault 1; + nix.buildCores = lib.mkDefault 4; + + boot.isContainer = true; + # /sbin/init + boot.loader.initScript.enable = true; + boot.loader.grub.enable = false; + + # Create a few files early before packing tarball for Proxmox + # architecture/OS detection. + system.extraSystemBuilderCmds = + '' + mkdir -m 0755 -p $out/bin + ln -s ${pkgs.bash}/bin/bash $out/bin/sh + mkdir -m 0755 -p $out/sbin + ln -s ../init $out/sbin/init + ''; + + fileSystems."/" = { fsType = "rootfs"; device = "rootfs"; }; + + # Required for remote deployment + services.openssh.enable = true; +} diff --git a/lib/shared.nix b/lib/shared.nix new file mode 100644 index 00000000..8df4aa61 --- /dev/null +++ b/lib/shared.nix @@ -0,0 +1,11 @@ +{ lib, ... }: + +{ + # Set your time zone. + time.timeZone = "Europe/Berlin"; + # Select internationalisation properties. + i18n = { + defaultLocale = "en_US.UTF-8"; + supportedLocales = lib.mkForce [ "en_US.UTF-8/UTF-8" ]; + }; +} diff --git a/secrets b/secrets new file mode 160000 index 00000000..16d7de68 --- /dev/null +++ b/secrets @@ -0,0 +1 @@ +Subproject commit 16d7de68c8468e0f347092526150d72d4fd5fc93