lol

specialisation: replace nesting with named configurations

Co-authored-by: worldofpeace <worldofpeace@protonmail.ch>

+230 -189
+1 -1
nixos/doc/manual/installation/installing-behind-a-proxy.xml
··· 40 40 <note> 41 41 <para> 42 42 If you are switching networks with different proxy configurations, use the 43 - <literal>nesting.clone</literal> option in 43 + <literal>specialisation</literal> option in 44 44 <literal>configuration.nix</literal> to switch proxies at runtime. Refer to 45 45 <xref linkend="ch-options" /> for more information. 46 46 </para>
+44
nixos/doc/manual/release-notes/rl-2009.xml
··· 203 203 <link xlink:href="https://github.com/gollum/gollum/wiki/5.0-release-notes#migrating-your-wiki">here</link>. 204 204 </para> 205 205 </listitem> 206 + 207 + <listitem> 208 + <para> 209 + The NixOS options <literal>nesting.clone</literal> and 210 + <literal>nesting.children</literal> have been deleted, and 211 + replaced with named <xref linkend="opt-specialisation"/> 212 + configurations. 213 + </para> 214 + 215 + <para> 216 + Replace a <literal>nesting.clone</literal> entry with: 217 + 218 + <programlisting>{ 219 + <link xlink:href="#opt-specialisation">specialisation.example-sub-configuration</link> = { 220 + <link xlink:href="#opt-specialisation._name_.configuration">configuration</link> = { 221 + ... 222 + }; 223 + };</programlisting> 224 + 225 + </para> 226 + <para> 227 + Replace a <literal>nesting.children</literal> entry with: 228 + 229 + <programlisting>{ 230 + <link xlink:href="#opt-specialisation">specialisation.example-sub-configuration</link> = { 231 + <link xlink:href="#opt-specialisation._name_.inheritParentConfig">inheritParentConfig</link> = false; 232 + <link xlink:href="#opt-specialisation._name_.configuration">configuration</link> = { 233 + ... 234 + }; 235 + };</programlisting> 236 + </para> 237 + 238 + <para> 239 + To switch to a specialised configuration at runtime you need to 240 + run: 241 + <programlisting> 242 + # sudo /run/current-system/specialisation/example-sub-configuration/bin/switch-to-configuration test 243 + </programlisting> 244 + Before you would have used: 245 + <programlisting> 246 + # sudo /run/current-system/fine-tune/child-1/bin/switch-to-configuration test 247 + </programlisting> 248 + </para> 249 + </listitem> 206 250 </itemizedlist> 207 251 </section> 208 252
+1 -2
nixos/modules/system/activation/no-clone.nix
··· 4 4 5 5 { 6 6 boot.loader.grub.device = mkOverride 0 "nodev"; 7 - nesting.children = mkOverride 0 []; 8 - nesting.clone = mkOverride 0 []; 7 + specialisation = mkOverride 0 {}; 9 8 }
+35 -30
nixos/modules/system/activation/top-level.nix
··· 11 11 # you can provide an easy way to boot the same configuration 12 12 # as you use, but with another kernel 13 13 # !!! fix this 14 - cloner = inheritParent: list: 15 - map (childConfig: 14 + children = mapAttrs (childName: childConfig: 16 15 (import ../../../lib/eval-config.nix { 17 16 inherit baseModules; 18 17 system = config.nixpkgs.initialSystem; 19 18 modules = 20 - (optionals inheritParent modules) 19 + (optionals childConfig.inheritParentConfig modules) 21 20 ++ [ ./no-clone.nix ] 22 - ++ [ childConfig ]; 21 + ++ [ childConfig.configuration ]; 23 22 }).config.system.build.toplevel 24 - ) list; 25 - 26 - children = 27 - cloner false config.nesting.children 28 - ++ cloner true config.nesting.clone; 23 + ) config.specialisation; 29 24 30 25 systemBuilder = 31 26 let ··· 77 72 echo -n "$nixosLabel" > $out/nixos-version 78 73 echo -n "${config.boot.kernelPackages.stdenv.hostPlatform.system}" > $out/system 79 74 80 - mkdir $out/fine-tune 81 - childCount=0 82 - for i in $children; do 83 - childCount=$(( childCount + 1 )) 84 - ln -s $i $out/fine-tune/child-$childCount 85 - done 75 + mkdir $out/specialisation 76 + ${concatStringsSep "\n" 77 + (mapAttrsToList (name: path: "ln -s ${path} $out/specialisation/${name}") children)} 86 78 87 79 mkdir $out/bin 88 80 export localeArchive="${config.i18n.glibcLocales}/lib/locale/locale-archive" ··· 112 104 shell = "${pkgs.bash}/bin/sh"; 113 105 su = "${pkgs.shadow.su}/bin/su"; 114 106 115 - inherit children; 116 107 kernelParams = config.boot.kernelParams; 117 108 installBootLoader = 118 109 config.system.build.installBootLoader ··· 143 134 in 144 135 145 136 { 137 + imports = [ 138 + (mkRemovedOptionModule [ "nesting" "clone" ] "Use `specialisation.«name» = { inheritParentConfig = true; configuration = { ... }; }` instead.") 139 + (mkRemovedOptionModule [ "nesting" "children" ] "Use `specialisation.«name».configuration = { ... }` instead.") 140 + ]; 141 + 146 142 options = { 147 143 148 144 system.build = mkOption { ··· 154 150 ''; 155 151 }; 156 152 157 - nesting.children = mkOption { 158 - default = []; 153 + specialisation = mkOption { 154 + default = {}; 155 + example = lib.literalExample "{ fewJobsManyCores.configuration = { nix.buildCores = 0; nix.maxJobs = 1; }; }"; 159 156 description = '' 160 - Additional configurations to build. 161 - ''; 162 - }; 163 - 164 - nesting.clone = mkOption { 165 - default = []; 166 - description = '' 167 - Additional configurations to build based on the current 168 - configuration which then has a lower priority. 157 + Additional configurations to build. If 158 + <literal>inheritParentConfig</literal> is true, the system 159 + will be based on the overall system configuration. 169 160 170 - To switch to a cloned configuration (e.g. <literal>child-1</literal>) 171 - at runtime, run 161 + To switch to a specialised configuration 162 + (e.g. <literal>fewJobsManyCores</literal>) at runtime, run: 172 163 173 164 <programlisting> 174 - # sudo /run/current-system/fine-tune/child-1/bin/switch-to-configuration test 165 + # sudo /run/current-system/specialisation/fewJobsManyCores/bin/switch-to-configuration test 175 166 </programlisting> 176 167 ''; 168 + type = types.attrsOf (types.submodule ( 169 + { ... }: { 170 + options.inheritParentConfig = mkOption { 171 + type = types.bool; 172 + default = true; 173 + description = "Include the entire system's configuration. Set to false to make a completely differently configured system."; 174 + }; 175 + 176 + options.configuration = mkOption { 177 + default = {}; 178 + description = "Arbitrary NixOS configuration options."; 179 + }; 180 + }) 181 + ); 177 182 }; 178 183 179 184 system.boot.loader.id = mkOption {
+3 -2
nixos/modules/system/boot/loader/grub/install-grub.pl
··· 409 409 410 410 # Find all the children of the current default configuration 411 411 # Do not search for grand children 412 - my @links = sort (glob "$defaultConfig/fine-tune/*"); 412 + my @links = sort (glob "$defaultConfig/specialisation/*"); 413 413 foreach my $link (@links) { 414 414 415 415 my $entryName = ""; ··· 425 425 if ($cfgName) { 426 426 $entryName = $cfgName; 427 427 } else { 428 - $entryName = "($date - $version)"; 428 + my $linkname = basename($link); 429 + $entryName = "($linkname - $date - $version)"; 429 430 } 430 431 addEntry("NixOS - $entryName", $link); 431 432 }
+1 -1
nixos/modules/system/boot/loader/init-script/init-script-builder.sh
··· 69 69 70 70 # Add all generations of the system profile to the menu, in reverse 71 71 # (most recent to least recent) order. 72 - for link in $((ls -d $defaultConfig/fine-tune/* ) | sort -n); do 72 + for link in $((ls -d $defaultConfig/specialisation/* ) | sort -n); do 73 73 date=$(stat --printf="%y\n" $link | sed 's/\..*//') 74 74 addEntry "NixOS - variation" $link "" 75 75 done
+46 -48
nixos/tests/acme.nix
··· 91 91 92 92 security.acme.server = "https://acme-v02.api.letsencrypt.org/dir"; 93 93 94 - nesting.clone = [ 95 - ({pkgs, ...}: { 96 - systemd.targets."acme-finished-b.example.com" = {}; 97 - systemd.services."acme-b.example.com" = { 98 - wants = [ "acme-finished-b.example.com.target" ]; 99 - before = [ "acme-finished-b.example.com.target" ]; 100 - after = [ "nginx.service" ]; 101 - }; 102 - services.nginx.virtualHosts."b.example.com" = { 103 - enableACME = true; 104 - forceSSL = true; 105 - locations."/".root = pkgs.runCommand "docroot" {} '' 106 - mkdir -p "$out" 107 - echo hello world > "$out/index.html" 108 - ''; 109 - }; 110 - }) 111 - ({pkgs, config, nodes, lib, ...}: { 112 - security.acme.certs."example.com" = { 113 - domain = "*.example.com"; 114 - dnsProvider = "exec"; 115 - dnsPropagationCheck = false; 116 - credentialsFile = with pkgs; writeText "wildcard.env" '' 117 - EXEC_PATH=${dnsScript { inherit writeScript bash curl; dnsAddress = nodes.dnsserver.config.networking.primaryIPAddress; }} 118 - ''; 119 - user = config.services.nginx.user; 120 - group = config.services.nginx.group; 121 - }; 122 - systemd.targets."acme-finished-example.com" = {}; 123 - systemd.services."acme-example.com" = { 124 - wants = [ "acme-finished-example.com.target" ]; 125 - before = [ "acme-finished-example.com.target" "nginx.service" ]; 126 - wantedBy = [ "nginx.service" ]; 127 - }; 128 - services.nginx.virtualHosts."c.example.com" = { 129 - forceSSL = true; 130 - sslCertificate = config.security.acme.certs."example.com".directory + "/cert.pem"; 131 - sslTrustedCertificate = config.security.acme.certs."example.com".directory + "/full.pem"; 132 - sslCertificateKey = config.security.acme.certs."example.com".directory + "/key.pem"; 133 - locations."/".root = pkgs.runCommand "docroot" {} '' 134 - mkdir -p "$out" 135 - echo hello world > "$out/index.html" 136 - ''; 137 - }; 138 - }) 139 - ]; 94 + specialisation.second-cert.configuration = {pkgs, ...}: { 95 + systemd.targets."acme-finished-b.example.com" = {}; 96 + systemd.services."acme-b.example.com" = { 97 + wants = [ "acme-finished-b.example.com.target" ]; 98 + before = [ "acme-finished-b.example.com.target" ]; 99 + after = [ "nginx.service" ]; 100 + }; 101 + services.nginx.virtualHosts."b.example.com" = { 102 + enableACME = true; 103 + forceSSL = true; 104 + locations."/".root = pkgs.runCommand "docroot" {} '' 105 + mkdir -p "$out" 106 + echo hello world > "$out/index.html" 107 + ''; 108 + }; 109 + }; 110 + specialisation.dns-01.configuration = {pkgs, config, nodes, lib, ...}: { 111 + security.acme.certs."example.com" = { 112 + domain = "*.example.com"; 113 + dnsProvider = "exec"; 114 + dnsPropagationCheck = false; 115 + credentialsFile = with pkgs; writeText "wildcard.env" '' 116 + EXEC_PATH=${dnsScript { inherit writeScript bash curl; dnsAddress = nodes.dnsserver.config.networking.primaryIPAddress; }} 117 + ''; 118 + user = config.services.nginx.user; 119 + group = config.services.nginx.group; 120 + }; 121 + systemd.targets."acme-finished-example.com" = {}; 122 + systemd.services."acme-example.com" = { 123 + wants = [ "acme-finished-example.com.target" ]; 124 + before = [ "acme-finished-example.com.target" "nginx.service" ]; 125 + wantedBy = [ "nginx.service" ]; 126 + }; 127 + services.nginx.virtualHosts."c.example.com" = { 128 + forceSSL = true; 129 + sslCertificate = config.security.acme.certs."example.com".directory + "/cert.pem"; 130 + sslTrustedCertificate = config.security.acme.certs."example.com".directory + "/full.pem"; 131 + sslCertificateKey = config.security.acme.certs."example.com".directory + "/key.pem"; 132 + locations."/".root = pkgs.runCommand "docroot" {} '' 133 + mkdir -p "$out" 134 + echo hello world > "$out/index.html" 135 + ''; 136 + }; 137 + }; 140 138 }; 141 139 142 140 client = {nodes, lib, ...}: { ··· 196 194 197 195 with subtest("Can add another certificate for nginx service"): 198 196 webserver.succeed( 199 - "/run/current-system/fine-tune/child-1/bin/switch-to-configuration test" 197 + "/run/current-system/specialisation/second-cert/bin/switch-to-configuration test" 200 198 ) 201 199 webserver.wait_for_unit("acme-finished-b.example.com.target") 202 200 client.succeed( ··· 208 206 "${switchToNewServer}" 209 207 ) 210 208 webserver.succeed( 211 - "/run/current-system/fine-tune/child-2/bin/switch-to-configuration test" 209 + "/run/current-system/specialisation/dns-01/bin/switch-to-configuration test" 212 210 ) 213 211 webserver.wait_for_unit("acme-finished-example.com.target") 214 212 client.succeed(
+1 -1
nixos/tests/all-tests.nix
··· 202 202 nat.standalone = handleTest ./nat.nix { withFirewall = false; }; 203 203 ndppd = handleTest ./ndppd.nix {}; 204 204 neo4j = handleTest ./neo4j.nix {}; 205 - nesting = handleTest ./nesting.nix {}; 205 + specialisation = handleTest ./specialisation.nix {}; 206 206 netdata = handleTest ./netdata.nix {}; 207 207 networking.networkd = handleTest ./networking.nix { networkd = true; }; 208 208 networking.scripted = handleTest ./networking.nix { networkd = false; };
+21 -23
nixos/tests/caddy.nix
··· 20 20 } 21 21 ''; 22 22 23 - nesting.clone = [ 24 - { 25 - services.caddy.config = lib.mkForce '' 26 - http://localhost { 27 - gzip 23 + specialisation.etag.configuration = { 24 + services.caddy.config = lib.mkForce '' 25 + http://localhost { 26 + gzip 28 27 29 - root ${ 30 - pkgs.runCommand "testdir2" {} '' 31 - mkdir "$out" 32 - echo changed > "$out/example.html" 33 - '' 34 - } 28 + root ${ 29 + pkgs.runCommand "testdir2" {} '' 30 + mkdir "$out" 31 + echo changed > "$out/example.html" 32 + '' 35 33 } 36 - ''; 37 - } 34 + } 35 + ''; 36 + }; 38 37 39 - { 40 - services.caddy.config = '' 41 - http://localhost:8080 { 42 - } 43 - ''; 44 - } 45 - ]; 38 + specialisation.config-reload.configuration = { 39 + services.caddy.config = '' 40 + http://localhost:8080 { 41 + } 42 + ''; 43 + }; 46 44 }; 47 45 }; 48 46 49 47 testScript = { nodes, ... }: let 50 - etagSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-1"; 51 - justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-2"; 48 + etagSystem = "${nodes.webserver.config.system.build.toplevel}/specialisation/etag"; 49 + justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/specialisation/config-reload"; 52 50 in '' 53 51 url = "http://localhost/example.html" 54 52 webserver.wait_for_unit("caddy") ··· 77 75 assert old_etag != new_etag, "Old ETag {} is the same as {}".format( 78 76 old_etag, new_etag 79 77 ) 80 - 78 + 81 79 with subtest("config is reloaded on nixos-rebuild switch"): 82 80 webserver.succeed( 83 81 "${justReloadSystem}/bin/switch-to-configuration test >&2"
+10 -10
nixos/tests/installer.nix
··· 65 65 # partitions and filesystems. 66 66 testScriptFun = { bootLoader, createPartitions, grubVersion, grubDevice, grubUseEfi 67 67 , grubIdentifier, preBootCommands, extraConfig 68 - , testCloneConfig 68 + , testSpecialisationConfig 69 69 }: 70 70 let iface = if grubVersion == 1 then "ide" else "virtio"; 71 71 isEfi = bootLoader == "systemd-boot" || (bootLoader == "grub" && grubUseEfi); ··· 220 220 221 221 # Tests for validating clone configuration entries in grub menu 222 222 '' 223 - + optionalString testCloneConfig '' 223 + + optionalString testSpecialisationConfig '' 224 224 # Reboot Machine 225 225 machine = create_machine_named("clone-default-config") 226 226 ${preBootCommands} ··· 262 262 , bootLoader ? "grub" # either "grub" or "systemd-boot" 263 263 , grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid", grubUseEfi ? false 264 264 , enableOCR ? false, meta ? {} 265 - , testCloneConfig ? false 265 + , testSpecialisationConfig ? false 266 266 }: 267 267 makeTest { 268 268 inherit enableOCR; ··· 337 337 testScript = testScriptFun { 338 338 inherit bootLoader createPartitions preBootCommands 339 339 grubVersion grubDevice grubIdentifier grubUseEfi extraConfig 340 - testCloneConfig; 340 + testSpecialisationConfig; 341 341 }; 342 342 }; 343 343 ··· 411 411 grubUseEfi = true; 412 412 }; 413 413 414 - clone-test-extraconfig = { 414 + specialisation-test-extraconfig = { 415 415 extraConfig = '' 416 416 environment.systemPackages = [ pkgs.grub2 ]; 417 417 boot.loader.grub.configurationName = "Home"; 418 - nesting.clone = [ { 418 + specialisation.work.configuration = { 419 419 boot.loader.grub.configurationName = lib.mkForce "Work"; 420 420 421 421 environment.etc = { ··· 424 424 gitproxy = none for work.com 425 425 "; 426 426 }; 427 - } ]; 427 + }; 428 428 ''; 429 - testCloneConfig = true; 429 + testSpecialisationConfig = true; 430 430 }; 431 431 432 432 ··· 440 440 simple = makeInstallerTest "simple" simple-test-config; 441 441 442 442 # Test cloned configurations with the simple grub configuration 443 - simpleClone = makeInstallerTest "simpleClone" (simple-test-config // clone-test-extraconfig); 443 + simpleSpecialised = makeInstallerTest "simpleSpecialised" (simple-test-config // specialisation-test-extraconfig); 444 444 445 445 # Simple GPT/UEFI configuration using systemd-boot with 3 partitions: ESP, swap & root filesystem 446 446 simpleUefiSystemdBoot = makeInstallerTest "simpleUefiSystemdBoot" { ··· 467 467 simpleUefiGrub = makeInstallerTest "simpleUefiGrub" simple-uefi-grub-config; 468 468 469 469 # Test cloned configurations with the uefi grub configuration 470 - simpleUefiGrubClone = makeInstallerTest "simpleUefiGrubClone" (simple-uefi-grub-config // clone-test-extraconfig); 470 + simpleUefiGrubSpecialisation = makeInstallerTest "simpleUefiGrubSpecialisation" (simple-uefi-grub-config // specialisation-test-extraconfig); 471 471 472 472 # Same as the previous, but now with a separate /boot partition. 473 473 separateBoot = makeInstallerTest "separateBoot" {
-44
nixos/tests/nesting.nix
··· 1 - import ./make-test-python.nix { 2 - name = "nesting"; 3 - nodes = { 4 - clone = { pkgs, ... }: { 5 - environment.systemPackages = [ pkgs.cowsay ]; 6 - nesting.clone = [ 7 - ({ pkgs, ... }: { 8 - environment.systemPackages = [ pkgs.hello ]; 9 - }) 10 - ]; 11 - }; 12 - children = { pkgs, ... }: { 13 - environment.systemPackages = [ pkgs.cowsay ]; 14 - nesting.children = [ 15 - ({ pkgs, ... }: { 16 - environment.systemPackages = [ pkgs.hello ]; 17 - }) 18 - ]; 19 - }; 20 - }; 21 - testScript = '' 22 - clone.wait_for_unit("default.target") 23 - clone.succeed("cowsay hey") 24 - clone.fail("hello") 25 - 26 - with subtest("Nested clones do inherit from parent"): 27 - clone.succeed( 28 - "/run/current-system/fine-tune/child-1/bin/switch-to-configuration test" 29 - ) 30 - clone.succeed("cowsay hey") 31 - clone.succeed("hello") 32 - 33 - children.wait_for_unit("default.target") 34 - children.succeed("cowsay hey") 35 - children.fail("hello") 36 - 37 - with subtest("Nested children do not inherit from parent"): 38 - children.succeed( 39 - "/run/current-system/fine-tune/child-1/bin/switch-to-configuration test" 40 - ) 41 - children.fail("cowsay hey") 42 - children.succeed("hello") 43 - ''; 44 - }
+2 -2
nixos/tests/nginx-etag.nix
··· 19 19 ''; 20 20 }; 21 21 22 - nesting.clone = lib.singleton { 22 + specialisation.pass-checks.configuration = { 23 23 services.nginx.virtualHosts.server = { 24 24 root = lib.mkForce (pkgs.runCommandLocal "testdir2" {} '' 25 25 mkdir "$out" ··· 70 70 71 71 testScript = { nodes, ... }: let 72 72 inherit (nodes.server.config.system.build) toplevel; 73 - newSystem = "${toplevel}/fine-tune/child-1"; 73 + newSystem = "${toplevel}/specialisation/pass-checks"; 74 74 in '' 75 75 start_all() 76 76
+22 -25
nixos/tests/nginx.nix
··· 42 42 43 43 services.nginx.enableReload = true; 44 44 45 - nesting.clone = [ 46 - { 47 - services.nginx.virtualHosts.localhost = { 48 - root = lib.mkForce (pkgs.runCommand "testdir2" {} '' 49 - mkdir "$out" 50 - echo content changed > "$out/index.html" 51 - ''); 52 - }; 53 - } 45 + specialisation.etagSystem.configuration = { 46 + services.nginx.virtualHosts.localhost = { 47 + root = lib.mkForce (pkgs.runCommand "testdir2" {} '' 48 + mkdir "$out" 49 + echo content changed > "$out/index.html" 50 + ''); 51 + }; 52 + }; 54 53 55 - { 56 - services.nginx.virtualHosts."1.my.test".listen = [ { addr = "127.0.0.1"; port = 8080; }]; 57 - } 54 + specialisation.justReloadSystem.configuration = { 55 + services.nginx.virtualHosts."1.my.test".listen = [ { addr = "127.0.0.1"; port = 8080; }]; 56 + }; 58 57 59 - { 60 - services.nginx.package = pkgs.nginxUnstable; 61 - } 58 + specialisation.reloadRestartSystem.configuration = { 59 + services.nginx.package = pkgs.nginxUnstable; 60 + }; 62 61 63 - { 64 - services.nginx.package = pkgs.nginxUnstable; 65 - services.nginx.virtualHosts."!@$$(#*%".locations."~@#*$*!)".proxyPass = ";;;"; 66 - } 67 - ]; 62 + specialisation.reloadWithErrorsSystem.configuration = { 63 + services.nginx.package = pkgs.nginxUnstable; 64 + services.nginx.virtualHosts."!@$$(#*%".locations."~@#*$*!)".proxyPass = ";;;"; 65 + }; 68 66 }; 69 - 70 67 }; 71 68 72 69 testScript = { nodes, ... }: let 73 - etagSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-1"; 74 - justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-2"; 75 - reloadRestartSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-3"; 76 - reloadWithErrorsSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-4"; 70 + etagSystem = "${nodes.webserver.config.system.build.toplevel}/specialisation/etagSystem"; 71 + justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/specialisation/justReloadSystem"; 72 + reloadRestartSystem = "${nodes.webserver.config.system.build.toplevel}/specialisation/reloadRestartSystem"; 73 + reloadWithErrorsSystem = "${nodes.webserver.config.system.build.toplevel}/specialisation/reloadWithErrorsSystem"; 77 74 in '' 78 75 url = "http://localhost/index.html" 79 76
+43
nixos/tests/specialisation.nix
··· 1 + import ./make-test-python.nix { 2 + name = "specialisation"; 3 + nodes = { 4 + inheritconf = { pkgs, ... }: { 5 + environment.systemPackages = [ pkgs.cowsay ]; 6 + specialisation.inheritconf.configuration = { pkgs, ... }: { 7 + environment.systemPackages = [ pkgs.hello ]; 8 + }; 9 + }; 10 + noinheritconf = { pkgs, ... }: { 11 + environment.systemPackages = [ pkgs.cowsay ]; 12 + specialisation.noinheritconf = { 13 + inheritParentConfig = false; 14 + configuration = { pkgs, ... }: { 15 + environment.systemPackages = [ pkgs.hello ]; 16 + }; 17 + }; 18 + }; 19 + }; 20 + testScript = '' 21 + inheritconf.wait_for_unit("default.target") 22 + inheritconf.succeed("cowsay hey") 23 + inheritconf.fail("hello") 24 + 25 + with subtest("Nested clones do inherit from parent"): 26 + inheritconf.succeed( 27 + "/run/current-system/specialisation/inheritconf/bin/switch-to-configuration test" 28 + ) 29 + inheritconf.succeed("cowsay hey") 30 + inheritconf.succeed("hello") 31 + 32 + noinheritconf.wait_for_unit("default.target") 33 + noinheritconf.succeed("cowsay hey") 34 + noinheritconf.fail("hello") 35 + 36 + with subtest("Nested children do not inherit from parent"): 37 + noinheritconf.succeed( 38 + "/run/current-system/specialisation/noinheritconf/bin/switch-to-configuration test" 39 + ) 40 + noinheritconf.fail("cowsay hey") 41 + noinheritconf.succeed("hello") 42 + ''; 43 + }