Compare commits
3 Commits
292a4c4d46
...
68ab6faeb3
Author | SHA1 | Date | |
---|---|---|---|
68ab6faeb3 | |||
00aeb81811 | |||
a809c28dde |
@ -5,7 +5,6 @@
|
|||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (pkgs) closureInfo;
|
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@ -36,11 +35,7 @@ in
|
|||||||
mkdir -p $TMPDIR/empty/nix/store/
|
mkdir -p $TMPDIR/empty/nix/store/
|
||||||
cp ${systemConfiguration}/bin/activate $TMPDIR/empty/activate
|
cp ${systemConfiguration}/bin/activate $TMPDIR/empty/activate
|
||||||
ln -s ${pkgs.s6-init-bin}/bin/init $TMPDIR/empty/init
|
ln -s ${pkgs.s6-init-bin}/bin/init $TMPDIR/empty/init
|
||||||
pkgClosure=${closureInfo {
|
grafts=$(sed < ${systemConfiguration}/etc/nix-store-paths 's/^\(.*\)$/--graft \1:\1/g')
|
||||||
rootPaths = [ systemConfiguration ];
|
|
||||||
}}
|
|
||||||
cp $pkgClosure/registration nix-path-registration
|
|
||||||
grafts=$(sed < $pkgClosure/store-paths 's/^\(.*\)$/--graft \1:\1/g')
|
|
||||||
mkfs.jffs2 --compression-mode=size ${endian} -e ${config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root $TMPDIR/empty --output $out $grafts --squash --faketime
|
mkfs.jffs2 --compression-mode=size ${endian} -e ${config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root $TMPDIR/empty --output $out $grafts --squash --faketime
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -8,9 +8,13 @@
|
|||||||
buildInputs = [ ];
|
buildInputs = [ ];
|
||||||
propagatedBuildInputs = [ cpio openssh nix ];
|
propagatedBuildInputs = [ cpio openssh nix ];
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
makeFlags = [ "min-list-garbage" ];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp min-copy-closure.sh $out/bin/min-copy-closure
|
for i in min-copy-closure liminix-rebuild; do
|
||||||
cp liminix-rebuild.sh $out/bin/liminix-rebuild
|
echo $i
|
||||||
|
cp ''${i}.sh $out/bin/$i
|
||||||
|
done
|
||||||
|
cp min-list-garbage $out/bin
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,4 @@ fi
|
|||||||
toplevel=$(nix-build "$@" -A outputs.systemConfiguration --no-out-link)
|
toplevel=$(nix-build "$@" -A outputs.systemConfiguration --no-out-link)
|
||||||
min-copy-closure $target_host $toplevel
|
min-copy-closure $target_host $toplevel
|
||||||
$ssh_command $target_host cp -v -fP $toplevel/bin/* /persist
|
$ssh_command $target_host cp -v -fP $toplevel/bin/* /persist
|
||||||
$ssh_command $target_host "sync; reboot"
|
$ssh_command $target_host "sync; source /etc/profile; reboot"
|
||||||
|
79
pkgs/min-copy-closure/min-list-garbage.c
Normal file
79
pkgs/min-copy-closure/min-list-garbage.c
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#include <dirent.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
typedef char hash_t[32];
|
||||||
|
hash_t *hash_list = NULL;
|
||||||
|
int hash_list_entries = 0;
|
||||||
|
int hash_list_size = 0;
|
||||||
|
|
||||||
|
int add_list_entry(char *name)
|
||||||
|
{
|
||||||
|
name += strlen("/nix/store/");
|
||||||
|
if(hash_list_entries >= hash_list_size) {
|
||||||
|
if(hash_list_size == 0) hash_list_size = 4;
|
||||||
|
hash_list_size = hash_list_size * 2;
|
||||||
|
hash_list = realloc(hash_list, hash_list_size * sizeof(hash_t));
|
||||||
|
}
|
||||||
|
strncpy(hash_list[hash_list_entries++], name, 32);
|
||||||
|
printf("%d %d\n", hash_list_entries, hash_list_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int read_list(char *filename)
|
||||||
|
{
|
||||||
|
char s[1024];
|
||||||
|
FILE *fp;
|
||||||
|
if(fp = fopen(filename, "r")) {
|
||||||
|
while(fgets(s, 1024, fp)) {
|
||||||
|
if(strrchr(s, '\n')) {
|
||||||
|
add_list_entry(s);
|
||||||
|
} else {
|
||||||
|
puts("hash list entry too long");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
int on_list(char *name)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < hash_list_entries; i++) {
|
||||||
|
if(!strncmp(hash_list[i], name, 32)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
struct dirent * de;
|
||||||
|
DIR * dirp;
|
||||||
|
char hash[32];
|
||||||
|
|
||||||
|
if(argc < 2) {
|
||||||
|
puts("Usage: min-list-garbage store-paths-file\n\nChecks all store paths against the list of expected paths in store-paths-file,\n and prints any which are present unexpectedly");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
read_list(argv[1]);
|
||||||
|
|
||||||
|
if((dirp = opendir("/nix/store")) == NULL) {
|
||||||
|
puts("can't open /nix/store");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while(de = readdir(dirp)) {
|
||||||
|
if(strlen(de->d_name) >= 32) {
|
||||||
|
strncpy(hash, de->d_name, 32);
|
||||||
|
if(!on_list(hash)) puts(de->d_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dirp);
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
writeText
|
writeText
|
||||||
, lib
|
, lib
|
||||||
, s6-init-bin
|
, s6-init-bin
|
||||||
|
, closureInfo
|
||||||
, stdenv
|
, stdenv
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@ -61,7 +62,8 @@ let
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
in attrset:
|
in attrset:
|
||||||
stdenv.mkDerivation {
|
let makedevs = activateScript attrset;
|
||||||
|
in stdenv.mkDerivation {
|
||||||
name="make-stuff";
|
name="make-stuff";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
@ -69,11 +71,13 @@ in attrset:
|
|||||||
LDFLAGS = "-static";
|
LDFLAGS = "-static";
|
||||||
|
|
||||||
postConfigure = ''
|
postConfigure = ''
|
||||||
cp ${activateScript attrset} makedevs.c
|
cp ${makedevs} makedevs.c
|
||||||
'';
|
'';
|
||||||
makeFlags = ["makedevs"];
|
makeFlags = ["makedevs"];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
closure=${closureInfo { rootPaths = [ makedevs ]; }}
|
||||||
|
mkdir -p $out/bin $out/etc
|
||||||
|
cp $closure/store-paths $out/etc/nix-store-paths
|
||||||
$STRIP --remove-section=.note --remove-section=.comment --strip-all makedevs -o $out/bin/activate
|
$STRIP --remove-section=.note --remove-section=.comment --strip-all makedevs -o $out/bin/activate
|
||||||
ln -s ${s6-init-bin}/bin/init $out/bin/init
|
ln -s ${s6-init-bin}/bin/init $out/bin/init
|
||||||
'';
|
'';
|
||||||
|
Loading…
Reference in New Issue
Block a user