From c40b0dc031f3cb32e86bff1f83760a75fa5c5b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 19 Aug 2022 09:47:39 +0200 Subject: fix standalone example --- example/stand-alone/configuration.nix | 34 ++++++++++++++++++++++++++++------ example/stand-alone/tsp-disk.json | 22 ---------------------- 2 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 example/stand-alone/tsp-disk.json diff --git a/example/stand-alone/configuration.nix b/example/stand-alone/configuration.nix index 2ee1597..2a15c32 100644 --- a/example/stand-alone/configuration.nix +++ b/example/stand-alone/configuration.nix @@ -1,10 +1,32 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let - disko = (builtins.fetchGit { - url = https://cgit.lassul.us/disko/; - rev = "88f56a0b644dd7bfa8438409bea5377adef6aef4"; - }) + "/lib"; - cfg = builtins.fromJSON ./tsp-disk.json; + disko = import (builtins.fetchGit { + url = "https://github.com/nix-community/disko"; + ref = "master"; + }) { + 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 { imports = [ (disko.config cfg) diff --git a/example/stand-alone/tsp-disk.json b/example/stand-alone/tsp-disk.json deleted file mode 100644 index 1d82c13..0000000 --- a/example/stand-alone/tsp-disk.json +++ /dev/null @@ -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": "/" - } - } - ] - } - } -} - -- cgit v1.2.3 From fc568cf797fdc4a726e2d961aa41d0dad1bbd004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 17 Aug 2022 17:52:12 +0200 Subject: add flag support --- example/config-gpt-bios.nix | 33 +++++++++++++++++++++++++++++++++ example/config.nix | 1 + example/default.nix | 8 +++++--- lib/default.nix | 3 +++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 example/config-gpt-bios.nix diff --git a/example/config-gpt-bios.nix b/example/config-gpt-bios.nix new file mode 100644 index 0000000..9dfcffa --- /dev/null +++ b/example/config-gpt-bios.nix @@ -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 = "/"; + }; + } + ]; + }; + }; +} diff --git a/example/config.nix b/example/config.nix index 199412d..1a64b1c 100644 --- a/example/config.nix +++ b/example/config.nix @@ -24,6 +24,7 @@ part-type = "primary"; start = "1024MiB"; end = "100%"; + flags = [ "bios_grub" ]; content = { type = "luks"; algo = "aes-xts..."; diff --git a/example/default.nix b/example/default.nix index f2826c9..bf8cd43 100644 --- a/example/default.nix +++ b/example/default.nix @@ -3,11 +3,13 @@ let # TODO: get rid of NIX_PATH dependency here pkgs = import {}; + cfg = import ./config.nix; + #cfg = import ./config-gpt-bios.nix; in with import ../lib { inherit (pkgs) lib;}; { - config = config (import ./config.nix); - create = create (import ./config.nix); - mount = mount (import ./config.nix); + config = config cfg; + create = create cfg; + mount = mount cfg; } diff --git a/lib/default.nix b/lib/default.nix index edc0062..66e667a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -75,6 +75,9 @@ let { ${optionalString (x.bootable or false) '' 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} ''; -- cgit v1.2.3