From f3bfe45c818cd4532d73b03171b86f24c074ad4e Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 15 May 2025 11:57:54 +0200 Subject: [PATCH 01/13] overview: use extra- in NIX_CONFIG this is much less noisy --- overview/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overview/default.nix b/overview/default.nix index e61380516..c1d57720f 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -322,7 +322,7 @@ let
  • Enable binary substituters -
    NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/'$'\n'''trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
    +
    NIX_CONFIG='extra-substituters = https://ngi.cachix.org/'$'\n'''extra-trusted-public-keys = ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
    export NIX_CONFIG
  • From 9c1b1d62258baf825cccd1d4e8eb4e1639ceca29 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 15 May 2025 23:32:00 +0200 Subject: [PATCH 02/13] CI: move NIX_CONFIG into workflow YAML that way we can access it easily from Nix code for use in documentation --- .github/workflows/test-demo.sh | 13 ------------- .github/workflows/test-demo.yaml | 7 ++++++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-demo.sh b/.github/workflows/test-demo.sh index 27f6caf67..daad3be09 100644 --- a/.github/workflows/test-demo.sh +++ b/.github/workflows/test-demo.sh @@ -1,19 +1,7 @@ #!/usr/bin/env bash -# nix build .#overview -# podman run --privileged \ -# --volume ./result/project/Cryptpad/default.nix:/default.nix \ -# --volume .github/workflows/test-demo.sh:/test-demo.sh /bin/bash \ -# -c "bash /test-demo.sh " - set -euo pipefail -DISTRO="$1" -# shellcheck disable=SC2089,2026 -NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/'$'\n''trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw=' -export NIX_CONFIG - - echo -e "\n-> Installing Nix ..." # Debian/Ubuntu if echo "$DISTRO" | grep --quiet "debian\|ubuntu"; then @@ -48,7 +36,6 @@ else | jq --raw-output ) NIXPKGS="https://github.com/NixOS/nixpkgs/archive/$nixpkgs_revision.tar.gz" - nix-shell --include nixpkgs="$NIXPKGS" --packages nix --run "nix-build /default.nix" fi diff --git a/.github/workflows/test-demo.yaml b/.github/workflows/test-demo.yaml index 75724b771..76c77891a 100644 --- a/.github/workflows/test-demo.yaml +++ b/.github/workflows/test-demo.yaml @@ -33,10 +33,15 @@ jobs: run: nix build .#overview - name: Run and test VM + env: + DISTRO: ${{ matrix.distro }} + NIX_CONFIG: | + extra-substituters = https://ngi.cachix.org/ + extra-trusted-public-keys = ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw= run: > docker run --privileged --volume ./result/project/Cryptpad/default.nix:/default.nix --volume "$(pwd)/.github/workflows/test-demo.sh:/test-demo.sh" ${{ matrix.distro }} - /bin/bash -c "bash /test-demo.sh ${{ matrix.distro }}" + /bin/bash -c "bash /test-demo.sh" From e16a33d50fd2e0126330886bf776217c5b97a651 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 15 May 2025 23:49:05 +0200 Subject: [PATCH 03/13] use NIX_CONFIG from CI workflow --- overview/default.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/overview/default.nix b/overview/default.nix index c1d57720f..a5eef9df7 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -322,8 +322,26 @@ let
  • Enable binary substituters -
    NIX_CONFIG='extra-substituters = https://ngi.cachix.org/'$'\n'''extra-trusted-public-keys = ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
    -
    export NIX_CONFIG
    + ${ + "" # TODO(@fricklerhandwerk): add more shells + } +
    NIX_CONFIG="
    +        ${
    +          let
    +            from-yaml =
    +              file:
    +              with builtins;
    +              fromJSON (
    +                # XXX(@fricklerhandwerk): IFD, sorry. I was there, Gandalf: https://github.com/NixOS/nix/pull/7340
    +                readFile (pkgs.runCommandNoCC "yaml.json" { } "${lib.getExe pkgs.yj} < ${file} > $out")
    +              );
    +            workflow = from-yaml ../.github/workflows/test-demo.yaml;
    +          in
    +          with lib;
    +          (elemAt workflow.jobs.test.steps 3).env.NIX_CONFIG
    +          # optimising for readability; empty lines in NIX_CONFIG are ignored
    +        }"
    +        export NIX_CONFIG
  • Build and run a virtual machine From e05237a1c9b2543c2c77505c1060f42c4b9f5dfc Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 15 May 2025 23:52:49 +0200 Subject: [PATCH 04/13] export inline --- overview/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/overview/default.nix b/overview/default.nix index a5eef9df7..53aaaf3c6 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -325,7 +325,7 @@ let ${ "" # TODO(@fricklerhandwerk): add more shells } -
    NIX_CONFIG="
    +              
    export NIX_CONFIG="
             ${
               let
                 from-yaml =
    @@ -340,8 +340,7 @@ let
               with lib;
               (elemAt workflow.jobs.test.steps 3).env.NIX_CONFIG
               # optimising for readability; empty lines in NIX_CONFIG are ignored
    -        }"
    -        export NIX_CONFIG
    + }"
  • Build and run a virtual machine From d917254613825379237daecda694e2bec87638d7 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 15 May 2025 11:57:54 +0200 Subject: [PATCH 05/13] overview: use extra- in NIX_CONFIG this is much less noisy --- overview/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overview/default.nix b/overview/default.nix index a9d857219..46c07377e 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -309,7 +309,7 @@ let
  • Enable binary substituters -
    NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/'$'\n'''trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
    +
    NIX_CONFIG='extra-substituters = https://ngi.cachix.org/'$'\n'''extra-trusted-public-keys = ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
    export NIX_CONFIG
  • From b38412c77a752e4cb63a5e7d8f6e2130f278c4b5 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 15 May 2025 23:49:05 +0200 Subject: [PATCH 06/13] use NIX_CONFIG from CI workflow --- overview/default.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/overview/default.nix b/overview/default.nix index 46c07377e..e88544559 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -309,8 +309,26 @@ let
  • Enable binary substituters -
    NIX_CONFIG='extra-substituters = https://ngi.cachix.org/'$'\n'''extra-trusted-public-keys = ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
    -
    export NIX_CONFIG
    + ${ + "" # TODO(@fricklerhandwerk): add more shells + } +
    NIX_CONFIG="
    +        ${
    +          let
    +            from-yaml =
    +              file:
    +              with builtins;
    +              fromJSON (
    +                # XXX(@fricklerhandwerk): IFD, sorry. I was there, Gandalf: https://github.com/NixOS/nix/pull/7340
    +                readFile (pkgs.runCommandNoCC "yaml.json" { } "${lib.getExe pkgs.yj} < ${file} > $out")
    +              );
    +            workflow = from-yaml ../.github/workflows/test-demo.yaml;
    +          in
    +          with lib;
    +          (elemAt workflow.jobs.test.steps 3).env.NIX_CONFIG
    +          # optimising for readability; empty lines in NIX_CONFIG are ignored
    +        }"
    +        export NIX_CONFIG
  • Build and run a virtual machine From 6e30d046e2310c8d448f4cadf3db61416a63a18b Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 15 May 2025 23:52:49 +0200 Subject: [PATCH 07/13] export inline --- overview/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/overview/default.nix b/overview/default.nix index e88544559..13b6e6afe 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -312,7 +312,7 @@ let ${ "" # TODO(@fricklerhandwerk): add more shells } -
    NIX_CONFIG="
    +              
    export NIX_CONFIG="
             ${
               let
                 from-yaml =
    @@ -327,8 +327,7 @@ let
               with lib;
               (elemAt workflow.jobs.test.steps 3).env.NIX_CONFIG
               # optimising for readability; empty lines in NIX_CONFIG are ignored
    -        }"
    -        export NIX_CONFIG
    + }"
  • Build and run a virtual machine From 57fb3c02f909c91cbd9a98f1af4c0cf01d038e06 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Wed, 4 Jun 2025 18:11:23 +0200 Subject: [PATCH 08/13] shell code content types --- overview/content-types/bash-code.nix | 13 +++++++++++++ overview/content-types/shell-code.nix | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 overview/content-types/bash-code.nix create mode 100644 overview/content-types/shell-code.nix diff --git a/overview/content-types/bash-code.nix b/overview/content-types/bash-code.nix new file mode 100644 index 000000000..c852f2c9e --- /dev/null +++ b/overview/content-types/bash-code.nix @@ -0,0 +1,13 @@ +{ + name, + config, + lib, + ... +}: +let + inherit (lib) mkOption types; +in +{ + imports = [ ./shell-code.nix ]; + config.prompt = lib.mkDefault "$"; +} diff --git a/overview/content-types/shell-code.nix b/overview/content-types/shell-code.nix new file mode 100644 index 000000000..340252f6b --- /dev/null +++ b/overview/content-types/shell-code.nix @@ -0,0 +1,23 @@ +{ + name, + config, + lib, + ... +}: +let + inherit (lib) mkOption types; +in +{ + options = { + prompt = mkOption { + type = types.str; + }; + input = mkOption { + type = types.lines; + }; + output = mkOption { + type = with types; nullOr lines; + default = null; + }; + }; +} From 54aa748af09b7042f21d45a4509d845bbf7c76f4 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Wed, 4 Jun 2025 18:16:26 +0200 Subject: [PATCH 09/13] install instructions type --- .../content-types/nix-install-instruction.nix | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 overview/content-types/nix-install-instruction.nix diff --git a/overview/content-types/nix-install-instruction.nix b/overview/content-types/nix-install-instruction.nix new file mode 100644 index 000000000..5a56f1eed --- /dev/null +++ b/overview/content-types/nix-install-instruction.nix @@ -0,0 +1,24 @@ +{ + name, + config, + lib, + ... +}: +let + inherit (lib) mkOption types; +in +{ + options = { + platform = mkOption { + type = types.str; + readOnly = true; + default = name; + }; + commands = { + bash = mkOption { + type = types.submodule ./bash-code.nix; + }; + # TODO: moar shells + }; + }; +} From a2715028b51e2d443e17be533b8b524885690cf7 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Wed, 4 Jun 2025 18:37:10 +0200 Subject: [PATCH 10/13] render it --- .../content-types/nix-install-instruction.nix | 3 -- .../nix-install-platform-instructions.nix | 35 +++++++++++++++++ overview/content-types/shell-code.nix | 11 ++++++ overview/default.nix | 39 +++++++++++++++---- 4 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 overview/content-types/nix-install-platform-instructions.nix diff --git a/overview/content-types/nix-install-instruction.nix b/overview/content-types/nix-install-instruction.nix index 5a56f1eed..81347e975 100644 --- a/overview/content-types/nix-install-instruction.nix +++ b/overview/content-types/nix-install-instruction.nix @@ -1,5 +1,4 @@ { - name, config, lib, ... @@ -11,8 +10,6 @@ in options = { platform = mkOption { type = types.str; - readOnly = true; - default = name; }; commands = { bash = mkOption { diff --git a/overview/content-types/nix-install-platform-instructions.nix b/overview/content-types/nix-install-platform-instructions.nix new file mode 100644 index 000000000..d815aa95e --- /dev/null +++ b/overview/content-types/nix-install-platform-instructions.nix @@ -0,0 +1,35 @@ +{ + name, + config, + lib, + ... +}: +let + inherit (lib) mkOption types; +in +{ + options = { + instructions = mkOption { + type = with types; listOf (submodule ./nix-install-instruction.nix); + }; + __toString = mkOption { + type = with types; functionTo str; + readOnly = true; + default = self: '' + Install Nix +
      + ${ + lib.concatMapStringsSep "\n" (i: '' +
    • +
      ${i.platform}
      +
      + ${i.commands.bash} +
      +
    • + '') self.instructions + } +
    + ''; + }; + }; +} diff --git a/overview/content-types/shell-code.nix b/overview/content-types/shell-code.nix index 340252f6b..d539ad746 100644 --- a/overview/content-types/shell-code.nix +++ b/overview/content-types/shell-code.nix @@ -19,5 +19,16 @@ in type = with types; nullOr lines; default = null; }; + __toString = mkOption { + type = with types; functionTo str; + readOnly = true; + default = + self: with lib; '' +
    ${trim ''
    +            ${self.prompt} ${self.input}
    +            ${optionalString (!isNull self.output) self.output}
    +          ''}
    + ''; + }; }; } diff --git a/overview/default.nix b/overview/default.nix index 869a410e2..76376bd67 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -268,18 +268,41 @@ let openPorts = demoSystem.config.networking.firewall.allowedTCPPorts; # The port that is forwarded to the host so that the user can access the demo service. servicePort = (builtins.head openPorts); + installation-instructions = eval { + imports = [ ./content-types/nix-install-platform-instructions.nix ]; + instructions = [ + { + platform = "Arch Linux"; + commands.bash = { + input = '' + pacman --sync --refresh --noconfirm curl git jq nix + ''; + }; + } + { + platform = "Debian"; + commands.bash = { + input = '' + apt install --yes curl git jq nix + ''; + }; + } + { + platform = "Ubuntu"; + commands.bash = { + input = '' + apt install --yes curl git jq nix + ''; + }; + } + ]; + }; in '' ${heading 2 "demo" "Try the service in a VM"}
    1. - Install Nix -
        -
      • Arch Linux
      • -
        pacman --sync --refresh --noconfirm curl git jq nix
        -
      • Debian/Ubuntu
      • -
        apt install --yes curl git jq nix
        -
      + ${installation-instructions}
    2. Download a configuration file @@ -349,7 +372,7 @@ let content = index; summary = '' NGIpkgs is collection of software applications funded by the Next - Generation Internet initiative and packaged for NixOS. + Generation Internet initiative and packaged for NixOS. ''; }; From 0fc5964262eee3423c1ef6121c67d13c7610f9f3 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Wed, 4 Jun 2025 18:48:06 +0200 Subject: [PATCH 11/13] fix presentation --- .../nix-install-platform-instructions.nix | 18 +++-- overview/content-types/shell-code.nix | 2 +- overview/default.nix | 66 +++++++++---------- overview/render-template.py | 2 +- overview/style.css | 6 ++ 5 files changed, 49 insertions(+), 45 deletions(-) diff --git a/overview/content-types/nix-install-platform-instructions.nix b/overview/content-types/nix-install-platform-instructions.nix index d815aa95e..063569fe8 100644 --- a/overview/content-types/nix-install-platform-instructions.nix +++ b/overview/content-types/nix-install-platform-instructions.nix @@ -18,16 +18,14 @@ in default = self: '' Install Nix
        - ${ - lib.concatMapStringsSep "\n" (i: '' -
      • -
        ${i.platform}
        -
        - ${i.commands.bash} -
        -
      • - '') self.instructions - } + ${lib.concatMapStringsSep "\n" (i: '' +
      • +
        ${i.platform}
        +
        + ${i.commands.bash} +
        +
      • + '') self.instructions}
      ''; }; diff --git a/overview/content-types/shell-code.nix b/overview/content-types/shell-code.nix index d539ad746..ad39fa73b 100644 --- a/overview/content-types/shell-code.nix +++ b/overview/content-types/shell-code.nix @@ -24,7 +24,7 @@ in readOnly = true; default = self: with lib; '' -
      ${trim ''
      +          
      ${trim ''
                   ${self.prompt} ${self.input}
                   ${optionalString (!isNull self.output) self.output}
                 ''}
      diff --git a/overview/default.nix b/overview/default.nix index 76376bd67..0ad4766cb 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -299,39 +299,39 @@ let }; in '' - ${heading 2 "demo" "Try the service in a VM"} -
        -
      1. - ${installation-instructions} -
      2. -
      3. - Download a configuration file - ${render.codeSnippet.one { - filename = "default.nix"; - relative = true; - downloadable = true; - }} -
      4. -
      5. - Enable binary substituters -
        NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/'$'\n'''trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
        -
        export NIX_CONFIG
        -
      6. -
      7. - Build and run a virtual machine -
          -
        • Arch Linux, Debian Sid and Ubuntu 25.04
        • -
          nix-build ./default.nix && ./result
          -
        • Debian 12 and Ubuntu 24.04/24.10
        • -
          rev=$(nix-instantiate --eval --attr sources.nixpkgs.rev https://github.com/ngi-nix/ngipkgs/archive/master.tar.gz | jq --raw-output)
          -
          nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/$rev.tar.gz --packages nix --run "nix-build ./default.nix && ./result"
          -
        -
      8. -
      9. - Access the service
        - Open a web browser at http://localhost:${toString servicePort} . -
      10. -
      + ${heading 2 "demo" "Try the service in a VM"} +
        +
      1. + ${installation-instructions} +
      2. +
      3. + Download a configuration file + ${render.codeSnippet.one { + filename = "default.nix"; + relative = true; + downloadable = true; + }} +
      4. +
      5. + Enable binary substituters +
        NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/'$'\n'''trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
        +        export NIX_CONFIG
        +
      6. +
      7. + Build and run a virtual machine +
          +
        • Arch Linux, Debian Sid and Ubuntu 25.04
        • +
          nix-build ./default.nix && ./result
          +
        • Debian 12 and Ubuntu 24.04/24.10
        • +
          rev=$(nix-instantiate --eval --attr sources.nixpkgs.rev https://github.com/ngi-nix/ngipkgs/archive/master.tar.gz | jq --raw-output)
          +        nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/$rev.tar.gz --packages nix --run "nix-build ./default.nix && ./result"
          +
        +
      8. +
      9. + Access the service
        + Open a web browser at http://localhost:${toString servicePort} . +
      10. +
      ''; }; diff --git a/overview/render-template.py b/overview/render-template.py index 56b11154d..84793f366 100644 --- a/overview/render-template.py +++ b/overview/render-template.py @@ -22,7 +22,7 @@ def include_code(language, file_path, relative_path=False): return highlight(code, lexer, formatter) except Exception: print("Fallback: Return the code without highlighting") - return f'
      {code}
      ' + return f'
      {code}
      ' md = MarkdownIt("commonmark") diff --git a/overview/style.css b/overview/style.css index 3854f865d..836133f1c 100644 --- a/overview/style.css +++ b/overview/style.css @@ -286,6 +286,12 @@ code, pre { overflow-x: auto; } +pre.shell, +div.code > pre /* for pygments output */ +{ + padding: 0.5em; +} + .code-block { position: relative; } From 562e0c05bc85dcb4a9faf52d73272bc5d07102e6 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Mon, 9 Jun 2025 18:14:39 +0200 Subject: [PATCH 12/13] refactor for sanity --- overview/content-types/commands.nix | 64 +++++++++++++++++++ .../content-types/nix-install-instruction.nix | 21 ------ .../nix-install-platform-instructions.nix | 33 ---------- overview/default.nix | 38 +++++------ 4 files changed, 83 insertions(+), 73 deletions(-) create mode 100644 overview/content-types/commands.nix delete mode 100644 overview/content-types/nix-install-instruction.nix delete mode 100644 overview/content-types/nix-install-platform-instructions.nix diff --git a/overview/content-types/commands.nix b/overview/content-types/commands.nix new file mode 100644 index 000000000..d9c2cd5ba --- /dev/null +++ b/overview/content-types/commands.nix @@ -0,0 +1,64 @@ +{ + name, + config, + lib, + ... +}: +let + inherit (lib) mkOption types; + commands = { + bash = mkOption { + type = types.submodule ./bash-code.nix; + }; + # TODO: moar shells + }; +in +{ + options = { + instructions = mkOption { + type = + with types; + either + # cross-platform + (submodule { + options = { + inherit commands; + }; + }) + # platform-specific + ( + listOf (submodule { + options = { + platform = mkOption { + type = types.str; + }; + inherit commands; + }; + }) + ); + }; + __toString = mkOption { + type = with types; functionTo str; + readOnly = true; + default = + self: + if lib.isList self.instructions then + '' +
        + ${lib.concatMapStringsSep "\n" (i: '' +
      • +
        ${i.platform}
        +
        + ${i.commands.bash} +
        +
      • + '') self.instructions} +
      + '' + else + '' + ${self.instructions.commands.bash} + ''; + }; + }; +} diff --git a/overview/content-types/nix-install-instruction.nix b/overview/content-types/nix-install-instruction.nix deleted file mode 100644 index 81347e975..000000000 --- a/overview/content-types/nix-install-instruction.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - config, - lib, - ... -}: -let - inherit (lib) mkOption types; -in -{ - options = { - platform = mkOption { - type = types.str; - }; - commands = { - bash = mkOption { - type = types.submodule ./bash-code.nix; - }; - # TODO: moar shells - }; - }; -} diff --git a/overview/content-types/nix-install-platform-instructions.nix b/overview/content-types/nix-install-platform-instructions.nix deleted file mode 100644 index 063569fe8..000000000 --- a/overview/content-types/nix-install-platform-instructions.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - name, - config, - lib, - ... -}: -let - inherit (lib) mkOption types; -in -{ - options = { - instructions = mkOption { - type = with types; listOf (submodule ./nix-install-instruction.nix); - }; - __toString = mkOption { - type = with types; functionTo str; - readOnly = true; - default = self: '' - Install Nix -
        - ${lib.concatMapStringsSep "\n" (i: '' -
      • -
        ${i.platform}
        -
        - ${i.commands.bash} -
        -
      • - '') self.instructions} -
      - ''; - }; - }; -} diff --git a/overview/default.nix b/overview/default.nix index 76191057f..d7ee0eed8 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -278,31 +278,25 @@ let # The port that is forwarded to the host so that the user can access the demo service. servicePort = if openPorts != [ ] then (builtins.head openPorts) else ""; installation-instructions = eval { - imports = [ ./content-types/nix-install-platform-instructions.nix ]; + imports = [ ./content-types/commands.nix ]; instructions = [ { platform = "Arch Linux"; - commands.bash = { - input = '' - pacman --sync --refresh --noconfirm curl git jq nix - ''; - }; + commands.bash.input = '' + pacman --sync --refresh --noconfirm curl git jq nix + ''; } { platform = "Debian"; - commands.bash = { - input = '' - apt install --yes curl git jq nix - ''; - }; + commands.bash.input = '' + apt install --yes curl git jq nix + ''; } { platform = "Ubuntu"; - commands.bash = { - input = '' - apt install --yes curl git jq nix - ''; - }; + commands.bash.input = '' + apt install --yes curl git jq nix + ''; } ]; }; @@ -325,6 +319,12 @@ let } ]; }; + set-nix-config = eval { + imports = [ ./content-types/commands.nix ]; + instructions.commands.bash.input = '' + export ${nix-config} + ''; + }; in '' ${heading 2 "demo" ( @@ -333,7 +333,8 @@ let
      1. - ${installation-instructions} + Install Nix + ${installation-instructions}
      2. Download a configuration file @@ -345,8 +346,7 @@ let
      3. Enable binary substituters -
        ${nix-config}
        -
        export NIX_CONFIG
        + ${set-nix-config}
      4. Build and run a virtual machine From 7fc729d667d3647634f6890e3b022ffd7768773a Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Mon, 9 Jun 2025 18:41:35 +0200 Subject: [PATCH 13/13] use shell command rendering code --- overview/content-types/config-item.nix | 20 ------------------ overview/content-types/nix-config.nix | 29 -------------------------- overview/default.nix | 2 +- 3 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 overview/content-types/config-item.nix delete mode 100644 overview/content-types/nix-config.nix diff --git a/overview/content-types/config-item.nix b/overview/content-types/config-item.nix deleted file mode 100644 index bd05b68a7..000000000 --- a/overview/content-types/config-item.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - name, - config, - lib, - ... -}: -let - inherit (lib) mkOption types; -in -{ - options = { - name = mkOption { - type = types.str; - default = name; - }; - value = mkOption { - type = with types; either str (listOf str); - }; - }; -} diff --git a/overview/content-types/nix-config.nix b/overview/content-types/nix-config.nix deleted file mode 100644 index 726d1126c..000000000 --- a/overview/content-types/nix-config.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ - name, - config, - lib, - ... -}: -let - inherit (lib) mkOption types; -in -{ - options = { - __toString = mkOption { - type = with types; functionTo str; - readOnly = true; - default = - self: - let - separator = "'$'\\n''"; - concatSettings = lib.concatStringsSep separator ( - lib.map (attrs: "${attrs.name} = ${toString attrs.value}") self.settings - ); - in - "NIX_CONFIG='${concatSettings}'"; - }; - settings = mkOption { - type = with types; listOf (submodule ./config-item.nix); - }; - }; -} diff --git a/overview/default.nix b/overview/default.nix index 12bc4b52b..3b6d20f7d 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -310,7 +310,7 @@ let readFile (pkgs.runCommandNoCC "yaml.json" { } "${lib.getExe pkgs.yj} < ${file} > $out") ); workflow = from-yaml ../.github/workflows/test-demo.yaml; - nix-config = with lib; (elemAt workflow.jobs.test.steps 3).env.NIX_CONFIG; + nix-config = with lib; trim (elemAt workflow.jobs.test.steps 3).env.NIX_CONFIG; in eval { imports = [ ./content-types/commands.nix ];