From b78bd2f9120b2e21b8556c45ee20ddb49942fc67 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Tue, 13 Aug 2024 21:33:15 -0400 Subject: [PATCH] Revert "Merge pull request #333952 from r-vdp/specialisation-name-regex" This reverts commit fc35704bc8f083ba939c081bb5cc7c1f7f3e8049, reversing changes made to c67d90d51787d796c0a50fcfdab41956fa89ba3d. --- .../system/activation/specialisation.nix | 19 +---------- .../systemd-boot/systemd-boot-builder.py | 2 +- nixos/tests/nixos-rebuild-specialisations.nix | 33 ------------------- 3 files changed, 2 insertions(+), 52 deletions(-) diff --git a/nixos/modules/system/activation/specialisation.nix b/nixos/modules/system/activation/specialisation.nix index fc348ad94c03..fdab287802fa 100644 --- a/nixos/modules/system/activation/specialisation.nix +++ b/nixos/modules/system/activation/specialisation.nix @@ -1,14 +1,10 @@ -{ config, lib, extendModules, noUserModules, ... }: +{ config, lib, pkgs, extendModules, noUserModules, ... }: let inherit (lib) - attrNames concatStringsSep - filter - length mapAttrs mapAttrsToList - match mkOption types ; @@ -77,19 +73,6 @@ in }; config = { - assertions = [( - let - invalidNames = filter (name: match "[[:alnum:]_]+" name == null) (attrNames config.specialisation); - in - { - assertion = length invalidNames == 0; - message = '' - Specialisation names can only contain alphanumeric characters and underscores - Invalid specialisation names: ${concatStringsSep ", " invalidNames} - ''; - } - )]; - system.systemBuilderCommands = '' mkdir $out/specialisation ${concatStringsSep "\n" diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py index c4324a8eae5b..846787985cea 100644 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py @@ -65,7 +65,7 @@ class Entry: # Matching nixos*-generation-$number*.conf rex_generation = re.compile(r"^nixos.*-generation-([0-9]+).*\.conf$") # Matching nixos*-generation-$number-specialisation-$specialisation_name*.conf - rex_specialisation = re.compile(r"^nixos.*-generation-([0-9]+)-specialisation-([a-zA-Z0-9_]+).*\.conf$") + rex_specialisation = re.compile(r"^nixos.*-generation-([0-9]+)-specialisation-([a-zA-Z0-9]+).*\.conf$") profile = rex_profile.sub(r"\1", filename) if rex_profile.match(filename) else None specialisation = rex_specialisation.sub(r"\2", filename) if rex_specialisation.match(filename) else None try: diff --git a/nixos/tests/nixos-rebuild-specialisations.nix b/nixos/tests/nixos-rebuild-specialisations.nix index a5b916f7d7e9..9192b8a8a030 100644 --- a/nixos/tests/nixos-rebuild-specialisations.nix +++ b/nixos/tests/nixos-rebuild-specialisations.nix @@ -71,32 +71,6 @@ import ./make-test-python.nix ({ pkgs, ... }: { } ''; - wrongConfigFile = pkgs.writeText "configuration.nix" '' - { lib, pkgs, ... }: { - imports = [ - ./hardware-configuration.nix - - ]; - - boot.loader.grub = { - enable = true; - device = "/dev/vda"; - forceInstall = true; - }; - - documentation.enable = false; - - environment.systemPackages = [ - (pkgs.writeShellScriptBin "parent" "") - ]; - - specialisation.foo-bar = { - inheritParentConfig = true; - - configuration = { ... }: { }; - }; - } - ''; in '' machine.start() @@ -142,12 +116,5 @@ import ./make-test-python.nix ({ pkgs, ... }: { with subtest("Make sure nonsense command combinations are forbidden"): machine.fail("nixos-rebuild boot --specialisation foo") machine.fail("nixos-rebuild boot -c foo") - - machine.copy_from_host( - "${wrongConfigFile}", - "/etc/nixos/configuration.nix", - ) - with subtest("Make sure that invalid specialisation names are rejected"): - machine.fail("nixos-rebuild switch") ''; })