Skip to content

Commit 2e29c10

Browse files
committedJul 4, 2023
add nixos management(mno001) box
1 parent a4833ef commit 2e29c10

File tree

7 files changed

+185
-2
lines changed

7 files changed

+185
-2
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
result

‎flake.nix

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@
55
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
66
};
77

8-
outputs = { self, nixpkgs }: {
9-
packages.x86_64-linux.rpi-manager = nixpkgs.legacyPackages.x86_64-linux.callPackage ./pkgs/ixp-manager.nix {};
8+
outputs = inputs@{ self, nixpkgs }: {
9+
packages.x86_64-linux.rpi-manager = nixpkgs.legacyPackages.x86_64-linux.callPackage ./pkgs/ixp-manager.nix { };
10+
11+
nixosConfigurations = {
12+
mno001 = nixpkgs.lib.nixosSystem {
13+
system = "x86_64-linux";
14+
specialArgs = { inherit inputs self; };
15+
modules = [
16+
./hosts/mno001/configuration.nix
17+
./modules/management
18+
];
19+
};
20+
};
1021
};
1122
}

‎hosts/mno001/configuration.nix

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{ config, pkgs, ... }:
2+
3+
{
4+
imports = [
5+
./hardware-configuration.nix
6+
./network.nix
7+
];
8+
9+
# Use the systemd-boot EFI boot loader.
10+
boot.loader.systemd-boot.enable = true;
11+
boot.loader.efi.canTouchEfiVariables = true;
12+
boot.zfs.requestEncryptionCredentials = true;
13+
14+
# Set your time zone.
15+
time.timeZone = "Europe/Berlin";
16+
17+
boot.supportedFilesystems = [ "zfs" ];
18+
19+
networking.hostId = "eeb0e9de";
20+
networking.hostName = "MNO001";
21+
22+
services.zfs.autoSnapshot.enable = true;
23+
services.zfs.autoScrub.enable = true;
24+
25+
environment.systemPackages = with pkgs; [
26+
vim
27+
git
28+
];
29+
30+
# Copy the NixOS configuration file and link it from the resulting system
31+
# (/run/current-system/configuration.nix). This is useful in case you
32+
# accidentally delete configuration.nix.
33+
# system.copySystemConfiguration = true;
34+
35+
# This value determines the NixOS release from which the default
36+
# settings for stateful data, like file locations and database versions
37+
# on your system were taken. It's perfectly fine and recommended to leave
38+
# this value at the release version of the first install of this system.
39+
# Before changing this value read the documentation for this option
40+
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
41+
system.stateVersion = "23.05"; # Did you read the comment?
42+
43+
}
44+
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Do not modify this file! It was generated by ‘nixos-generate-config’
2+
# and may be overwritten by future invocations. Please make changes
3+
# to /etc/nixos/configuration.nix instead.
4+
{ config, lib, pkgs, modulesPath, ... }:
5+
6+
{
7+
imports =
8+
[
9+
(modulesPath + "/installer/scan/not-detected.nix")
10+
];
11+
12+
boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "megaraid_sas" "usbhid" "usb_storage" "sd_mod" "sr_mod" ];
13+
boot.initrd.kernelModules = [ ];
14+
boot.kernelModules = [ "kvm-intel" ];
15+
boot.extraModulePackages = [ ];
16+
17+
fileSystems."/" =
18+
{
19+
device = "rpool/root/nixos";
20+
fsType = "zfs";
21+
};
22+
23+
fileSystems."/nix" =
24+
{
25+
device = "rpool/root/nixos/nix";
26+
fsType = "zfs";
27+
};
28+
29+
fileSystems."/var/lib" =
30+
{
31+
device = "rpool/data";
32+
fsType = "zfs";
33+
};
34+
35+
fileSystems."/boot" =
36+
{
37+
device = "/dev/disk/by-uuid/9864-EC3C";
38+
fsType = "vfat";
39+
};
40+
41+
swapDevices = [ ];
42+
43+
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
44+
}

‎hosts/mno001/network.nix

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{ pkgs, ... }:
2+
let
3+
bond_name = "bond0";
4+
in
5+
{
6+
7+
# LACP on first two ports
8+
networking.bonds."${bond_name}" = {
9+
interfaces = [ "eno2" "eno3" ];
10+
driverOptions = {
11+
mode = "802.3ad";
12+
lacp_rate = "fast";
13+
};
14+
};
15+
16+
# Static IP Address
17+
networking.interfaces."${bond_name}" = {
18+
useDHCP = false;
19+
ipv4.addresses = [
20+
{
21+
address = "212.111.245.178";
22+
prefixLength = 29;
23+
}
24+
];
25+
};
26+
27+
# Default Gateway
28+
networking.defaultGateway.address = "212.111.245.177";
29+
30+
# nameservers
31+
networking.nameservers = [ "212.111.228.53" "193.36.123.53" ];
32+
33+
# enabling and configuring firewall
34+
networking.firewall = {
35+
enable = true;
36+
allowedTCPPorts = [ 80 22 443 ];
37+
allowedUDPPorts = [ ];
38+
};
39+
}

‎modules/management/base.nix

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{ pkgs, config, lib, ... }: {
2+
nix = {
3+
package = pkgs.nixUnstable;
4+
nixPath = [
5+
"nixpkgs=${pkgs.path}"
6+
"nixos-config=/etc/nixos/configuration.nix"
7+
];
8+
settings = {
9+
auto-optimise-store = true;
10+
substituters = [
11+
"https://nix-serve.hq.c3d2.de"
12+
];
13+
trusted-public-keys = [
14+
"nix-serve.hq.c3d2.de:KZRGGnwOYzys6pxgM8jlur36RmkJQ/y8y62e52fj1ps="
15+
];
16+
};
17+
extraOptions = ''
18+
experimental-features = nix-command flakes
19+
allow-import-from-derivation = true
20+
'';
21+
};
22+
23+
environment.systemPackages = with pkgs; [
24+
git # versioning tool
25+
vim # vim editor
26+
htop # resource monitor
27+
];
28+
29+
30+
programs.vim.defaultEditor = true;
31+
programs.mosh.enable = true;
32+
services.openssh.enable = true;
33+
34+
users.users.root.openssh.authorizedKeys.keys = [
35+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMbUizElFyULDlpEE9XHWWOca4ZXepS18ljh4Fj4YnJOAs7sbYzzhfMUiD703FIgK5YObzOlheu/PBbwUOStgcmPDuRalZWLr+0kCUYERfjLHkgliFx96xEFw9dluvII6JpbzFI/uvkEkQ3ESKapRcYAuBTk2sRoit8za+HX9sLmMueqN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
38+
39+
}

‎modules/management/default.nix

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
imports = [
3+
./base.nix
4+
];
5+
}

0 commit comments

Comments
 (0)
Please sign in to comment.