From 986680cc26e75217b9365935f379581b84b26007 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 2 Oct 2022 23:59:08 +0200 Subject: [PATCH 1/2] bootstrap iso: add PubSolarOS naming, drone pipeline adjustments to include a symlink to the latest iso built --- .drone.yml | 13 +++++++++-- hosts/bootstrap.nix | 48 +++++++++++++++++++++++++++++++--------- modules/core/default.nix | 9 ++++---- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7da733c4..b9718b8c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -98,7 +98,14 @@ steps: - | nix $$NIX_FLAGS build \ '.#nixosConfigurations.bootstrap.config.system.build.isoImage' - - cp $(readlink -f result)/iso/*.iso /var/nix/iso-cache/ + - cp $(readlink -f result)/iso/PubSolarOS*.iso /var/nix/iso-cache/ + - nix shell nixpkgs#findutils + - cd /var/nix/iso-cache/ + - export ISO_NAME=$(find . -name '*.iso' -printf "%f\n") + - sha256sum $ISO_NAME > $ISO_NAME.sha256 + - ln -s $ISO_NAME PubSolarOS-latest.iso + - cp $ISO_NAME.sha256 PubSolarOS-latest.iso.sha256 + - nix run nixpkgs#gnused -- --in-place "s/$ISO_NAME/PubSolarOS-latest.iso/" PubSolarOS-latest.iso.sha256 - name: "Publish ISO" image: appleboy/drone-scp @@ -117,6 +124,8 @@ steps: target: /srv/os source: - /var/nix/iso-cache/*.iso + - /var/nix/iso-cache/*.iso.sha256 + overwrite: true strip_components: 3 depends_on: @@ -134,6 +143,6 @@ volumes: --- kind: signature -hmac: 2b930bb5fe02006203b7c2fae8af75814749e8cec5f976ec0d6e64eae1b0c5db +hmac: 7b0b56a97294cd563eee2bde56abeea6dd0928e01729980a25f8c165a3f6e0f6 ... diff --git a/hosts/bootstrap.nix b/hosts/bootstrap.nix index 7772b0f1..49422675 100644 --- a/hosts/bootstrap.nix +++ b/hosts/bootstrap.nix @@ -1,4 +1,18 @@ -{ profiles, ... }: +{ config, lib, pkgs, profiles, ... }: +with lib; +let + # Gets hostname of host to be bundled inside iso + # Copied from https://github.com/divnix/digga/blob/30ffa0b02272dc56c94fd3c7d8a5a0f07ca197bf/modules/bootstrap-iso.nix#L3-L11 + getFqdn = config: + let + net = config.networking; + fqdn = + if (net ? domain) && (net.domain != null) + then "${net.hostName}.${net.domain}" + else net.hostName; + in + fqdn; +in { # build with: `nix build ".#nixosConfigurations.bootstrap.config.system.build.isoImage"` imports = [ @@ -10,16 +24,28 @@ profiles.pub-solar-iso ]; - boot.loader.systemd-boot.enable = true; + config = { + boot.loader.systemd-boot.enable = true; - # will be overridden by the bootstrapIso instrumentation - fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; + # will be overridden by the bootstrapIso instrumentation + fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "21.05"; # Did you read the comment? + system.nixos.label = "PubSolarOS-" + config.system.nixos.version; + + # mkForce because a similar transformation gets double applied otherwise + # https://github.com/divnix/digga/blob/30ffa0b02272dc56c94fd3c7d8a5a0f07ca197bf/modules/bootstrap-iso.nix#L17 + # https://github.com/NixOS/nixpkgs/blob/aecd4d8349b94f9bd5718c74a5b789f233f67326/nixos/modules/installer/cd-dvd/installation-cd-base.nix#L21-L22 + isoImage = { + isoBaseName = mkForce (getFqdn config); + isoName = mkForce "${config.system.nixos.label}-${config.isoImage.isoBaseName}-${pkgs.stdenv.hostPlatform.system}.iso"; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.05"; # Did you read the comment? + }; } diff --git a/modules/core/default.nix b/modules/core/default.nix index 9a3ea0fe..4f74b46d 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -2,7 +2,6 @@ with lib; let - psCfg = config.pub-solar; cfg = config.pub-solar.core; in { @@ -29,12 +28,12 @@ in config = { pub-solar = { - audio.enable = lib.mkIf (!cfg.lite) (lib.mkDefault true); - crypto.enable = lib.mkIf (!cfg.lite) (lib.mkDefault true); - devops.enable = lib.mkIf (!cfg.lite) (lib.mkDefault true); + audio.enable = mkIf (!cfg.lite) (mkDefault true); + crypto.enable = mkIf (!cfg.lite) (mkDefault true); + devops.enable = mkIf (!cfg.lite) (mkDefault true); terminal-life = { - enable = lib.mkDefault true; + enable = mkDefault true; lite = cfg.lite; }; }; From f2ecc2d8b9ee6b5c0cbda2f3e8b5342e714e58b6 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Mon, 3 Oct 2022 02:30:08 +0200 Subject: [PATCH 2/2] ci: fix upload target path --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index b9718b8c..5e20924e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -121,7 +121,7 @@ steps: from_secret: iso_web_ssh_port key: from_secret: iso_web_ssh_key - target: /srv/os + target: /srv/os/download source: - /var/nix/iso-cache/*.iso - /var/nix/iso-cache/*.iso.sha256 @@ -143,6 +143,6 @@ volumes: --- kind: signature -hmac: 7b0b56a97294cd563eee2bde56abeea6dd0928e01729980a25f8c165a3f6e0f6 +hmac: 8823c7103f6a075bb291a497c7ab5d5db47a91f9bc7d8ef95329b5620c9cf91d ...