From 00e16adb899959f55344f44691c2b6a6ca25f1f2 Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Fri, 28 Mar 2025 10:13:26 +0100 Subject: [PATCH 1/6] structure changes to flake --- flake.lock | 27 ++++ starter/config.json | 11 ++ starter/configuration.nix | 243 +++++++++-------------------- starter/env/baserow.env | 2 +- starter/env/n8n.env | 1 + starter/flake.lock | 56 ++++++- starter/flake.nix | 19 ++- starter/hardware-configuration.nix | 26 --- 8 files changed, 175 insertions(+), 210 deletions(-) create mode 100644 flake.lock delete mode 100644 starter/hardware-configuration.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8c618e8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1741379970, + "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/starter/config.json b/starter/config.json index e69de29..8154012 100644 --- a/starter/config.json +++ b/starter/config.json @@ -0,0 +1,11 @@ +{ + "username": "m3tam3re", + "hashedPassword": "$6$WiEXGgna68Sm8vIN$oZ9YET4gQt9wtM.rQ0c4y9fYelkIhFV1lvppgYp8LplOstReounIlxKIIlNTLvdE.ZG8LkC03X0ZAyfXe07Z7/", + "sshKey": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMQolhh8u4ZXzr1a+ua6h4iHEgi5WjcD462+6lD+b+fP m3tam3re@m3-kratos", + "domains": { + "portainer": "p-t.m3tam3re.com", + "n8n": "n-t.m3tam3re.com", + "baserow": "b-t.m3tam3re.com" + }, + "rootDevice": "/dev/sda" +} diff --git a/starter/configuration.nix b/starter/configuration.nix index 903a93a..9182872 100644 --- a/starter/configuration.nix +++ b/starter/configuration.nix @@ -1,197 +1,94 @@ { + config, lib, pkgs, + self, ... }: # Read configuration from JSON let jsonConfig = builtins.fromJSON (builtins.readFile ./config.json); -in { - imports = [ - ./disko-config.nix - ./hardware-configuration.nix - ]; - # Enable flakes and nix commands - nix = { - settings = { - experimental-features = ["nix-command" "flakes"]; - # Enable automatic garbage collection - auto-optimise-store = true; + customServicesDir = ./custom-services; + customServicesExists = builtins.pathExists customServicesDir; + + customServices = + if customServicesExists + then + map + (name: ./custom-services + "/${name}") + (builtins.filter + (name: lib.hasSuffix ".nix" name) + (builtins.attrNames (builtins.readDir customServicesDir))) + else []; +in { + imports = + [ + ./disko-config.nix + ] + ++ customServices; + + options.nixosConfig.flake = lib.mkOption { + type = lib.types.path; + description = "Path to the current flake configuration"; + }; + + config = { + nix.settings = { trusted-users = [jsonConfig.username]; }; - # Automatic cleanup of old generations - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; + # Set the flake path + nixosConfig.flake = self; + + # Activation script to save the configuration + system.activationScripts.saveFlakeConfig = { + deps = []; + text = '' + rm -rf /etc/nixos/current-systemconfig + mkdir -p /etc/nixos/current-systemconfig + cp -rf ${config.nixosConfig.flake}/* /etc/nixos/current-systemconfig/ + cd /etc/nixos/current-systemconfig + chown -R ${jsonConfig.username}:users /etc/nixos/current-systemconfig + chmod -R u=rwX,g=rX,o=rX /etc/nixos/current-systemconfig + ''; }; - }; - # Boot configuration - boot.loader.grub = { - enable = true; - devices = [jsonConfig.rootDevice]; - efiSupport = true; - efiInstallAsRemovable = true; - }; - - # Networking - networking = { - firewall = { + services.selfHostPlaybook = { enable = true; - # Only allow necessary ports - allowedTCPPorts = [80 443 2222]; # HTTP, HTTPS, and SSH + tier = "starter"; # This determines which services are enabled }; - }; - environment.etc = { - environment-files = { - source = pkgs.copyPathToStore ./env; + # Networking + networking = { + firewall = { + enable = true; + # Only allow necessary ports + allowedTCPPorts = [80 443 2222]; # HTTP, HTTPS, and SSH + }; }; - }; - # System packages - environment.systemPackages = with pkgs; [ - # System utilities - neovim - git - # Docker tools - docker - docker-compose - ]; + environment.etc = { + environment-files = { + source = ./env; + }; + }; + # User configuration + users.users.${jsonConfig.username} = { + isNormalUser = true; + extraGroups = ["wheel" "docker"]; + hashedPassword = jsonConfig.hashedPassword; + openssh.authorizedKeys.keys = [jsonConfig.sshKey]; + # Set default shell to bash + shell = pkgs.bash; + }; - # Enable Docker with recommended settings - virtualisation.docker = { - enable = true; - # Enable docker daemon to start on boot - enableOnBoot = true; - # Use overlay2 storage driver - storageDriver = "overlay2"; - # Enable live restore - liveRestore = true; - }; - - # Services configuration - services = { - # SSH server configuration - openssh = { + programs.git = { enable = true; - settings = { - PermitRootLogin = "no"; - PasswordAuthentication = false; - # Additional security settings - MaxAuthTries = 3; - LoginGraceTime = "30s"; - }; - ports = [2222]; - }; - - # Caddy configuration with security headers - caddy = { - enable = true; - virtualHosts = { - "${jsonConfig.domains.portainer}" = { - extraConfig = '' - reverse_proxy localhost:9000 - header { - # Security headers - Strict-Transport-Security "max-age=31536000; includeSubDomains" - X-Content-Type-Options "nosniff" - X-Frame-Options "DENY" - Referrer-Policy "strict-origin-when-cross-origin" - } - ''; - }; - "${jsonConfig.domains.n8n}" = { - extraConfig = '' - reverse_proxy localhost:5678 - header { - Strict-Transport-Security "max-age=31536000; includeSubDomains" - X-Content-Type-Options "nosniff" - X-Frame-Options "DENY" - Referrer-Policy "strict-origin-when-cross-origin" - } - ''; - }; - "${jsonConfig.domains.baserow}" = { - extraConfig = '' - reverse_proxy localhost:3000 - header { - Strict-Transport-Security "max-age=31536000; includeSubDomains" - X-Content-Type-Options "nosniff" - X-Frame-Options "DENY" - Referrer-Policy "strict-origin-when-cross-origin" - } - ''; - }; + config = { + user.name = jsonConfig.username; + user.email = "${jsonConfig.username}@nixos"; + safe.directory = "/etc/nixos/current-systemconfig"; }; }; }; - # User configuration - users.users.${jsonConfig.username} = { - isNormalUser = true; - extraGroups = ["wheel" "docker"]; - hashedPassword = jsonConfig.hashedPassword; - openssh.authorizedKeys.keys = [jsonConfig.sshKey]; - # Set default shell to bash - shell = pkgs.bash; - }; - - # Container configurations - virtualisation.oci-containers = { - backend = "docker"; - containers = { - "portainer" = { - image = "docker.io/portainer/portainer-ce:latest"; - ports = ["127.0.0.1:9000:9000"]; - volumes = [ - "/etc/localtime:/etc/localtime:ro" - "/var/run/docker.sock:/var/run/docker.sock:ro" - "portainer_data:/data" - ]; - extraOptions = [ - "--network=web" - ]; - }; - - "n8n" = { - image = "docker.io/n8nio/n8n:latest"; - environmentFiles = ["/etc/environment-files/n8n.env"]; - ports = ["127.0.0.1:5678:5678"]; - volumes = ["n8n_data:/home/node/.n8n"]; - extraOptions = ["--network=web"]; - }; - - "baserow" = { - image = "docker.io/baserow/baserow:latest"; - environmentFiles = ["/etc/environment-files/baserow.env"]; - ports = ["127.0.0.1:3000:80"]; - volumes = ["baserow_data:/baserow/data"]; - extraOptions = ["--network=web"]; - }; - }; - }; - - systemd.services.docker-network-web = { - description = "Create Docker Network Web"; - requires = ["docker.service"]; - after = ["docker.service"]; - wantedBy = ["multi-user.target"]; - - # Run on startup if network doesn't exist - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - - script = '' - if ! /run/current-system/sw/bin/docker network ls | grep -q 'web'; then - /run/current-system/sw/bin/docker network create web - fi - ''; - }; - - # System state version (do not change) - system.stateVersion = "24.11"; } diff --git a/starter/env/baserow.env b/starter/env/baserow.env index cd30d72..5e30b1c 100644 --- a/starter/env/baserow.env +++ b/starter/env/baserow.env @@ -1 +1 @@ -BASEROW_PUBLIC_URL=https://BASEROW_DOMAIN +BASEROW_PUBLIC_URL=https://b-t.m3tam3re.com diff --git a/starter/env/n8n.env b/starter/env/n8n.env index c66516e..b3515eb 100644 --- a/starter/env/n8n.env +++ b/starter/env/n8n.env @@ -1,3 +1,4 @@ N8N_HOST=N8N_DOMAIN +WEBHOOK_URL=https://N8N_DOMAIN NODE_ENV=production N8N_ENCRYPTION_KEY=changeme diff --git a/starter/flake.lock b/starter/flake.lock index 742661d..946432d 100644 --- a/starter/flake.lock +++ b/starter/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "base-config": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + }, + "locked": { + "lastModified": 1741872348, + "narHash": "sha256-4d0S59c/rR5lcfqeqw3z+k4FlDwyci6dwrwMPgKuO/g=", + "ref": "stable", + "rev": "50af8d01fb5d5d5616bd1d5c38ced9946f863ca4", + "revCount": 6, + "type": "git", + "url": "https://code.m3tam3re.com/m3tam3re/self-host-playbook-base" + }, + "original": { + "ref": "stable", + "type": "git", + "url": "https://code.m3tam3re.com/m3tam3re/self-host-playbook-base" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -7,11 +27,11 @@ ] }, "locked": { - "lastModified": 1739760714, - "narHash": "sha256-SaGuzIQUTC2UPwX0aTm9W4aSEUcq3h6yZbi30piej2U=", + "lastModified": 1741786315, + "narHash": "sha256-VT65AE2syHVj6v/DGB496bqBnu1PXrrzwlw07/Zpllc=", "owner": "nix-community", "repo": "disko", - "rev": "be1e4321c9fb3a4bc2c061dafcdb424937a74dad", + "rev": "0d8c6ad4a43906d14abd5c60e0ffe7b587b213de", "type": "github" }, "original": { @@ -22,24 +42,44 @@ }, "nixpkgs": { "locked": { - "lastModified": 1739580444, - "narHash": "sha256-+/bSz4EAVbqz8/HsIGLroF8aNaO8bLRL7WfACN+24g4=", + "lastModified": 1741600792, + "narHash": "sha256-yfDy6chHcM7pXpMF4wycuuV+ILSTG486Z/vLx/Bdi6Y=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8bb37161a0488b89830168b81c48aed11569cb93", + "rev": "ebe2788eafd539477f83775ef93c3c7e244421d3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1741708242, + "narHash": "sha256-cNRqdQD4sZpN7JLqxVOze4+WsWTmv2DGH0wNCOVwrWc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b62d2a95c72fb068aecd374a7262b37ed92df82b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b62d2a95c72fb068aecd374a7262b37ed92df82b", + "type": "github" + } + }, "root": { "inputs": { + "base-config": "base-config", "disko": "disko", - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "base-config", + "nixpkgs" + ] } } }, diff --git a/starter/flake.nix b/starter/flake.nix index 304c4cf..f114302 100644 --- a/starter/flake.nix +++ b/starter/flake.nix @@ -2,7 +2,14 @@ description = "Self-hosted server setup with Portainer, n8n, and Baserow"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + base-config = { + # url = "path:/home/m3tam3re/p/nix/self-host-playbook-base"; + url = "git+https://code.m3tam3re.com/m3tam3re/self-host-playbook-base?ref=stable"; + }; + nixpkgs = { + url = "github:NixOS/nixpkgs/nixos-24.11"; + follows = "base-config/nixpkgs"; + }; disko = { url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgs"; @@ -11,15 +18,23 @@ outputs = { self, + base-config, nixpkgs, ... } @ inputs: { - nixosConfigurations.server = nixpkgs.lib.nixosSystem { + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ + (base-config.nixosModules.default { + tier = "starter"; + jsonConfig = builtins.fromJSON (builtins.readFile ./config.json); + }) # Pass tier here inputs.disko.nixosModules.disko ./configuration.nix ]; + specialArgs = { + inherit self; + }; }; }; } diff --git a/starter/hardware-configuration.nix b/starter/hardware-configuration.nix deleted file mode 100644 index 4daad50..0000000 --- a/starter/hardware-configuration.nix +++ /dev/null @@ -1,26 +0,0 @@ -# Do not modify this file! It was generated by β€˜nixos-generate-config’ -# and may be overwritten by future invocations. Please make changes -# to /etc/nixos/configuration.nix instead. -{ - lib, - modulesPath, - ... -}: { - imports = [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; - - boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod"]; - boot.initrd.kernelModules = []; - boot.kernelModules = []; - boot.extraModulePackages = []; - - # Enables DHCP on each ethernet and wireless interface. In case of scripted networking - # (the default) this is the recommended approach. When using systemd-networkd it's - # still possible to use this option, but it's recommended to use it in conjunction - # with explicit per-interface declarations with `networking.interfaces..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.ens18.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; -} From 8b7635d56ad63824d8489aaf03ce77bea7f51c4f Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Thu, 3 Apr 2025 09:28:07 +0200 Subject: [PATCH 2/6] +gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d344ba6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json From e653e1640a89348eae47211fa7710c00bd227405 Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Thu, 3 Apr 2025 09:42:57 +0200 Subject: [PATCH 3/6] +version file --- starter/version.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 starter/version.json diff --git a/starter/version.json b/starter/version.json new file mode 100644 index 0000000..590ac5d --- /dev/null +++ b/starter/version.json @@ -0,0 +1,8 @@ +{ + "version": "0.1.0", + "minCompatibleVersion": "0.0.0", + "updateUrl": "https://code.m3tam3re.com/m3tam3re/self-host-playbook", + "changelog": { + "0.1.0": ["Management CLI", "Flake rework"] + } +} From 851ffc4ed3cc0dac56910ac3043c710071ed2eac Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Thu, 3 Apr 2025 10:24:42 +0200 Subject: [PATCH 4/6] +version file --- .gitignore | 2 +- starter/config.json | 11 ----------- starter/env/baserow.env | 2 +- 3 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 starter/config.json diff --git a/.gitignore b/.gitignore index d344ba6..6bf1823 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -config.json +starter/config.json diff --git a/starter/config.json b/starter/config.json deleted file mode 100644 index 8154012..0000000 --- a/starter/config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "username": "m3tam3re", - "hashedPassword": "$6$WiEXGgna68Sm8vIN$oZ9YET4gQt9wtM.rQ0c4y9fYelkIhFV1lvppgYp8LplOstReounIlxKIIlNTLvdE.ZG8LkC03X0ZAyfXe07Z7/", - "sshKey": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMQolhh8u4ZXzr1a+ua6h4iHEgi5WjcD462+6lD+b+fP m3tam3re@m3-kratos", - "domains": { - "portainer": "p-t.m3tam3re.com", - "n8n": "n-t.m3tam3re.com", - "baserow": "b-t.m3tam3re.com" - }, - "rootDevice": "/dev/sda" -} diff --git a/starter/env/baserow.env b/starter/env/baserow.env index 5e30b1c..cd30d72 100644 --- a/starter/env/baserow.env +++ b/starter/env/baserow.env @@ -1 +1 @@ -BASEROW_PUBLIC_URL=https://b-t.m3tam3re.com +BASEROW_PUBLIC_URL=https://BASEROW_DOMAIN From 171e9dd89e6ce6a625464169238f64ec822d0411 Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Thu, 3 Apr 2025 11:10:07 +0200 Subject: [PATCH 5/6] Flake Rework --- .gitignore | 2 +- starter/README.md => README.md | 0 .../configuration.nix => configuration.nix | 0 starter/disko-config.nix => disko-config.nix | 0 {starter/env => env}/baserow.env | 0 {starter/env => env}/n8n.env | 0 flake.lock | 71 +++++++++++++-- flake.nix | 51 ++++++----- starter/install.sh => install.sh | 0 starter/flake.lock | 88 ------------------- starter/flake.nix | 40 --------- starter/version.json => version.json | 0 12 files changed, 98 insertions(+), 154 deletions(-) rename starter/README.md => README.md (100%) rename starter/configuration.nix => configuration.nix (100%) rename starter/disko-config.nix => disko-config.nix (100%) rename {starter/env => env}/baserow.env (100%) rename {starter/env => env}/n8n.env (100%) rename starter/install.sh => install.sh (100%) delete mode 100644 starter/flake.lock delete mode 100644 starter/flake.nix rename starter/version.json => version.json (100%) diff --git a/.gitignore b/.gitignore index 6bf1823..d344ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -starter/config.json +config.json diff --git a/starter/README.md b/README.md similarity index 100% rename from starter/README.md rename to README.md diff --git a/starter/configuration.nix b/configuration.nix similarity index 100% rename from starter/configuration.nix rename to configuration.nix diff --git a/starter/disko-config.nix b/disko-config.nix similarity index 100% rename from starter/disko-config.nix rename to disko-config.nix diff --git a/starter/env/baserow.env b/env/baserow.env similarity index 100% rename from starter/env/baserow.env rename to env/baserow.env diff --git a/starter/env/n8n.env b/env/n8n.env similarity index 100% rename from starter/env/n8n.env rename to env/n8n.env diff --git a/flake.lock b/flake.lock index 8c618e8..946432d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,85 @@ { "nodes": { + "base-config": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + }, + "locked": { + "lastModified": 1741872348, + "narHash": "sha256-4d0S59c/rR5lcfqeqw3z+k4FlDwyci6dwrwMPgKuO/g=", + "ref": "stable", + "rev": "50af8d01fb5d5d5616bd1d5c38ced9946f863ca4", + "revCount": 6, + "type": "git", + "url": "https://code.m3tam3re.com/m3tam3re/self-host-playbook-base" + }, + "original": { + "ref": "stable", + "type": "git", + "url": "https://code.m3tam3re.com/m3tam3re/self-host-playbook-base" + } + }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741786315, + "narHash": "sha256-VT65AE2syHVj6v/DGB496bqBnu1PXrrzwlw07/Zpllc=", + "owner": "nix-community", + "repo": "disko", + "rev": "0d8c6ad4a43906d14abd5c60e0ffe7b587b213de", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1741379970, - "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", + "lastModified": 1741600792, + "narHash": "sha256-yfDy6chHcM7pXpMF4wycuuV+ILSTG486Z/vLx/Bdi6Y=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", + "rev": "ebe2788eafd539477f83775ef93c3c7e244421d3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1741708242, + "narHash": "sha256-cNRqdQD4sZpN7JLqxVOze4+WsWTmv2DGH0wNCOVwrWc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b62d2a95c72fb068aecd374a7262b37ed92df82b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b62d2a95c72fb068aecd374a7262b37ed92df82b", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "base-config": "base-config", + "disko": "disko", + "nixpkgs": [ + "base-config", + "nixpkgs" + ] } } }, diff --git a/flake.nix b/flake.nix index 0b0ba0b..f114302 100644 --- a/flake.nix +++ b/flake.nix @@ -1,29 +1,40 @@ { - description = "Self Host Playbook!"; + description = "Self-hosted server setup with Portainer, n8n, and Baserow"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + base-config = { + # url = "path:/home/m3tam3re/p/nix/self-host-playbook-base"; + url = "git+https://code.m3tam3re.com/m3tam3re/self-host-playbook-base?ref=stable"; + }; + nixpkgs = { + url = "github:NixOS/nixpkgs/nixos-24.11"; + follows = "base-config/nixpkgs"; + }; + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = {nixpkgs, ...}: let - systems = [ - "aarch64-linux" - "i686-linux" - "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - forAllSystems = nixpkgs.lib.genAttrs systems; - in { - templates = { - starter = { - description = '' - Description here! - ''; - path = ./starter; + outputs = { + self, + base-config, + nixpkgs, + ... + } @ inputs: { + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + (base-config.nixosModules.default { + tier = "starter"; + jsonConfig = builtins.fromJSON (builtins.readFile ./config.json); + }) # Pass tier here + inputs.disko.nixosModules.disko + ./configuration.nix + ]; + specialArgs = { + inherit self; }; }; - formatter = - forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); }; } diff --git a/starter/install.sh b/install.sh similarity index 100% rename from starter/install.sh rename to install.sh diff --git a/starter/flake.lock b/starter/flake.lock deleted file mode 100644 index 946432d..0000000 --- a/starter/flake.lock +++ /dev/null @@ -1,88 +0,0 @@ -{ - "nodes": { - "base-config": { - "inputs": { - "nixpkgs": "nixpkgs", - "nixpkgs-unstable": "nixpkgs-unstable" - }, - "locked": { - "lastModified": 1741872348, - "narHash": "sha256-4d0S59c/rR5lcfqeqw3z+k4FlDwyci6dwrwMPgKuO/g=", - "ref": "stable", - "rev": "50af8d01fb5d5d5616bd1d5c38ced9946f863ca4", - "revCount": 6, - "type": "git", - "url": "https://code.m3tam3re.com/m3tam3re/self-host-playbook-base" - }, - "original": { - "ref": "stable", - "type": "git", - "url": "https://code.m3tam3re.com/m3tam3re/self-host-playbook-base" - } - }, - "disko": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1741786315, - "narHash": "sha256-VT65AE2syHVj6v/DGB496bqBnu1PXrrzwlw07/Zpllc=", - "owner": "nix-community", - "repo": "disko", - "rev": "0d8c6ad4a43906d14abd5c60e0ffe7b587b213de", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "disko", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1741600792, - "narHash": "sha256-yfDy6chHcM7pXpMF4wycuuV+ILSTG486Z/vLx/Bdi6Y=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ebe2788eafd539477f83775ef93c3c7e244421d3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-24.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1741708242, - "narHash": "sha256-cNRqdQD4sZpN7JLqxVOze4+WsWTmv2DGH0wNCOVwrWc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b62d2a95c72fb068aecd374a7262b37ed92df82b", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b62d2a95c72fb068aecd374a7262b37ed92df82b", - "type": "github" - } - }, - "root": { - "inputs": { - "base-config": "base-config", - "disko": "disko", - "nixpkgs": [ - "base-config", - "nixpkgs" - ] - } - } - }, - "root": "root", - "version": 7 -} diff --git a/starter/flake.nix b/starter/flake.nix deleted file mode 100644 index f114302..0000000 --- a/starter/flake.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - description = "Self-hosted server setup with Portainer, n8n, and Baserow"; - - inputs = { - base-config = { - # url = "path:/home/m3tam3re/p/nix/self-host-playbook-base"; - url = "git+https://code.m3tam3re.com/m3tam3re/self-host-playbook-base?ref=stable"; - }; - nixpkgs = { - url = "github:NixOS/nixpkgs/nixos-24.11"; - follows = "base-config/nixpkgs"; - }; - disko = { - url = "github:nix-community/disko"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = { - self, - base-config, - nixpkgs, - ... - } @ inputs: { - nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - (base-config.nixosModules.default { - tier = "starter"; - jsonConfig = builtins.fromJSON (builtins.readFile ./config.json); - }) # Pass tier here - inputs.disko.nixosModules.disko - ./configuration.nix - ]; - specialArgs = { - inherit self; - }; - }; - }; -} diff --git a/starter/version.json b/version.json similarity index 100% rename from starter/version.json rename to version.json From 851f1b1344f6362ed7b9b014f568cff29443f23b Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Wed, 9 Apr 2025 16:08:16 +0200 Subject: [PATCH 6/6] Prepare v0.1.0 --- .gitignore | 1 - flake.lock | 3 + flake.nix | 22 +++- install.sh | 155 +++++++++++++++++++++++++--- update.sh | 280 +++++++++++++++++++++++++++++++++++++++++++++++++++ version.json | 8 +- 6 files changed, 451 insertions(+), 18 deletions(-) delete mode 100644 .gitignore create mode 100644 update.sh diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d344ba6..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -config.json diff --git a/flake.lock b/flake.lock index 946432d..c1682f5 100644 --- a/flake.lock +++ b/flake.lock @@ -75,6 +75,9 @@ "root": { "inputs": { "base-config": "base-config", + "deploy-rs": [ + "nixpkgs" + ], "disko": "disko", "nixpkgs": [ "base-config", diff --git a/flake.nix b/flake.nix index f114302..4357c73 100644 --- a/flake.nix +++ b/flake.nix @@ -14,20 +14,27 @@ url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgs"; }; + deploy-rs = { + url = "github:serokell/deploy-rs"; + follows = "nixpkgs"; + }; }; outputs = { self, base-config, + deploy-rs, nixpkgs, ... - } @ inputs: { + } @ inputs: let + jsonConfig = builtins.fromJSON (builtins.readFile ./config.json); + in { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ (base-config.nixosModules.default { tier = "starter"; - jsonConfig = builtins.fromJSON (builtins.readFile ./config.json); + inherit jsonConfig; }) # Pass tier here inputs.disko.nixosModules.disko ./configuration.nix @@ -36,5 +43,16 @@ inherit self; }; }; + deploy.nodes.nixos = { + hostname = "self-host-playbook"; + profiles.system = { + sshUser = jsonConfig.username; + user = "root"; + interactiveSudo = true; + path = + deploy-rs.lib.x86_64-linux.activate.nixos + self.nixosConfigurations.nixos; + }; + }; }; } diff --git a/install.sh b/install.sh index 099d955..2bfeb89 100755 --- a/install.sh +++ b/install.sh @@ -13,14 +13,23 @@ fi if [ -z "${INSIDE_NIX_SHELL+x}" ]; then export NIX_CONFIG="experimental-features = nix-command flakes" export INSIDE_NIX_SHELL=1 - exec nix shell nixpkgs#git nixpkgs#mkpasswd --command bash "$0" + exec nix shell nixpkgs#git nixpkgs#mkpasswd nixpkgs#jq --command bash "$0" fi -# Function to setup from template -setup_from_template() { - local TEMPLATE=starter - local DIR_NAME="self-host-playbook" +# Check directory situation and handle navigation +DIR_NAME="self-host-playbook" +CURRENT_DIR=$(basename "$(pwd)") +if [ "$CURRENT_DIR" = "$DIR_NAME" ]; then + echo "πŸ“‚ Already in $DIR_NAME directory" + echo "⚠️ Warning: Proceeding will overwrite the current version!" + read -p "Do you want to continue? (y/N) " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "❌ Operation cancelled" + exit 1 + fi +else if [ -d "$DIR_NAME" ]; then echo "πŸ“‚ Directory '$DIR_NAME' already exists" read -p "Do you want to proceed in the existing directory? (y/N) " -n 1 -r @@ -32,17 +41,78 @@ setup_from_template() { exit 1 fi else - echo "πŸ”„ Creating new self-host-playbook configuration from template..." - nix flake new --template "git+https://code.m3tam3re.com/m3tam3re/self-host-playbook#${TEMPLATE}" "$DIR_NAME" + echo "πŸ”„ Creating new self-host-playbook configuration..." + mkdir -p "$DIR_NAME" cd "$DIR_NAME" fi +fi + +get_latest_version() { + local LATEST_VERSION + + latest_version=$(curl -s "https://code.m3tam3re.com/api/v1/repos/m3tam3re/self-host-playbook/tags" | jq -r '.[] | select(.name | startswith("v")) | .name' | sort -V | tail -n1) + + if [ -z "$latest_version" ]; then + echo "❌ Error: Could not fetch latest version from repository" + exit 1 + fi + + # Remove 'v' prefix if present and return + echo "${latest_version#v}" +} + +setup_latest_version() { + local target_version=$1 + local dir_name=$2 + + echo "⬇️ Downloading version $target_version..." + + TEMP_DIR=$(mktemp -d) + trap 'rm -rf "$TEMP_DIR"' EXIT + + # Create a subdirectory for the clone + CLONE_DIR="${TEMP_DIR}/clone" + mkdir -p "$CLONE_DIR" + + # Clone to temporary directory with --quiet flag + if ! nix flake clone --quiet "git+https://code.m3tam3re.com/m3tam3re/self-host-playbook?ref=v${target_version}" --dest "$CLONE_DIR" 2>/dev/null; then + echo "❌ Failed to clone repository" + return 1 + fi + + # Copy files from clone to target directory + cp -r "$CLONE_DIR"/* "$dir_name/" + + return 0 +} + +# Function to setup from template +setup_from_template() { + # Create backup if directory is not empty + if [ -n "$(ls -A)" ]; then + local CURRENT_VERSION=$(date +%Y%m%d_%H%M%S) + local backup_dir="backup_${CURRENT_VERSION}_$(date +%Y%m%d_%H%M%S)" + echo "πŸ“‘ Creating backup in $backup_dir..." + mkdir -p "$backup_dir" + find . -maxdepth 1 ! -name "." ! -name ".." ! -name "$backup_dir" -exec cp -r {} "$backup_dir/" \; + echo "βœ… Backup created successfully" + + # Clean current directory except backup + echo "πŸ—‘οΈ Cleaning current directory..." + find . -maxdepth 1 ! -name "." ! -name ".." ! -name "$backup_dir" -exec rm -rf {} \; + fi + + # Get and setup latest version + local LATEST_VERSION=$(get_latest_version) + echo "⬇️ Setting up version $LATEST_VERSION..." + setup_latest_version "$LATEST_VERSION" "." } # Function to generate SSH key generate_ssh_key() { local KEY_NAME="self-host-playbook" local KEY_PATH="$HOME/.ssh/${KEY_NAME}" - +W if [ ! -f "$KEY_PATH" ]; then mkdir -p "$HOME/.ssh" echo "πŸ”‘ Generating new SSH key pair..." >&2 @@ -122,6 +192,58 @@ get_device_name() { esac } +setup_ssh_config() { + local username=$1 + local ip_address=$2 + local ssh_config_dir="$HOME/.ssh" + local ssh_config_file="$ssh_config_dir/config" + local ssh_key_file="$ssh_config_dir/self-host-playbook" + + # Create .ssh directory if it doesn't exist + mkdir -p "$ssh_config_dir" + chmod 700 "$ssh_config_dir" + + # Create or append to SSH config + local config_entry="Host self-host-playbook + HostName $ip_address + User $username + IdentityFile $ssh_key_file" + + # Check if entry already exists + if ! grep -q "Host self-host-playbook" "$ssh_config_file" 2>/dev/null; then + echo -e "\n$config_entry" >> "$ssh_config_file" + echo "βœ… Added SSH config entry" + else + # Update existing entry + sed -i.bak "/Host self-host-playbook/,/IdentityFile.*/{ + s/HostName.*/HostName $ip_address/ + s/User.*/User $username/ + }" "$ssh_config_file" + echo "βœ… Updated existing SSH config entry" + fi + + # Set appropriate permissions + chmod 600 "$ssh_config_file" +} + +install_deploy_rs() { + echo "πŸ”§ Installing deploy-rs to user environment..." + + # Check if deploy is already installed + if command -v deploy >/dev/null 2>&1; then + echo "ℹ️ deploy-rs is already installed" + return 0 + fi + + # Install deploy-rs using nix profile + if nix profile install 'github:serokell/deploy-rs'; then + echo "βœ… deploy-rs installed successfully" + else + echo "❌ Failed to install deploy-rs" + return 1 + fi +} + echo "πŸš€ Welcome to the Self-Host Playbook!" echo "================================================" echo "This script will help you manage your NixOS server with:" @@ -155,11 +277,11 @@ read -p "Press ENTER to continue or CTRL + C to abort..." echo "" echo "πŸ“ Please provide the following information:" echo "-------------------------------------------" -read -p "1. Enter target server IP address: " SERVER_IP +read -p "1. Enter target server IP address: " IP_ADDRESS read -p "2. Enter desired username for server access: " USERNAME read -s -p "3. Enter desired password: " PASSWORD echo -echo "4. Enter domain names for services (must point to $SERVER_IP):" +echo "4. Enter domain names for services (must point to $IP_ADDRESS):" read -p " - Domain for Portainer: " PORTAINER_DOMAIN read -p " - Domain for n8n: " N8N_DOMAIN read -p " - Domain for Baserow: " BASEROW_DOMAIN @@ -173,10 +295,10 @@ read -p "Enter your choice (1-2): " KEY_CHOICE case $KEY_CHOICE in 1) - INSTALL_COMMAND="nix run github:nix-community/nixos-anywhere -- --flake .#server root@$SERVER_IP" + INSTALL_COMMAND="nix run github:nix-community/nixos-anywhere -- --flake .#server root@$IP_ADDRESS" ;; 2) - INSTALL_COMMAND="nix run github:nix-community/nixos-anywhere -- --flake .#server -i $SSH_KEY_PATH root@$SERVER_IP" + INSTALL_COMMAND="nix run github:nix-community/nixos-anywhere -- --flake .#server -i $SSH_KEY_PATH root@$IP_ADDRESS" ;; *) echo "❌ Invalid choice" @@ -264,7 +386,8 @@ cat > config.json << EOF "n8n": "$N8N_DOMAIN", "baserow": "$BASEROW_DOMAIN" }, - "rootDevice": "$DEVICE_NAME" + "rootDevice": "$DEVICE_NAME", + "ipAddress": "$IP_ADDRESS" } EOF @@ -292,6 +415,8 @@ echo "This process might take several minutes..." # Run nixos-anywhere installation $INSTALL_COMMAND && { + echo "πŸ”§ Setting up SSH configuration..." + setup_ssh_config "$USERNAME" "$IP_ADDRESS" echo echo "πŸŽ‰ Installation completed successfully!" echo "=====================================>" @@ -301,7 +426,9 @@ $INSTALL_COMMAND && { echo "- Baserow: https://$BASEROW_DOMAIN" echo echo "To connect to your server, use:" - echo "ssh -i $SSH_KEY_PATH -p 2222 $USERNAME@$SERVER_IP" + echo "ssh self-host-playbook" + echo + install_deploy_rs echo echo "⚠️ Important: Please save your SSH key path: $SSH_KEY_PATH" echo "=====================================>" diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..926a66e --- /dev/null +++ b/update.sh @@ -0,0 +1,280 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Ensure we're in a flakes-enabled environment with required tools +if ! command -v nix &> /dev/null; then + echo "❌ Nix is not installed. Please install Nix first:" + echo "curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install" + exit 1 +fi + +# Check if we need to enter a new shell +if [ -z "${INSIDE_NIX_SHELL+x}" ]; then + export NIX_CONFIG="experimental-features = nix-command flakes" + export INSIDE_NIX_SHELL=1 + exec nix shell nixpkgs#git nixpkgs#jq --command bash "$0" +fi + +get_current_version() { + local version_file=$1 + if [ -f "$version_file" ]; then + jq -r '.version' "$version_file" + else + echo "0.0.0" + fi +} + +get_latest_version() { + local LATEST_VERSION + + latest_version=$(curl -s "https://code.m3tam3re.com/api/v1/repos/m3tam3re/self-host-playbook/tags" | jq -r '.[] | select(.name | startswith("v")) | .name' | sort -V | tail -n1) + + if [ -z "$latest_version" ]; then + echo "❌ Error: Could not fetch latest version from repository" + exit 1 + fi + + # Remove 'v' prefix if present and return + echo "${latest_version#v}" +} + +check_compatibility() { + local current_version=$1 + local target_version=$2 + local version_file=$3 + + # Special case for initial install + if [ "$current_version" = "0.0.0" ]; then + echo "ℹ️ First time upgrade detected - proceeding with upgrade" + return 0 + fi + + local min_compatible_version + min_compatible_version=$(curl -s "https://code.m3tam3re.com/m3tam3re/self-host-playbook/raw/branch/develop/v${target_version}/$version_file" | jq -r '.minCompatibleVersion') + + if version_lt "$current_version" "$min_compatible_version"; then + echo "❌ Your current version ($current_version) is too old for direct upgrade." + echo "Please upgrade to version $min_compatible_version first." + return 1 + fi + return 0 +} + +# Show changelog - modified to use version file parameter +show_changelog() { + local current_version=$1 + local target_version=$2 + local version_file=$3 + + echo "πŸ“‹ Changelog from $current_version to $target_version:" + echo "------------------------------------------------" + + local changelog + changelog=$(curl -s "https://code.m3tam3re.com/m3tam3re/self-host-playbook/raw/branch/develop/v${target_version}/$version_file" | jq -r '.changelog') + + # Process each version once, then all its changes + echo "$changelog" | jq -r --arg cv "$current_version" --arg tv "$target_version" ' + to_entries[] + | select(.key > $cv and .key <= $tv) + | "\(.key):\n" + (.value | map(" - " + .) | join("\n")) + ' 2>/dev/null + + echo "------------------------------------------------" +} + +perform_update() { + local target_version=$1 + local backup_dir=$2 + echo "⬇️ Downloading version $target_version..." + + TEMP_DIR=$(mktemp -d) + trap 'rm -rf "$TEMP_DIR"' EXIT + + # Create a subdirectory for the clone + CLONE_DIR="${TEMP_DIR}/clone" + mkdir -p "$CLONE_DIR" + + # Clone to temporary directory with --quiet flag + if ! nix flake clone --quiet "git+https://code.m3tam3re.com/m3tam3re/self-host-playbook?ref=v${target_version}" --dest "$CLONE_DIR" 2>/dev/null; then + echo "❌ Failed to clone repository" + return 1 + fi + + # Remove current directory contents except backup + echo "πŸ—‘οΈ Cleaning current directory..." + find . -maxdepth 1 ! -name "." ! -name ".." ! -name "$backup_dir" -exec rm -rf {} + + + # Copy new version from clone + echo "πŸ“‹ Installing new version..." + cp -r "$CLONE_DIR"/* . + + # Restore configuration files from backup + echo "πŸ”„ Restoring configuration files..." + cp -r "${backup_dir}/config.json" \ + "${backup_dir}/env" . 2>/dev/null || true + + + return 0 +} + +setup_ssh_config() { + local username=$1 + local ip_address=$2 + local ssh_config_dir="$HOME/.ssh" + local ssh_config_file="$ssh_config_dir/config" + local ssh_key_file="$ssh_config_dir/self-host-playbook" + + # Create .ssh directory if it doesn't exist + mkdir -p "$ssh_config_dir" + chmod 700 "$ssh_config_dir" + + # Create or append to SSH config + local config_entry="Host self-host-playbook + HostName $ip_address + User $username + IdentityFile $ssh_key_file" + + # Check if entry already exists + if ! grep -q "Host self-host-playbook" "$ssh_config_file" 2>/dev/null; then + echo -e "\n$config_entry" >> "$ssh_config_file" + echo "βœ… Added SSH config entry" + else + # Update existing entry + sed -i.bak "/Host self-host-playbook/,/IdentityFile.*/{ + s/HostName.*/HostName $ip_address/ + s/User.*/User $username/ + }" "$ssh_config_file" + echo "βœ… Updated existing SSH config entry" + fi + + # Set appropriate permissions + chmod 600 "$ssh_config_file" +} + +update_config_json() { + local ip_address=$1 + local config_file="config.json" + + # Read existing config + local config + config=$(cat "$config_file") + + # Update or add ipAddress field + if jq -e '.ipAddress' "$config_file" >/dev/null 2>&1; then + config=$(echo "$config" | jq --arg ip "$ip_address" '.ipAddress = $ip') + else + config=$(echo "$config" | jq --arg ip "$ip_address" '. + {ipAddress: $ip}') + fi + + # Write back to file + echo "$config" | jq '.' > "$config_file" + echo "βœ… Updated IP address in config.json" +} + +install_deploy_rs() { + echo "πŸ”§ Installing deploy-rs to user environment..." + + # Check if deploy is already installed + if command -v deploy >/dev/null 2>&1; then + echo "ℹ️ deploy-rs is already installed" + return 0 + fi + + # Install deploy-rs using nix profile + if nix profile install 'github:serokell/deploy-rs'; then + echo "βœ… deploy-rs installed successfully" + else + echo "❌ Failed to install deploy-rs" + return 1 + fi +} + + +# Main script +echo "πŸ”„ Self-Host Playbook Update Assistant" +echo "======================================" + +# Check if we're in the right directory +if [ ! -f "config.json" ]; then + echo "❌ Error: config.json not found. Please run this script in your self-host-playbook directory." + exit 1 +fi + +USERNAME=$(jq -r '.username' config.json) +IP_ADDRESS=$(jq -r '.ipAddress // empty' config.json) + +if [ -z "$USERNAME" ]; then + echo "❌ Error: Could not read username from config.json" + exit 1 +fi + +# If IP address is not in config.json, prompt for it +if [ -z "$IP_ADDRESS" ]; then + echo "ℹ️ No IP address found in config.json" + read -p "Enter the IP address of your server: " IP_ADDRESS + + # Validate IP address format + if ! [[ $IP_ADDRESS =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "❌ Error: Invalid IP address format" + exit 1 + fi + + # Update config.json with the new IP address + update_config_json "$IP_ADDRESS" +fi + +VERSION_FILE="version.json" +CURRENT_VERSION=$(get_current_version "$VERSION_FILE") +LATEST_VERSION=$(get_latest_version) + +echo "Current version: $CURRENT_VERSION" +echo "Latest version: $LATEST_VERSION" +echo + +if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then + echo "βœ… You are already on the latest version!" + exit 0 +fi + +if ! check_compatibility "$CURRENT_VERSION" "$LATEST_VERSION" "$VERSION_FILE"; then + exit 1 +fi + +show_changelog "$CURRENT_VERSION" "$LATEST_VERSION" "$VERSION_FILE" + +echo +read -p "Do you want to update to version $LATEST_VERSION? (y/N) " -n 1 -r +echo + +if [[ $REPLY =~ ^[Yy]$ ]]; then + # Create backup + backup_dir="backup_${CURRENT_VERSION}_$(date +%Y%m%d_%H%M%S)" + echo "πŸ“‘ Creating backup in $backup_dir..." + mkdir -p "$backup_dir" + find . -maxdepth 1 ! -name "." ! -name ".." ! -name "$backup_dir" -exec cp -r {} "$backup_dir/" \; + + + # Perform update + if perform_update "$LATEST_VERSION" "$backup_dir"; then + echo + echo "βœ… Update completed successfully!" + # Setup SSH configuration + echo + echo "πŸ”§ Setting up SSH configuration..." + setup_ssh_config "$USERNAME" "$IP_ADDRESS" + echo + install_deploy_rs + echo + echo "To apply the changes, run:" + echo "sudo nixos-rebuild switch" + echo + echo "If you encounter any issues, your backup is available in $backup_dir" + else + echo "❌ Update failed. Your backup is available in $backup_dir" + exit 1 + fi +else + echo "Update cancelled." + exit 1 +fi diff --git a/version.json b/version.json index 590ac5d..96b27fe 100644 --- a/version.json +++ b/version.json @@ -3,6 +3,12 @@ "minCompatibleVersion": "0.0.0", "updateUrl": "https://code.m3tam3re.com/m3tam3re/self-host-playbook", "changelog": { - "0.1.0": ["Management CLI", "Flake rework"] + "0.1.0": [ + "Added a management CLI for easily adding custom services.", + "Automated server updates / security patches daily.", + "Structural rework for easier upgrades.", + "Install Script Optimizations", + "Update Script" + ] } }