From f61ea6ce5c70c3e460ff84a0781bb8d131721510 Mon Sep 17 00:00:00 2001 From: kalipso Date: Tue, 26 Nov 2024 13:14:36 +0100 Subject: [PATCH] [bakunin] add disko device --- flake.nix | 2 + machines/configuration.nix | 3 +- machines/modules/disko/btrfs-laptop.nix | 63 +++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 machines/modules/disko/btrfs-laptop.nix diff --git a/flake.nix b/flake.nix index c02f881..f5e5802 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,8 @@ mfsync.url = "github:k4lipso/mfsync"; microvm.url = "github:astro/microvm.nix"; microvm.inputs.nixpkgs.follows = "nixpkgs"; + inputs.disko.url = "github:nix-community/disko/latest"; + inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; utils = { url = "github:numtide/flake-utils"; diff --git a/machines/configuration.nix b/machines/configuration.nix index df738e4..bb50a90 100644 --- a/machines/configuration.nix +++ b/machines/configuration.nix @@ -83,12 +83,13 @@ in ]; }; - bakunin = nixosSystem { system = "x86_64-linux"; specialArgs.inputs = inputs; modules = defaultModules ++ [ ./bakunin/configuration.nix + inputs.disko.nixosModules.disko + ./modules/disko/btrfs-laptop.nix ]; }; diff --git a/machines/modules/disko/btrfs-laptop.nix b/machines/modules/disko/btrfs-laptop.nix new file mode 100644 index 0000000..aeedcbb --- /dev/null +++ b/machines/modules/disko/btrfs-laptop.nix @@ -0,0 +1,63 @@ +{ config, self, inputs, ... }: + +{ + imports = [ + inputs.disko.nixosModules.disko + ]; + + # https://github.com/nix-community/disko/blob/master/example/luks-btrfs-subvolumes.nix + disko.devices = { + disk = { + main = { + type = "disk"; + # When using disko-install, we will overwrite this value from the commandline + device = "/dev/disk/by-id/some-disk-id"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "crypted"; + passwordFile = "/tmp/secret.key"; # Interactive + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "20M"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +}