Как добавить ярлыки к поколениям NixOS

Когда я загружаю свою машину, она показывает все поколения в списке, но называю их «Поколение 49», «Поколение 50» и т. Д.

Есть ли способ добавить ярлыки к поколениям, чтобы потом я мог легко увидеть, что было изменено? Я хотел бы иметь что-то вроде необязательного сообщения о фиксации, например «Поколение 49 - переключилось на KDE5», «Поколение 50 - переключилось обратно на gnome3».


person psmith    schedule 29.01.2016    source источник


Ответы (1)


/boot/grub/grub.conf в настоящее время создается из:

nixos / modules / system / boot / loader / grub / install-grub.pl

# Emit submenus for all system profiles.
sub addProfile {
    my ($profile, $description) = @_;

    # Add entries for all generations of this profile.
    $conf .= "submenu \"$description\" {\n" if $grubVersion == 2;

    sub nrFromGen { my ($x) = @_; $x =~ /\/\w+-(\d+)-link/; return $1; }

    my @links = sort
        { nrFromGen($b) <=> nrFromGen($a) }
        (glob "$profile-*-link");

    my $curEntry = 0;
    foreach my $link (@links) {
        last if $curEntry++ >= $configurationLimit;
        my $date = strftime("%F", localtime(lstat($link)->mtime));
        my $version =
            -e "$link/nixos-version"
            ? readFile("$link/nixos-version")
            : basename((glob(dirname(Cwd::abs_path("$link/kernel")) . "/lib/modules/*"))[0]);
        addEntry("NixOS - Configuration " . nrFromGen($link) . " ($date - $version)", $link);
    }

    $conf .= "}\n" if $grubVersion == 2;
}

это единственная запись в grub.conf:

menuentry "NixOS - Configuration 38 (2016-01-29 - 16.03pre75806.77f8f35)" {
search --set=drive1 --fs-uuid d931bd85-8f35-4ae9-a36b-c1ac51ad7b57
  linux ($drive1)//kernels/56fkcbxnwzi0kh6vg677a4cd4zcabm55-linux-4.1.15-bzImage systemConfig=/nix/store/2sybsl278s5a8kzhplwcz5jbhbsqwdci-nixos-system-lenovo-t530-16.03pre75806.77f8f35 init=/nix/store/2sybsl278s5a8kzhplwcz5jbhbsqwdci-nixos-system-lenovo-t530-16.03pre75806.77f8f35/init loglevel=4
  initrd ($drive1)//kernels/r33fajk0kaxlfmg922c2hy4rak5cj90z-initrd-initrd
}

однако nixos-rebuild поддерживает --profile-name, цитируя страницу руководства:

   --profile-name, -p
       Instead of using the Nix profile /nix/var/nix/profiles/system to keep track of
       the current and previous system configurations, use
       /nix/var/nix/profiles/system-profiles/name. When you use GRUB 2, for every
       system profile created with this flag, NixOS will create a submenu named “NixOS
       - Profile 'name'” in GRUB’s boot menu, containing the current and previous
       configurations of this profile.

       For instance, if you want to test a configuration file named test.nix without
       affecting the default system profile, you would do:

           $ nixos-rebuild switch -p test -I nixos-config=./test.nix

       The new configuration will appear in the GRUB 2 submenu “NixOS - Profile
       'test'”.

Резюме: надеюсь, это то, что вы ищете.

person invalidmagic    schedule 27.02.2016
comment
Это похоже на то, что я хотел. Однако я больше не использую NixOS, поэтому не могу проверить ваш ответ. - person psmith; 27.02.2016
comment
Я думаю, это не то, что он ищет. Насколько я понимаю, эти имена профилей похожи на ветки одного поколения. Он хочет пометить все поколения на стволе. (я тоже) - person 0fnt; 24.04.2019