Skip to content

Commit

Permalink
feat(nixos-server): Set static IP
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones2014 committed Jan 18, 2025
1 parent bedcf36 commit a03bc44
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion home-manager/modules/ssh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in {
enable = true;
forwardAgent = true;
matchBlocks = {
"nixos-server".hostname = "192.168.189.2";
"nixos-server".hostname = import ../../hosts/server/ip.nix;
"gitlab.1password.io" = {
port = 2227;
hostname = "ssh.gitlab.1password.io";
Expand Down
6 changes: 5 additions & 1 deletion hosts/server/hardware-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true;
# static IP on ethernet interface
networking.interfaces.enp0s31f6.ipv4.addresses = [{
address = import ./ip.nix;
prefixLength = 24;
}];

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode =
Expand Down
1 change: 1 addition & 0 deletions hosts/server/ip.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_: "192.168.189.2"
8 changes: 5 additions & 3 deletions hosts/server/nextcloud.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{ pkgs, config, ... }:
let port = 8888;
let
port = 8888;
ip = import ./ip.nix;
in {
age.secrets.nextcloud_admin_pass = {
file = ../../secrets/nextcloud_admin_pass.age;
Expand All @@ -19,7 +21,7 @@ in {
phpOptions."opcache.interned_strings_buffer" = "23";
configureRedis = true;
maxUploadSize = "1G";
hostName = "192.168.189.2";
hostName = ip;
home = "/mnt/nextcloud";
config = {
adminpassFile = config.age.secrets.nextcloud_admin_pass.path;
Expand Down Expand Up @@ -49,7 +51,7 @@ in {
};
};
# see https://nixos.wiki/wiki/Nextcloud#Change_default_listening_port
services.nginx.virtualHosts."192.168.189.2".listen = [{
services.nginx.virtualHosts."${ip}".listen = [{
addr = "0.0.0.0";
inherit port;
}];
Expand Down

0 comments on commit a03bc44

Please sign in to comment.