From a67ff67ada75e3cb420f2d301314786a1e8a2fa0 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Wed, 17 Jan 2024 08:31:33 +0100 Subject: [PATCH] Prepare lapetus reinstall --- home/features/desktop/spotify.nix | 12 +-- home/features/neovim/config/lazy-lock.json | 4 +- home/features/neovim/default.nix | 14 ++- hosts/nixos/common/global/default.nix | 3 + .../nixos/lapetus/filesystems/partitions.nix | 11 ++- hosts/nixos/lapetus/filesystems/zfs.nix | 86 +++++++++++++++++-- hosts/nixos/tethys/boot.nix | 2 - 7 files changed, 112 insertions(+), 20 deletions(-) diff --git a/home/features/desktop/spotify.nix b/home/features/desktop/spotify.nix index 66920c3..76db852 100644 --- a/home/features/desktop/spotify.nix +++ b/home/features/desktop/spotify.nix @@ -2,10 +2,10 @@ let spicePkgs = inputs.spicetify-nix.packages.${pkgs.system}.default; themeMap = lib.fix (self: { - "Catppuccin Mocha" = spicePkgs.themes.catppuccin; - "Catppuccin Latte" = spicePkgs.themes.catppuccin; - "Catppuccin Frappe" = spicePkgs.themes.catppuccin; - "Catppuccin Macchiato" = spicePkgs.themes.catppuccin; + "Catppuccin Mocha" = spicePkgs.themes.Comfy; + "Catppuccin Latte" = spicePkgs.themes.Comfy; + "Catppuccin Frappe" = spicePkgs.themes.Comfy; + "Catppuccin Macchiato" = spicePkgs.themes.Comfy; default.light = self."Catppuccin Latte"; default.dark = self."Catppuccin Macchiato"; @@ -42,7 +42,9 @@ in wikify # Shows an artist's wikipedia entry songStats showQueueDuration - genre + # REASON: broken + # https://github.com/the-argus/spicetify-nix/issues/50 + # genre adblock savePlaylists # Adds a button to duplicate playlists ]; diff --git a/home/features/neovim/config/lazy-lock.json b/home/features/neovim/config/lazy-lock.json index e0cae5c..0effc48 100644 --- a/home/features/neovim/config/lazy-lock.json +++ b/home/features/neovim/config/lazy-lock.json @@ -29,7 +29,6 @@ "hyprland": { "branch": "main", "commit": "be665459a21730a6acdfaa9c6352cda5e4763af6" }, "idris": { "branch": "main", "commit": "8bff02984a33264437e70fd9fff4359679d910da" }, "inc-rename": { "branch": "main", "commit": "6f9b5f9cb237e12935144cdc535322b8c93c1b25" }, - "inc-rename.nvim": { "branch": "main", "commit": "a48c7cec5c4f00d7438dce5fadb55f4d715ef9f2" }, "indent-blankline": { "branch": "master", "commit": "7206c77cb931f79885fc47f88ae18f99148392eb" }, "lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, @@ -37,6 +36,8 @@ "live-command": { "branch": "main", "commit": "d460067d47948725a6f25b20f31ea8bbfdfe4622" }, "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, "luasnip": { "branch": "master", "commit": "118263867197a111717b5f13d954cd1ab8124387" }, + "mini.base16": { "branch": "main", "commit": "867265505d5147af45d38ca120bbfddaa43e61aa" }, + "mini.colors": { "branch": "main", "commit": "a6b594b7cc07a55fd9e9698be2ff5d2194fd4ac6" }, "mini.comment": { "branch": "main", "commit": "3d9c8009615857e982f09bc5357fc95f2a2175f3" }, "mini.files": { "branch": "main", "commit": "173d73f5d0b2a9abbb2d6533a3770fdbbd0c4dcc" }, "mini.operators": { "branch": "main", "commit": "7a97e2528a4c274e9da8953d3ba22f493c360a9f" }, @@ -57,7 +58,6 @@ "plenary": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "rust-tools": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, - "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, "scrap": { "branch": "main", "commit": "0f833d8dccaabe49c1ed7a2b24cfd887d9d5003f" }, "smart-splits.nvim": { "branch": "master", "commit": "c970c7a3cc7ba635fd73d43c81b40f04c00f5058" }, "ssr": { "branch": "main", "commit": "bb323ba621ac647b4ac5638b47666e3ef3c279e1" }, diff --git a/home/features/neovim/default.nix b/home/features/neovim/default.nix index 4d3d21b..54e0e4d 100644 --- a/home/features/neovim/default.nix +++ b/home/features/neovim/default.nix @@ -1328,7 +1328,9 @@ let # }}} # {{{ obsidian obsidian = - let vault = "${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}/stellar-sanctum"; + let + vault = "${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}/stellar-sanctum"; + dateFormat = "%Y-%m-%d"; in { package = "epwalsh/obsidian.nvim"; @@ -1346,9 +1348,17 @@ let opts = { dir = vault; notes_subdir = "chaos"; + daily_notes = { folder = "daily"; - date_format = "%Y-%m-%d"; + date_format = dateFormat; + template = "New daily note.md"; + }; + + templates = { + subdir = "templates"; + date_format = dateFormat; + time_format = "%H:%M"; }; completion = { diff --git a/hosts/nixos/common/global/default.nix b/hosts/nixos/common/global/default.nix index 05e67ad..65f4f04 100644 --- a/hosts/nixos/common/global/default.nix +++ b/hosts/nixos/common/global/default.nix @@ -46,6 +46,9 @@ in services.journald.extraConfig = lib.mkDefault '' SystemMaxUse=256M ''; + + # Boot using systemd + boot.initrd.systemd.enable = true; # }}} nixpkgs = { diff --git a/hosts/nixos/lapetus/filesystems/partitions.nix b/hosts/nixos/lapetus/filesystems/partitions.nix index 540e8f8..bd5dff9 100644 --- a/hosts/nixos/lapetus/filesystems/partitions.nix +++ b/hosts/nixos/lapetus/filesystems/partitions.nix @@ -9,10 +9,11 @@ type = "table"; format = "gpt"; partitions = [ + # {{{ Boot { name = "ESP"; start = "0"; - end = "64MiB"; + end = "512MiB"; fs-type = "fat32"; bootable = true; content = { @@ -21,15 +22,18 @@ mountpoint = "/boot"; }; } + # }}} + # {{{ Main { name = "zfs"; - start = "128MiB"; + start = "1GiB"; end = "100%"; content = { type = "zfs"; pool = "zroot"; }; } + # }}} ]; }; }; @@ -43,7 +47,6 @@ postCreateHook = '' zfs snapshot zroot@blank - zfs set keylocation="prompt" "zroot"; ''; rootFsOptions = { @@ -51,7 +54,7 @@ "com.sun:auto-snapshot" = "false"; encryption = "aes-256-gcm"; keyformat = "passphrase"; - keylocation = "file:///tmp/secret.key"; + keylocation = "file:///hermes/secrets/lapetus/disk.key"; }; # {{{ Datasets diff --git a/hosts/nixos/lapetus/filesystems/zfs.nix b/hosts/nixos/lapetus/filesystems/zfs.nix index f350a4e..8df786b 100644 --- a/hosts/nixos/lapetus/filesystems/zfs.nix +++ b/hosts/nixos/lapetus/filesystems/zfs.nix @@ -1,12 +1,88 @@ -{ config, ... }: { +{ config, pkgs, ... }: { # Configure ZFS boot.supportedFilesystems = [ "zfs" ]; boot.zfs.extraPools = [ "zroot" ]; boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; boot.kernelParams = [ "nohibernate" ]; - # Roll back to blank snapshot on boot - # boot.initrd.postDeviceCommands = lib.mkAfter '' - # zfs rollback -r zroot@blank - # ''; + boot.initrd.systemd.services = + let secretMountpoint = "/hermes"; + in + { + # {{{ Mount usb + mountSecrets = { + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + unitConfig.DefaultDependencies = "no"; + wantedBy = [ "initrd.target" ]; + before = [ "zfs-mount.service" ]; + after = [ "zfs-import.target" ]; + script = '' + MOUNTPOINT="${secretMountpoint}" + USB="/dev/sdb" + + echo "Waiting for $USB" + for I in {1..20}; do + if [ -e "$USB" ]; then break; fi + echo -n . + sleep 1 + done + + echo "Found $USB" + sleep 1 + + if [ -e "$USB" ]; then + echo "Mounting $USB" + mkdir -p $MOUNTPOINT + mount -o ro "$USB" $MOUNTPOINT + if [ $? -eq 0 ]; then + exit 0 + else + echo "Error mounting $USB" >&2 + fi + else + echo "Cannot find $USB" >&2 + fi + ''; + }; + # }}} + # {{{ Unmount usb + unmountSecrets = { + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + unitConfig.DefaultDependencies = "no"; + wantedBy = [ "initrd.target" ]; + after = [ "zfs-mount.service" ]; + script = '' + MOUNTPOINT="${secretMountpoint}" + if [ -e "$MOUNTPOINT" ]; then + echo "Clearing $MOUNTPOINT" + umount $MOUNTPOINT + rmdir $MOUNTPOINT + echo "Unmounted $MOUNTPOINT" + else + echo "Nothing to unmount" + fi + ''; + }; + # }}} + # # {{{ Rollback + # rollback = { + # path = [ pkgs.zfs ]; + # serviceConfig = { + # Type = "oneshot"; + # RemainAfterExit = true; + # }; + # unitConfig.DefaultDependencies = "no"; + # wantedBy = [ "initrd.target" ]; + # after = [ "zfs-import.target" ]; + # before = [ "sysroot.mount" ]; + # script = "zfs rollback -r zroot@blank"; + # }; + # # }}} + }; } diff --git a/hosts/nixos/tethys/boot.nix b/hosts/nixos/tethys/boot.nix index fc36caa..d7f2cc5 100644 --- a/hosts/nixos/tethys/boot.nix +++ b/hosts/nixos/tethys/boot.nix @@ -1,8 +1,6 @@ { inputs, ... }: { imports = [ inputs.grub2-themes.nixosModules.default ]; - boot.initrd.systemd.enable = true; - # Defined [here](https://github.com/vinceliuice/grub2-themes/blob/master/flake.nix#L11) boot.loader.grub2-theme = { enable = true;