From cdbd9f7f83099a48bfa59a886b6e51790d898a24 Mon Sep 17 00:00:00 2001 From: ene Date: Sat, 4 Feb 2023 21:37:52 +0100 Subject: Flake: Changed the configuration to a flake Nix flakes make a lot of things very easy. --- system/fileSystemLayouts.nix | 45 +++++++++++++++++++++++++++++++++ system/hardware.nix | 9 +++++++ system/packages.nix | 9 +++++++ system/users.nix | 59 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 system/fileSystemLayouts.nix create mode 100644 system/hardware.nix create mode 100644 system/packages.nix create mode 100644 system/users.nix (limited to 'system') diff --git a/system/fileSystemLayouts.nix b/system/fileSystemLayouts.nix new file mode 100644 index 0000000..9d03a05 --- /dev/null +++ b/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/hardware.nix b/system/hardware.nix new file mode 100644 index 0000000..c4c7dc9 --- /dev/null +++ b/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/system/packages.nix b/system/packages.nix new file mode 100644 index 0000000..4d33c6e --- /dev/null +++ b/system/packages.nix @@ -0,0 +1,9 @@ +{pkgs, ...}: { + environment.systemPackages = with pkgs; [ + jre_minimal + git + zsh + neovim + btrfs-progs + ]; +} diff --git a/system/users.nix b/system/users.nix new file mode 100644 index 0000000..34e1648 --- /dev/null +++ b/system/users.nix @@ -0,0 +1,59 @@ +{pkgs, ...}: { + users.mutableUsers = false; + users.defaultUserShell = pkgs.zsh; + + users.users = { + root = { + #uid = 0; + #initialHashedPassword = null; # to lock root + # Backup, if something happens. TODO remove this later + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG63gxw8JePmrC8Fni0pLV4TnPBhCPmSV9FYEdva+6s7 sils" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBFuTNNn71Rhfnop2cdz3r/RhWWlCePnSBOhTBbu2ME soispha" + ]; + }; + + sils = { + name = "sils"; + isNormalUser = true; + home = "/srv/home/sils"; + initialHashedPassword = "$y$jFT$KpFnahVCE9JbE.5P3us8o.$ZzSxCusWqe3sL7b6DLgOXNNUf114tiiptM6T8lDxtKC"; # TODO CHANGE + uid = 1000; + extraGroups = [ + "wheel" + ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG63gxw8JePmrC8Fni0pLV4TnPBhCPmSV9FYEdva+6s7 sils" + ]; + }; + + soispha = { + name = "soispha"; + isNormalUser = true; + home = "/srv/home/soispha"; + initialHashedPassword = "$y$jFT$3.8XmUyukZvpExMUxDZkI.$IVrJgm8ysNDF/0vDD2kF6w73ozXgr1LMVRNN4Bq7pv1"; + uid = 1001; + extraGroups = [ + "wheel" + ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBFuTNNn71Rhfnop2cdz3r/RhWWlCePnSBOhTBbu2ME soispha" + ]; + }; + + nightingale = { + name = "nightingale"; + isNormalUser = true; + home = "/srv/home/nightingale"; + initialHashedPassword = null; # TODO CHANGE + uid = 1002; + extraGroups = [ + "wheel" + ]; + openssh.authorizedKeys.keys = [ + ]; + }; + }; +} +# vim: ts=2 + -- cgit 1.4.1 From cb69f4ae60e2d94039a7bb0b5caa566a9d288686 Mon Sep 17 00:00:00 2001 From: ene Date: Sun, 5 Feb 2023 08:58:11 +0100 Subject: Fix: correct host name and convenience changes We used the domain name instead of the host name, which obviously doesn't work for multiple host. In addition to that I changed some directory to make importing easier and enabled the "nix-command" and "flakes" experimental options, to make the `nix flake check` command usable. Refs: #15 --- flake.nix | 4 +- hosts/server1/configuration.nix | 20 ++++++++++ hosts/server1/networking.nix | 49 +++++++++++++++++++++++ hosts/vhack.eu/configuration.nix | 25 ------------ hosts/vhack.eu/networking.nix | 49 ----------------------- services/minecraft.nix | 26 ------------ services/opensshd.nix | 18 --------- services/rust-motd.nix | 79 ------------------------------------- services/services.nix | 8 ++++ services/services/minecraft.nix | 26 ++++++++++++ services/services/nix.nix | 18 +++++++++ services/services/opensshd.nix | 18 +++++++++ services/services/rust-motd.nix | 79 +++++++++++++++++++++++++++++++++++++ system/fileSystemLayouts.nix | 45 --------------------- system/hardware.nix | 9 ----- system/packages.nix | 9 ----- system/system.nix | 8 ++++ system/system/fileSystemLayouts.nix | 45 +++++++++++++++++++++ system/system/hardware.nix | 9 +++++ system/system/packages.nix | 9 +++++ system/system/users.nix | 59 +++++++++++++++++++++++++++ system/users.nix | 59 --------------------------- 22 files changed, 350 insertions(+), 321 deletions(-) create mode 100644 hosts/server1/configuration.nix create mode 100644 hosts/server1/networking.nix delete mode 100644 hosts/vhack.eu/configuration.nix delete mode 100644 hosts/vhack.eu/networking.nix delete mode 100644 services/minecraft.nix delete mode 100644 services/opensshd.nix delete mode 100644 services/rust-motd.nix create mode 100644 services/services.nix create mode 100644 services/services/minecraft.nix create mode 100644 services/services/nix.nix create mode 100644 services/services/opensshd.nix create mode 100644 services/services/rust-motd.nix delete mode 100644 system/fileSystemLayouts.nix delete mode 100644 system/hardware.nix delete mode 100644 system/packages.nix create mode 100644 system/system.nix create mode 100644 system/system/fileSystemLayouts.nix create mode 100644 system/system/hardware.nix create mode 100644 system/system/packages.nix create mode 100644 system/system/users.nix delete mode 100644 system/users.nix (limited to 'system') diff --git a/flake.nix b/flake.nix index a6d95b6..2e52203 100644 --- a/flake.nix +++ b/flake.nix @@ -11,10 +11,10 @@ nixpkgs, ... } @ attrs: { - nixosConfigurations."vhack.eu" = nixpkgs.lib.nixosSystem { + nixosConfigurations."server1" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = attrs; - modules = [./hosts/vhack.eu/configuration.nix]; + modules = [./hosts/server1/configuration.nix]; }; }; } diff --git a/hosts/server1/configuration.nix b/hosts/server1/configuration.nix new file mode 100644 index 0000000..6f91fc0 --- /dev/null +++ b/hosts/server1/configuration.nix @@ -0,0 +1,20 @@ +{pkgs, ...}: { + imports = [ + ./networking.nix # network configuration that just works + + ../../system/system.nix + + ../../services/services.nix + ]; + + boot.cleanTmpDir = true; + zramSwap.enable = true; + networking.hostName = "server1"; + networking.domain = "vhack.eu"; + + system.fileSystemLayouts.mainDisk = "/dev/vda3"; + + system.stateVersion = "22.11"; +} +# vim: ts=2 + diff --git a/hosts/server1/networking.nix b/hosts/server1/networking.nix new file mode 100644 index 0000000..26d6719 --- /dev/null +++ b/hosts/server1/networking.nix @@ -0,0 +1,49 @@ +{lib, ...}: { + # This file was populated at runtime with the networking + # details gathered from the active system. + networking = { + nameservers = [ + "8.8.8.8" + ]; + defaultGateway = "89.58.56.1"; + defaultGateway6 = "fe80::1"; + dhcpcd.enable = false; + usePredictableInterfaceNames = lib.mkForce false; + interfaces = { + eth0 = { + ipv4.addresses = [ + { + address = "89.58.58.33"; + prefixLength = 22; + } + ]; + ipv6.addresses = [ + { + address = "2a03:4000:6a:3f3:6422:6dff:fe82:939b"; + prefixLength = 64; + } + { + address = "fe80::6422:6dff:fe82:939b"; + prefixLength = 64; + } + ]; + ipv4.routes = [ + { + address = "89.58.56.1"; + prefixLength = 32; + } + ]; + ipv6.routes = [ + { + address = "fe80::1"; + prefixLength = 128; + } + ]; + }; + }; + }; + services.udev.extraRules = '' + ATTR{address}=="66:22:6d:82:93:9b", NAME="eth0" + + ''; +} diff --git a/hosts/vhack.eu/configuration.nix b/hosts/vhack.eu/configuration.nix deleted file mode 100644 index a58e58d..0000000 --- a/hosts/vhack.eu/configuration.nix +++ /dev/null @@ -1,25 +0,0 @@ -{pkgs, ...}: { - imports = [ - ./networking.nix # network configuration that just works - - ../../system/hardware.nix - ../../system/fileSystemLayouts.nix - ../../system/packages.nix - ../../system/users.nix - - ../../services/minecraft.nix - ../../services/rust-motd.nix - ../../services/opensshd.nix - ]; - - boot.cleanTmpDir = true; - zramSwap.enable = true; - networking.hostName = "server1"; - networking.domain = "vhack.eu"; - - system.fileSystemLayouts.mainDisk = "/dev/vda3"; - - system.stateVersion = "22.11"; -} -# vim: ts=2 - diff --git a/hosts/vhack.eu/networking.nix b/hosts/vhack.eu/networking.nix deleted file mode 100644 index 26d6719..0000000 --- a/hosts/vhack.eu/networking.nix +++ /dev/null @@ -1,49 +0,0 @@ -{lib, ...}: { - # This file was populated at runtime with the networking - # details gathered from the active system. - networking = { - nameservers = [ - "8.8.8.8" - ]; - defaultGateway = "89.58.56.1"; - defaultGateway6 = "fe80::1"; - dhcpcd.enable = false; - usePredictableInterfaceNames = lib.mkForce false; - interfaces = { - eth0 = { - ipv4.addresses = [ - { - address = "89.58.58.33"; - prefixLength = 22; - } - ]; - ipv6.addresses = [ - { - address = "2a03:4000:6a:3f3:6422:6dff:fe82:939b"; - prefixLength = 64; - } - { - address = "fe80::6422:6dff:fe82:939b"; - prefixLength = 64; - } - ]; - ipv4.routes = [ - { - address = "89.58.56.1"; - prefixLength = 32; - } - ]; - ipv6.routes = [ - { - address = "fe80::1"; - prefixLength = 128; - } - ]; - }; - }; - }; - services.udev.extraRules = '' - ATTR{address}=="66:22:6d:82:93:9b", NAME="eth0" - - ''; -} diff --git a/services/minecraft.nix b/services/minecraft.nix deleted file mode 100644 index 5882d9a..0000000 --- a/services/minecraft.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ - config, - pkgs, - ... -}: { - users = { - groups.minecraft = {}; - users.minecraft = { - isSystemUser = true; - group = "minecraft"; - }; - }; - systemd.services.minecraft = { - wantedBy = "multi-user.target"; - after = "network.target"; - description = "Minecraft Server"; - serviceConfig = { - WorkingDirectory = "/srv/minecraft"; - User = "minecraft"; - Group = "minecraft"; - Restart = "always"; - ExecStart = "${pkgs.openjdk}/bin/java -Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paper.jar --nogui"; - SyslogIdentifier = "minecraft-server"; - }; - }; -} diff --git a/services/opensshd.nix b/services/opensshd.nix deleted file mode 100644 index cb9f2ba..0000000 --- a/services/opensshd.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - config, - pkg, - ... -}: { - services.openssh = { - enable = true; - passwordAuthentication = false; - hostKeys = [ - { - comment = "key comment"; - path = "/srv/sshd/ssh_host_ed25519_key"; - rounds = 1000; - type = "ed25519"; - } - ]; - }; -} diff --git a/services/rust-motd.nix b/services/rust-motd.nix deleted file mode 100644 index 21bc1cd..0000000 --- a/services/rust-motd.nix +++ /dev/null @@ -1,79 +0,0 @@ -{ - config, - pkgs, - ... -}: { - programs.rust-motd = { - enable = true; - enableMotdInSSHD = true; - refreshInterval = "*:0/5"; # 0/5 means: hour 0 AND all hour wich match (0 + 5 * x) (is the same as: 0, 5, 10, 15, 20) - settings = { - global = { - progress_full_character = "="; - progress_empty_character = "-"; - progress_prefix = "["; - progress_suffix = "]"; - time_format = "%Y-%m-%d %H:%M:%S"; - }; - - banner = { - color = "red"; - command = "${pkgs.hostname}/bin/hostname | ${pkgs.figlet}/bin/figlet -f slant"; - # if you don't want a dependency on figlet, you can generate your - # banner however you want, put it in a file, and then use something like: - # command = "cat banner.txt" - }; - - # [weather] - # url = "https://wttr.in/New+York,New+York?0" - # proxy = "http://proxy:8080" - - # [service_status] - # Accounts = "accounts-daemon" - # Cron = "cron" - - # [docker_status] - # Local containers MUST start with a slash - # https://github.com/moby/moby/issues/6705 - #"/nextcloud-nextcloud-1" = "Nextcloud" - #"/nextcloud-nextcloud-mariadb-1" = "Nextcloud Database" - - uptime = { - prefix = "Uptime:"; - }; - - # [user_service_status] - # gpg-agent = "gpg-agent" - - #s_s_l_certs = { - # sort_method = "manual" - # - # certs = { - # CertName1 = "/path/to/cert1.pem" - # CertName2 = "/path/to/cert2.pem" - # } - #}; - - filesystems = { - root = "/"; - }; - - memory = { - swap_pos = "beside"; # or "below" or "none" - }; - - fail2_ban = { - jails = ["sshd"]; #, "anotherjail"] - }; - - last_login = { - sils = 2; - soispha = 2; - nightingale = 2; - }; - - last_run = { - }; - }; - }; -} diff --git a/services/services.nix b/services/services.nix new file mode 100644 index 0000000..6983529 --- /dev/null +++ b/services/services.nix @@ -0,0 +1,8 @@ +{config, ...}: { + imports = [ + ./services/minecraft.nix + ./services/nix.nix + ./services/opensshd.nix + ./services/rust-motd.nix + ]; +} diff --git a/services/services/minecraft.nix b/services/services/minecraft.nix new file mode 100644 index 0000000..5882d9a --- /dev/null +++ b/services/services/minecraft.nix @@ -0,0 +1,26 @@ +{ + config, + pkgs, + ... +}: { + users = { + groups.minecraft = {}; + users.minecraft = { + isSystemUser = true; + group = "minecraft"; + }; + }; + systemd.services.minecraft = { + wantedBy = "multi-user.target"; + after = "network.target"; + description = "Minecraft Server"; + serviceConfig = { + WorkingDirectory = "/srv/minecraft"; + User = "minecraft"; + Group = "minecraft"; + Restart = "always"; + ExecStart = "${pkgs.openjdk}/bin/java -Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paper.jar --nogui"; + SyslogIdentifier = "minecraft-server"; + }; + }; +} 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/services/opensshd.nix b/services/services/opensshd.nix new file mode 100644 index 0000000..cb9f2ba --- /dev/null +++ b/services/services/opensshd.nix @@ -0,0 +1,18 @@ +{ + config, + pkg, + ... +}: { + services.openssh = { + enable = true; + passwordAuthentication = false; + hostKeys = [ + { + comment = "key comment"; + path = "/srv/sshd/ssh_host_ed25519_key"; + rounds = 1000; + type = "ed25519"; + } + ]; + }; +} diff --git a/services/services/rust-motd.nix b/services/services/rust-motd.nix new file mode 100644 index 0000000..21bc1cd --- /dev/null +++ b/services/services/rust-motd.nix @@ -0,0 +1,79 @@ +{ + config, + pkgs, + ... +}: { + programs.rust-motd = { + enable = true; + enableMotdInSSHD = true; + refreshInterval = "*:0/5"; # 0/5 means: hour 0 AND all hour wich match (0 + 5 * x) (is the same as: 0, 5, 10, 15, 20) + settings = { + global = { + progress_full_character = "="; + progress_empty_character = "-"; + progress_prefix = "["; + progress_suffix = "]"; + time_format = "%Y-%m-%d %H:%M:%S"; + }; + + banner = { + color = "red"; + command = "${pkgs.hostname}/bin/hostname | ${pkgs.figlet}/bin/figlet -f slant"; + # if you don't want a dependency on figlet, you can generate your + # banner however you want, put it in a file, and then use something like: + # command = "cat banner.txt" + }; + + # [weather] + # url = "https://wttr.in/New+York,New+York?0" + # proxy = "http://proxy:8080" + + # [service_status] + # Accounts = "accounts-daemon" + # Cron = "cron" + + # [docker_status] + # Local containers MUST start with a slash + # https://github.com/moby/moby/issues/6705 + #"/nextcloud-nextcloud-1" = "Nextcloud" + #"/nextcloud-nextcloud-mariadb-1" = "Nextcloud Database" + + uptime = { + prefix = "Uptime:"; + }; + + # [user_service_status] + # gpg-agent = "gpg-agent" + + #s_s_l_certs = { + # sort_method = "manual" + # + # certs = { + # CertName1 = "/path/to/cert1.pem" + # CertName2 = "/path/to/cert2.pem" + # } + #}; + + filesystems = { + root = "/"; + }; + + memory = { + swap_pos = "beside"; # or "below" or "none" + }; + + fail2_ban = { + jails = ["sshd"]; #, "anotherjail"] + }; + + last_login = { + sils = 2; + soispha = 2; + nightingale = 2; + }; + + last_run = { + }; + }; + }; +} diff --git a/system/fileSystemLayouts.nix b/system/fileSystemLayouts.nix deleted file mode 100644 index 9d03a05..0000000 --- a/system/fileSystemLayouts.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - 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/hardware.nix b/system/hardware.nix deleted file mode 100644 index c4c7dc9..0000000 --- a/system/hardware.nix +++ /dev/null @@ -1,9 +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"]; -} diff --git a/system/packages.nix b/system/packages.nix deleted file mode 100644 index 4d33c6e..0000000 --- a/system/packages.nix +++ /dev/null @@ -1,9 +0,0 @@ -{pkgs, ...}: { - environment.systemPackages = with pkgs; [ - jre_minimal - git - zsh - neovim - btrfs-progs - ]; -} diff --git a/system/system.nix b/system/system.nix new file mode 100644 index 0000000..2af4982 --- /dev/null +++ b/system/system.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/system/system/packages.nix b/system/system/packages.nix new file mode 100644 index 0000000..4d33c6e --- /dev/null +++ b/system/system/packages.nix @@ -0,0 +1,9 @@ +{pkgs, ...}: { + environment.systemPackages = with pkgs; [ + jre_minimal + git + zsh + neovim + btrfs-progs + ]; +} diff --git a/system/system/users.nix b/system/system/users.nix new file mode 100644 index 0000000..34e1648 --- /dev/null +++ b/system/system/users.nix @@ -0,0 +1,59 @@ +{pkgs, ...}: { + users.mutableUsers = false; + users.defaultUserShell = pkgs.zsh; + + users.users = { + root = { + #uid = 0; + #initialHashedPassword = null; # to lock root + # Backup, if something happens. TODO remove this later + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG63gxw8JePmrC8Fni0pLV4TnPBhCPmSV9FYEdva+6s7 sils" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBFuTNNn71Rhfnop2cdz3r/RhWWlCePnSBOhTBbu2ME soispha" + ]; + }; + + sils = { + name = "sils"; + isNormalUser = true; + home = "/srv/home/sils"; + initialHashedPassword = "$y$jFT$KpFnahVCE9JbE.5P3us8o.$ZzSxCusWqe3sL7b6DLgOXNNUf114tiiptM6T8lDxtKC"; # TODO CHANGE + uid = 1000; + extraGroups = [ + "wheel" + ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG63gxw8JePmrC8Fni0pLV4TnPBhCPmSV9FYEdva+6s7 sils" + ]; + }; + + soispha = { + name = "soispha"; + isNormalUser = true; + home = "/srv/home/soispha"; + initialHashedPassword = "$y$jFT$3.8XmUyukZvpExMUxDZkI.$IVrJgm8ysNDF/0vDD2kF6w73ozXgr1LMVRNN4Bq7pv1"; + uid = 1001; + extraGroups = [ + "wheel" + ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBFuTNNn71Rhfnop2cdz3r/RhWWlCePnSBOhTBbu2ME soispha" + ]; + }; + + nightingale = { + name = "nightingale"; + isNormalUser = true; + home = "/srv/home/nightingale"; + initialHashedPassword = null; # TODO CHANGE + uid = 1002; + extraGroups = [ + "wheel" + ]; + openssh.authorizedKeys.keys = [ + ]; + }; + }; +} +# vim: ts=2 + diff --git a/system/users.nix b/system/users.nix deleted file mode 100644 index 34e1648..0000000 --- a/system/users.nix +++ /dev/null @@ -1,59 +0,0 @@ -{pkgs, ...}: { - users.mutableUsers = false; - users.defaultUserShell = pkgs.zsh; - - users.users = { - root = { - #uid = 0; - #initialHashedPassword = null; # to lock root - # Backup, if something happens. TODO remove this later - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG63gxw8JePmrC8Fni0pLV4TnPBhCPmSV9FYEdva+6s7 sils" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBFuTNNn71Rhfnop2cdz3r/RhWWlCePnSBOhTBbu2ME soispha" - ]; - }; - - sils = { - name = "sils"; - isNormalUser = true; - home = "/srv/home/sils"; - initialHashedPassword = "$y$jFT$KpFnahVCE9JbE.5P3us8o.$ZzSxCusWqe3sL7b6DLgOXNNUf114tiiptM6T8lDxtKC"; # TODO CHANGE - uid = 1000; - extraGroups = [ - "wheel" - ]; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG63gxw8JePmrC8Fni0pLV4TnPBhCPmSV9FYEdva+6s7 sils" - ]; - }; - - soispha = { - name = "soispha"; - isNormalUser = true; - home = "/srv/home/soispha"; - initialHashedPassword = "$y$jFT$3.8XmUyukZvpExMUxDZkI.$IVrJgm8ysNDF/0vDD2kF6w73ozXgr1LMVRNN4Bq7pv1"; - uid = 1001; - extraGroups = [ - "wheel" - ]; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBFuTNNn71Rhfnop2cdz3r/RhWWlCePnSBOhTBbu2ME soispha" - ]; - }; - - nightingale = { - name = "nightingale"; - isNormalUser = true; - home = "/srv/home/nightingale"; - initialHashedPassword = null; # TODO CHANGE - uid = 1002; - extraGroups = [ - "wheel" - ]; - openssh.authorizedKeys.keys = [ - ]; - }; - }; -} -# vim: ts=2 - -- cgit 1.4.1 From 1b73e041b1aff42d3fdb448931c4aafdea986da8 Mon Sep 17 00:00:00 2001 From: ene Date: Sun, 5 Feb 2023 10:25:28 +0100 Subject: Feat: Use default.nix --- hosts/server1/configuration.nix | 4 ++-- services/default.nix | 8 ++++++++ services/services.nix | 8 -------- system/default.nix | 8 ++++++++ system/system.nix | 8 -------- 5 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 services/default.nix delete mode 100644 services/services.nix create mode 100644 system/default.nix delete mode 100644 system/system.nix (limited to 'system') diff --git a/hosts/server1/configuration.nix b/hosts/server1/configuration.nix index 6f91fc0..729ef0f 100644 --- a/hosts/server1/configuration.nix +++ b/hosts/server1/configuration.nix @@ -2,9 +2,9 @@ imports = [ ./networking.nix # network configuration that just works - ../../system/system.nix + ../../system - ../../services/services.nix + ../../services ]; boot.cleanTmpDir = true; 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/services.nix b/services/services.nix deleted file mode 100644 index 6983529..0000000 --- a/services/services.nix +++ /dev/null @@ -1,8 +0,0 @@ -{config, ...}: { - imports = [ - ./services/minecraft.nix - ./services/nix.nix - ./services/opensshd.nix - ./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.nix b/system/system.nix deleted file mode 100644 index 2af4982..0000000 --- a/system/system.nix +++ /dev/null @@ -1,8 +0,0 @@ -{config, ...}: { - imports = [ - ./system/fileSystemLayouts.nix - ./system/hardware.nix - ./system/packages.nix - ./system/users.nix - ]; -} -- cgit 1.4.1