File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 29
29
30
30
writeClosure = pkgs . writeClosure or pkgs . writeReferencesToFile ;
31
31
32
+ storeDiskContents = writeClosure (
33
+ [ config . system . build . toplevel ]
34
+ ++
35
+ lib . optional config . nix . enable regInfo
36
+ ) ;
37
+
32
38
in
33
39
{
34
40
options . microvm = with lib ; {
84
90
85
91
microvm . storeDisk = pkgs . runCommandLocal "microvm-store-disk.${ config . microvm . storeDiskType } " {
86
92
nativeBuildInputs = [
93
+ pkgs . buildPackages . time
94
+ pkgs . buildPackages . bubblewrap
87
95
{
88
96
squashfs = [ pkgs . buildPackages . squashfs-tools-ng ] ;
89
97
erofs = [ erofs-utils ] ;
93
101
inherit regInfo ;
94
102
} ;
95
103
} ''
96
- echo Copying a /nix/store
97
104
mkdir store
98
- for d in $(sort -u ${
99
- lib . concatMapStringsSep " " writeClosure (
100
- lib . optionals config . microvm . storeOnDisk (
101
- [ config . system . build . toplevel ]
102
- ++
103
- lib . optional config . nix . enable regInfo
104
- )
105
- )
106
- } ); do
107
- cp -a $d store
105
+ BWRAP_ARGS="--dev-bind / / --chdir $(pwd)"
106
+ for d in $(sort -u ${ storeDiskContents } ); do
107
+ BWRAP_ARGS="$BWRAP_ARGS --ro-bind $d $(pwd)/store/$(basename $d)"
108
108
done
109
109
110
110
echo Creating a ${ config . microvm . storeDiskType }
111
- time ${ {
111
+ bwrap $BWRAP_ARGS -- time ${ {
112
112
squashfs = "gensquashfs ${ squashfsFlags } -D store --all-root -q $out" ;
113
113
erofs = "mkfs.erofs ${ erofsFlags } -T 0 --all-root -L nix-store --mount-point=/nix/store $out store" ;
114
114
} . ${ config . microvm . storeDiskType } }
You can’t perform that action at this time.
0 commit comments