mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:39:23 +08:00
使用 stripeTabs
This commit is contained in:
10
flake.nix
10
flake.nix
@@ -189,9 +189,9 @@
|
||||
};
|
||||
boot.grub =
|
||||
{
|
||||
entries =
|
||||
''
|
||||
menuentry "Windows" {
|
||||
entries = localLib.stripeTabs
|
||||
"
|
||||
menuentry \"Windows\" {
|
||||
insmod part_gpt
|
||||
insmod fat
|
||||
insmod search_fs_uuid
|
||||
@@ -199,7 +199,7 @@
|
||||
search --fs-uuid --set=root 7317-1DB6
|
||||
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
|
||||
}
|
||||
menuentry "Windows for malware" {
|
||||
menuentry \"Windows for malware\" {
|
||||
insmod part_gpt
|
||||
insmod fat
|
||||
insmod search_fs_uuid
|
||||
@@ -207,7 +207,7 @@
|
||||
search --fs-uuid --set=root 7321-FA9C
|
||||
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
|
||||
}
|
||||
'';
|
||||
";
|
||||
installDevice = "efi";
|
||||
};
|
||||
system =
|
||||
|
||||
@@ -53,12 +53,12 @@ lib:
|
||||
stripeTabs = text:
|
||||
let
|
||||
# Whether all lines start with a tab (or is empty)
|
||||
shouldStripTab = lines: builtins.all (line: (line == "") || (pkgs.lib.strings.hasPrefix " " line)) lines;
|
||||
shouldStripTab = lines: builtins.all (line: (line == "") || (lib.strings.hasPrefix " " line)) lines;
|
||||
# Strip a leading tab from all lines
|
||||
stripTab = lines: builtins.map (line: pkgs.lib.strings.removePrefix " " line) lines;
|
||||
stripTab = lines: builtins.map (line: lib.strings.removePrefix " " line) lines;
|
||||
# Strip tabs recursively until there are none
|
||||
stripTabs = lines: if (shouldStripTab lines) then (stripTabs (stripTab lines)) else lines;
|
||||
in
|
||||
# Split into lines. Strip leading tabs. Concat back to string.
|
||||
builtins.concatStringsSep "\n" (stripTabs (pkgs.lib.strings.splitString "\n" text));
|
||||
builtins.concatStringsSep "\n" (stripTabs (lib.strings.splitString "\n" text));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ inputs:
|
||||
path = mkOption { type = types.nonEmptyStr; };
|
||||
}; }); };
|
||||
};
|
||||
config = let inherit (inputs.lib) mkMerge mkIf; in mkMerge
|
||||
config = let inherit (inputs.lib) mkMerge mkIf; inherit (inputs.localLib) stripeTabs; in mkMerge
|
||||
[
|
||||
# mount.vfat
|
||||
{
|
||||
@@ -105,8 +105,8 @@ inputs:
|
||||
before = [ "local-fs-pre.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = let inherit (inputs.config.nixos.fileSystems.rollingRootfs) device path; in
|
||||
''
|
||||
script = let inherit (inputs.config.nixos.fileSystems.rollingRootfs) device path; in stripeTabs
|
||||
"
|
||||
mount ${device} /mnt -m
|
||||
if [ -f /mnt${path}/current/.timestamp ]
|
||||
then
|
||||
@@ -115,7 +115,7 @@ inputs:
|
||||
btrfs subvolume create /mnt${path}/current
|
||||
echo $(date '+%Y%m%d%H%M%S') > /mnt${path}/current/.timestamp
|
||||
umount /mnt
|
||||
'';
|
||||
";
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user