Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 01ea8a548603
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 747871e9fb05
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Nov 10, 2017

  1. make-disk-image: use faketime to get a consistent timestamp

    This fixes #28768 because during an image build, Nix sees bad store
    timestamps and attempts to fix them, but can't fix them on a running
    system (due to being inside a builder). Since timestamps on the store
    are supposed to be 1 anyway, if we fix this, that fixes image building
    inside booted images made this way.
    
    Note that this adds quite a bit of noise to the output, because running
    `cptofs` under `faketime` causes a bunch of seemingly spurious error
    messages and my attempts to suppress them all failed. We'll fix it when
    `cptofs` gets a native timestamp preservation feature.
    copumpkin committed Nov 10, 2017
    Copy the full SHA
    16cf436 View commit details
  2. Merge pull request #31469 from copumpkin/faketime-make-disk-image

    make-disk-image: use faketime to get a consistent timestamp
    edolstra authored Nov 10, 2017
    Copy the full SHA
    747871e View commit details
Showing with 11 additions and 3 deletions.
  1. +11 −3 nixos/lib/make-disk-image.nix
14 changes: 11 additions & 3 deletions nixos/lib/make-disk-image.nix
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ let
${channelSources}
'';

prepareImageInputs = with pkgs; [ rsync utillinux parted e2fsprogs lkl fakeroot config.system.build.nixos-prepare-root ] ++ stdenv.initialPath;
prepareImageInputs = with pkgs; [ rsync utillinux parted e2fsprogs lkl fakeroot libfaketime config.system.build.nixos-prepare-root ] ++ stdenv.initialPath;

# I'm preserving the line below because I'm going to search for it across nixpkgs to consolidate
# image building logic. The comment right below this now appears in 4 different places in nixpkgs :)
@@ -86,7 +86,7 @@ let
offset=0
''}
mkfs.${fsType} -F -L nixos -E offset=$offset $diskImage
faketime -f "1970-01-01 00:00:01" mkfs.${fsType} -F -L nixos -E offset=$offset $diskImage
root="$PWD/root"
mkdir -p $root
@@ -124,7 +124,15 @@ let
fakeroot nixos-prepare-root $root ${channelSources} ${config.system.build.toplevel} closure
echo "copying staging root to image..."
cptofs ${pkgs.lib.optionalString partitioned "-P 1"} -t ${fsType} -i $diskImage $root/* /
# If we don't faketime, we can end up with timestamps other than 1 on the nix store, which
# will confuse Nix in some situations (e.g., breaking image builds in the target image)
# N.B: I use 0 here, which results in timestamp = 1 in the image. It's weird but see
# https://github.com/lkl/linux/issues/393. Also, running under faketime makes `cptofs` super
# noisy and it prints out that it can't find a bunch of files, and then works anyway. We'll
# shut it up someday but trying to do a stderr filter through grep is running into some nasty
# bug in some eval nonsense we have in runInLinuxVM and I'm sick of trying to fix it.
faketime -f "1970-01-01 00:00:00" \
cptofs ${pkgs.lib.optionalString partitioned "-P 1"} -t ${fsType} -i $diskImage $root/* /
'';
in pkgs.vmTools.runInLinuxVM (
pkgs.runCommand name