summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorene <ene@sils.li>2023-02-08 17:33:02 +0100
committerene <ene@sils.li>2023-02-08 17:33:02 +0100
commitc50431b189e982a631d2d4864b304f33169bacdb (patch)
tree164c350e503c7dfda585ed505536b08882e00323
parentMerge pull request 'Imported the headless profile' (#13) from server1_headles... (diff)
parentMerge branch 'server1_minecraft2' into server1 (diff)
downloadnixos-server-c50431b189e982a631d2d4864b304f33169bacdb.tar.gz
nixos-server-c50431b189e982a631d2d4864b304f33169bacdb.zip
Merge pull request 'Merge to server1' (#16) from server1_develop into server1
Reviewed-on: https://git.sils.li/vhack.eu/nixos-server/pulls/16
Diffstat (limited to '')
-rw-r--r--flake.lock27
-rw-r--r--flake.nix21
-rw-r--r--hardware-configuration.nix35
-rw-r--r--hosts/server1/configuration.nix (renamed from configuration.nix)11
-rw-r--r--hosts/server1/networking.nix (renamed from networking.nix)0
-rw-r--r--services/default.nix8
-rw-r--r--services/services/minecraft.nix (renamed from services/minecraft.nix)2
-rw-r--r--services/services/nix.nix18
-rw-r--r--services/services/opensshd.nix (renamed from services/opensshd.nix)0
-rw-r--r--services/services/rust-motd.nix (renamed from services/rust-motd.nix)0
-rw-r--r--system/default.nix8
-rw-r--r--system/system/fileSystemLayouts.nix45
-rw-r--r--system/system/hardware.nix9
-rw-r--r--system/system/packages.nix (renamed from packages.nix)0
-rw-r--r--system/system/users.nix (renamed from users.nix)0
15 files changed, 142 insertions, 42 deletions
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..8af459c
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+  "nodes": {
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1675512093,
+        "narHash": "sha256-u1CY4feK14B57E6T+0Bhkuoj8dpBxCPrWO+SP87UVP8=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "8e8240194eda25b61449f29bb5131e02b28a5486",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-22.11-small",
+        "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..2e52203
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,21 @@
+# vim: ts=2
+{
+  description = "Nixos server config";
+
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11-small";
+  };
+
+  outputs = {
+    self,
+    nixpkgs,
+    ...
+  } @ attrs: {
+    nixosConfigurations."server1" = nixpkgs.lib.nixosSystem {
+      system = "x86_64-linux";
+      specialArgs = attrs;
+      modules = [./hosts/server1/configuration.nix];
+    };
+  };
+}
+
diff --git a/hardware-configuration.nix b/hardware-configuration.nix
deleted file mode 100644
index d960da6..0000000
--- a/hardware-configuration.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{modulesPath, ...}: {
-  imports = [
-      (modulesPath + "/profiles/qemu-guest.nix")
-      (modulesPath + "/profiles/headless.nix")
-  ];
-  boot.loader.grub.device = "/dev/vda";
-  boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi"];
-  boot.initrd.kernelModules = ["nvme" "btrfs"];
-  fileSystems = {
-    "/" = {
-      device = "tmpfs";
-      fsType = "tmpfs";
-      options = ["defaults" "size=2G" "mode=755"];
-    };
-    "/nix" = {
-      device = "/dev/vda3";
-      fsType = "btrfs";
-      options = ["subvol=nix" "compress-force=zstd"];
-    };
-    "/srv" = {
-      device = "/dev/vda3";
-      fsType = "btrfs";
-      options = ["subvol=storage" "compress-force=zstd"];
-    };
-    "/boot" = {
-      device = "/dev/vda3";
-      options = ["subvol=boot" "compress-force=zstd"];
-    };
-
-    "/etc/nixos" = {
-      device = "/srv/nix-config";
-      options = ["bind"];
-    };
-  };
-}
diff --git a/configuration.nix b/hosts/server1/configuration.nix
index 8fc047a..729ef0f 100644
--- a/configuration.nix
+++ b/hosts/server1/configuration.nix
@@ -1,13 +1,10 @@
 {pkgs, ...}: {
   imports = [
-    ./hardware-configuration.nix
-    ./packages.nix
     ./networking.nix # network configuration that just works
-    ./users.nix
 
-    ./services/minecraft.nix
-    ./services/rust-motd.nix
-    ./services/opensshd.nix
+    ../../system
+
+    ../../services
   ];
 
   boot.cleanTmpDir = true;
@@ -15,6 +12,8 @@
   networking.hostName = "server1";
   networking.domain = "vhack.eu";
 
+  system.fileSystemLayouts.mainDisk = "/dev/vda3";
+
   system.stateVersion = "22.11";
 }
 # vim: ts=2
diff --git a/networking.nix b/hosts/server1/networking.nix
index 26d6719..26d6719 100644
--- a/networking.nix
+++ b/hosts/server1/networking.nix
diff --git a/services/default.nix b/services/default.nix
new file mode 100644
index 0000000..6983529
--- /dev/null
+++ b/services/default.nix
@@ -0,0 +1,8 @@
+{config, ...}: {
+  imports = [
+    ./services/minecraft.nix
+    ./services/nix.nix
+    ./services/opensshd.nix
+    ./services/rust-motd.nix
+  ];
+}
diff --git a/services/minecraft.nix b/services/services/minecraft.nix
index 5882d9a..754c974 100644
--- a/services/minecraft.nix
+++ b/services/services/minecraft.nix
@@ -11,7 +11,7 @@
     };
   };
   systemd.services.minecraft = {
-    wantedBy = "multi-user.target";
+    wantedBy = ["multi-user.target"];
     after = "network.target";
     description = "Minecraft Server";
     serviceConfig = {
diff --git a/services/services/nix.nix b/services/services/nix.nix
new file mode 100644
index 0000000..bd562ec
--- /dev/null
+++ b/services/services/nix.nix
@@ -0,0 +1,18 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}: {
+  nix = {
+    #    gc = {
+    #      automatic = true;
+    #      dates = "daily";
+    #      options = "--delete-older-than 3";
+    #    };
+    settings = {
+      auto-optimise-store = true;
+      experimental-features = ["nix-command" "flakes"];
+    };
+  };
+}
diff --git a/services/opensshd.nix b/services/services/opensshd.nix
index cb9f2ba..cb9f2ba 100644
--- a/services/opensshd.nix
+++ b/services/services/opensshd.nix
diff --git a/services/rust-motd.nix b/services/services/rust-motd.nix
index 21bc1cd..21bc1cd 100644
--- a/services/rust-motd.nix
+++ b/services/services/rust-motd.nix
diff --git a/system/default.nix b/system/default.nix
new file mode 100644
index 0000000..2af4982
--- /dev/null
+++ b/system/default.nix
@@ -0,0 +1,8 @@
+{config, ...}: {
+  imports = [
+    ./system/fileSystemLayouts.nix
+    ./system/hardware.nix
+    ./system/packages.nix
+    ./system/users.nix
+  ];
+}
diff --git a/system/system/fileSystemLayouts.nix b/system/system/fileSystemLayouts.nix
new file mode 100644
index 0000000..9d03a05
--- /dev/null
+++ b/system/system/fileSystemLayouts.nix
@@ -0,0 +1,45 @@
+{
+  modulesPath,
+  config,
+  lib,
+  ...
+}:
+with lib; let
+  cfg = config.system.fileSystemLayouts;
+in {
+  options.system.fileSystemLayouts = {
+    mainDisk = mkOption {
+      type = lib.types.path;
+      example = literalExpression "/dev/disk/by-uuid/0442cb6d-f13a-4635-b487-fa76189774c5";
+      description = lib.mdDoc "Path to the main disk";
+    };
+  };
+  config = {
+    fileSystems = {
+      "/" = {
+        device = "tmpfs";
+        fsType = "tmpfs";
+        options = ["defaults" "size=2G" "mode=755"];
+      };
+      "/nix" = {
+        device = cfg.mainDisk;
+        fsType = "btrfs";
+        options = ["subvol=nix" "compress-force=zstd"];
+      };
+      "/srv" = {
+        device = cfg.mainDisk;
+        fsType = "btrfs";
+        options = ["subvol=storage" "compress-force=zstd"];
+      };
+      "/boot" = {
+        device = cfg.mainDisk;
+        options = ["subvol=boot" "compress-force=zstd"];
+      };
+
+      "/etc/nixos" = {
+        device = "/srv/nix-config";
+        options = ["bind"];
+      };
+    };
+  };
+}
diff --git a/system/system/hardware.nix b/system/system/hardware.nix
new file mode 100644
index 0000000..c4c7dc9
--- /dev/null
+++ b/system/system/hardware.nix
@@ -0,0 +1,9 @@
+{modulesPath, ...}: {
+  imports = [
+    (modulesPath + "/profiles/qemu-guest.nix")
+    (modulesPath + "/profiles/headless.nix")
+  ];
+  boot.loader.grub.device = "/dev/vda";
+  boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi"];
+  boot.initrd.kernelModules = ["nvme" "btrfs"];
+}
diff --git a/packages.nix b/system/system/packages.nix
index 4d33c6e..4d33c6e 100644
--- a/packages.nix
+++ b/system/system/packages.nix
diff --git a/users.nix b/system/system/users.nix
index 34e1648..34e1648 100644
--- a/users.nix
+++ b/system/system/users.nix