From 37b1bd4ebd5371a721cf92311bfb8049c5f71d55 Mon Sep 17 00:00:00 2001 From: Enkaiyuegure Date: Sat, 2 Nov 2024 21:34:33 +0800 Subject: [PATCH] fix: Resolve error on build caused by accidental triggering from systemd-machine-id-commit.service The bind mount creation for `/etc/machine-id` by `impermanence` is unintentionally triggering `systemd-machine-id-commit.service`, causing an error. This commit resolves this issue, see: https://github.com/nix-community/impermanence/issues/229 and https://github.com/NixOS/nixpkgs/pull/351151 for details. --- flake.nix | 2 +- impermanence.nix | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 49136f8..6cff12f 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ #================================Nix Packages collection & NixOS==============================# #-----------Official NixOS package source, using nixos's unstable branch by default-----------# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - #-------------------------Simplify Nix Flakes with the module system--------------------------# + #=========================Simplify Nix Flakes with the module system==========================# flake-parts.url = "github:hercules-ci/flake-parts"; #===================Declarative disk partitioning and formatting using nix====================# disko = { diff --git a/impermanence.nix b/impermanence.nix index 48ec1a3..f825f80 100644 --- a/impermanence.nix +++ b/impermanence.nix @@ -11,6 +11,15 @@ in pkgs.ncdu ]; + # issue: https://github.com/nix-community/impermanence/issues/229 + # Use symlink + systemd.tmpfiles.rules = [ + "L /etc/machine-id - - - - /persist/etc/machine-id" + ]; + # Or + # boot.initrd.systemd.suppressedUnits = [ "systemd-machine-id-commit.service" ]; + # systemd.suppressedSystemUnits = [ "systemd-machine-id-commit.service" ]; + # There are two ways to clear the root filesystem on every boot: ## 1. use tmpfs for / ## 2. (btrfs/zfs only)take a blank snapshot of the root filesystem and revert to it on every boot via: @@ -45,7 +54,7 @@ in # "/usr/share/icons" ]; files = [ - "/etc/machine-id" + #"/etc/machine-id" "/etc/create-ap.conf" ];