Browse Source

Merge branch 'master' of ssh://gitea.c3d2.de:2222/C3D2/nix-config

container/radius
Markus Schmidl 1 year ago
parent
commit
0e5096599e

+ 15
- 0
README.md View File

@@ -0,0 +1,15 @@
1
+# Deployment
2
+
3
+Beide failen bei Activation des neuen Profils. (TODO)
4
+
5
+## Mit `nixos-switch rebuild`
6
+
7
+```shell
8
+nixos-rebuild switch -I nixos-config=./hosts/storage-ng/$HOST/configuration.nix --target-host "root@$HOST.hq.c3d2.de"
9
+```
10
+
11
+## Mit NixOps
12
+
13
+```shell
14
+nixops create  hq.nixops -d hq
15
+```

+ 40
- 0
hosts/storage-ng/dhcp/configuration.nix View File

@@ -0,0 +1,40 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+{
4
+  imports =
5
+    [ ../../../lib/lxc-container.nix
6
+      ../../../lib/shared.nix
7
+    ];
8
+
9
+  networking.hostName = "dhcp";
10
+  networking.defaultGateway = "172.22.99.1";
11
+  networking.nameservers = [ "172.20.72.6" "172.20.72.10" ];
12
+  networking.interfaces.eth0 = {
13
+    ipv4.addresses = [ {
14
+      address = "172.22.99.254";
15
+      prefixLength = 24;
16
+    } ];
17
+  };
18
+
19
+  # List packages installed in system profile. To search, run:
20
+  # $ nix search wget
21
+  environment.systemPackages = with pkgs; [
22
+    vim
23
+  ];
24
+
25
+  # dhcp
26
+  networking.firewall.allowedUDPPorts = [ 67 68 ];
27
+  networking.useDHCP = false;
28
+
29
+  services.dhcpd4 = {
30
+    enable = true;
31
+    interfaces = [ "eth0" ];
32
+    extraConfig = builtins.readFile ../../../secrets/hosts/dhcp/config;
33
+  };
34
+
35
+  # This value determines the NixOS release with which your system is to be
36
+  # compatible, in order to avoid breaking some software such as database
37
+  # servers. You should change this only after NixOS release notes say you
38
+  # should.
39
+  system.stateVersion = "18.09"; # Did you read the comment?
40
+}

+ 3
- 31
hosts/storage-ng/lxc-template.nix View File

@@ -6,30 +6,12 @@
6 6
 
7 7
 {
8 8
   imports =
9
-    [ <nixpkgs/nixos/modules/profiles/minimal.nix>
9
+    [ ../../lib/lxc-container.nix
10
+      ../../lib/shared.nix
10 11
     ];
11
-  nix.useSandbox = false;
12
-  nix.maxJobs = lib.mkDefault 4;
13
-
14
-  boot.isContainer = true;
15
-  # /sbin/init
16
-  boot.loader.initScript.enable = true;
17
-  boot.loader.grub.enable = false;
18
-  #boot.supportedFilesystems = ["zfs" "ext2" "ext3" "vfat" "fat32" "bcache" "bcachefs"];
19
-
20
-  fileSystems."/" = { fsType = "rootfs"; device = "rootfs"; };
21 12
 
22 13
   networking.hostName = "nixbert"; # Define your hostname.
23
-  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
24
-  networking.useNetworkd = true;
25
-
26
-  # Set your time zone.
27
-  time.timeZone = "Europe/Berlin";
28
-  # Select internationalisation properties.
29
-  i18n = {
30
-    defaultLocale = "en_US.UTF-8";
31
-    supportedLocales = lib.mkForce [ "en_US.UTF-8/UTF-8" ];
32
-  };
14
+  networking.useNetworkd = false;
33 15
 
34 16
   # List packages installed in system profile. To search, run:
35 17
   # $ nix search wget
@@ -37,16 +19,6 @@
37 19
     wget vim
38 20
   ];
39 21
 
40
-  # Create a few files early before packing tarball for Proxmox
41
-  # architecture/OS detection.
42
-  system.extraSystemBuilderCmds = 
43
-      ''
44
-          mkdir -m 0755 -p $out/bin
45
-          ln -s ${pkgs.bash}/bin/bash $out/bin/sh
46
-          mkdir -m 0755 -p $out/sbin
47
-          ln -s ../init $out/sbin/init
48
-      '';
49
-
50 22
   # This value determines the NixOS release with which your system is to be
51 23
   # compatible, in order to avoid breaking some software such as database
52 24
   # servers. You should change this only after NixOS release notes say you

+ 1
- 3
hosts/storage-ng/lxc-template.sh View File

@@ -1,5 +1,3 @@
1 1
 #!/usr/bin/env bash
2 2
 
3
-# Doesn't boot in Proxmox, use nixos-install to generate an image instead!
4
-
5
-nix-build -E '(import ../../nixpkgs/nixos/release.nix { configuration = import ./lxc-template.nix; }).containerTarball.x86_64-linux'
3
+nix-build -I nixos-config=./lxc-template.nix '<nixpkgs/nixos>' -A config.system.build.tarball

+ 21
- 0
hq.nixops View File

@@ -0,0 +1,21 @@
1
+{
2
+  network.description = "C3D2 HQ";
3
+
4
+  "grafana" =
5
+    { ... }:
6
+    {
7
+      imports = [
8
+        hosts/storage-ng/grafana/configuration.nix
9
+      ];
10
+      deployment.targetHost = "grafana.hq.c3d2.de";
11
+    };
12
+
13
+  "dhcp" =
14
+    { ... }:
15
+    {
16
+      imports = [
17
+        hosts/storage-ng/dhcp/configuration.nix
18
+      ];
19
+      deployment.targetHost = "2a02:8106:208:5201:3801:15ff:fe95:8988";
20
+    };
21
+}

+ 1
- 0
lib/lxc-container.nix View File

@@ -3,6 +3,7 @@
3 3
 {
4 4
   imports =
5 5
     [ <nixpkgs/nixos/modules/profiles/minimal.nix>
6
+      <nixpkgs/nixos/modules/profiles/docker-container.nix>
6 7
     ];
7 8
   nix.useSandbox = false;
8 9
   nix.maxJobs = lib.mkDefault 1;

+ 1
- 1
secrets

@@ -1 +1 @@
1
-Subproject commit f43e472380ae045952c2f5c68d6da580f7b958d0
1
+Subproject commit 57621eb036ccaee2ea1af85b31abe93526fd0e79

Loading…
Cancel
Save