Merge pull request #12 from nix-community/flag-support

Add flag support
This commit is contained in:
Jörg Thalheim 2022-08-19 08:52:50 +01:00 committed by GitHub
commit 5bcd94a7ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 31 deletions

View File

@ -0,0 +1,33 @@
# Example to create a bios compatible gpt partition
{
type = "devices";
content = {
sda = {
type = "table";
format = "gpt";
partitions = [
{
type = "partition";
start = "0";
end = "1M";
part-type = "primary";
flags = ["bios_grub"];
content.type = "noop";
}
{
type = "partition";
# leave space for the grub aka BIOS boot
start = "1M";
end = "100%";
part-type = "primary";
bootable = true;
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
}
];
};
};
}

View File

@ -24,6 +24,7 @@
part-type = "primary"; part-type = "primary";
start = "1024MiB"; start = "1024MiB";
end = "100%"; end = "100%";
flags = [ "bios_grub" ];
content = { content = {
type = "luks"; type = "luks";
algo = "aes-xts..."; algo = "aes-xts...";

View File

@ -3,11 +3,13 @@
let let
# TODO: get rid of NIX_PATH dependency here # TODO: get rid of NIX_PATH dependency here
pkgs = import <nixpkgs> {}; pkgs = import <nixpkgs> {};
cfg = import ./config.nix;
#cfg = import ./config-gpt-bios.nix;
in in
with import ../lib { inherit (pkgs) lib;}; with import ../lib { inherit (pkgs) lib;};
{ {
config = config (import ./config.nix); config = config cfg;
create = create (import ./config.nix); create = create cfg;
mount = mount (import ./config.nix); mount = mount cfg;
} }

View File

@ -1,10 +1,32 @@
{ pkgs, ... }: { pkgs, lib, ... }:
let let
disko = (builtins.fetchGit { disko = import (builtins.fetchGit {
url = https://cgit.lassul.us/disko/; url = "https://github.com/nix-community/disko";
rev = "88f56a0b644dd7bfa8438409bea5377adef6aef4"; ref = "master";
}) + "/lib"; }) {
cfg = builtins.fromJSON ./tsp-disk.json; inherit lib;
};
cfg = {
type = "devices";
content = {
sda = {
type = "table";
format = "msdos";
partitions = [{
type = "partition";
part-type = "primary";
start = "1M";
end = "100%";
bootable = true;
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
}];
};
};
};
in { in {
imports = [ imports = [
(disko.config cfg) (disko.config cfg)

View File

@ -1,22 +0,0 @@
{
"type": "devices",
"content": {
"sda": {
"type": "table",
"format": "msdos",
"partitions": [
{ "type": "partition",
"start": "1M",
"end": "100%",
"bootable": true,
"content": {
"type": "filesystem",
"format": "ext4",
"mountpoint": "/"
}
}
]
}
}
}

View File

@ -75,6 +75,9 @@ let {
${optionalString (x.bootable or false) '' ${optionalString (x.bootable or false) ''
parted -s ${q.device} set ${toString q.index} boot on parted -s ${q.device} set ${toString q.index} boot on
''} ''}
${concatMapStringsSep "" (flag: ''
parted -s ${q.device} set ${toString q.index} ${flag} on
'') (x.flags or [])}
${create-f { device = q.device + toString q.index; } x.content} ${create-f { device = q.device + toString q.index; } x.content}
''; '';