Compare commits
No commits in common. "1c14bb63fac64bcfd3f51d4dd65b565c0c0aafe0" and "d5ccecf0384a51f3b6c0a2c4c952d9100d30edeb" have entirely different histories.
1c14bb63fa
...
d5ccecf038
@ -10,11 +10,12 @@ let
|
|||||||
<liminix-config>
|
<liminix-config>
|
||||||
] nixpkgs.pkgs;
|
] nixpkgs.pkgs;
|
||||||
finalConfig = config // {
|
finalConfig = config // {
|
||||||
packages = (with nixpkgs.pkgs; [ s6-init-files s6-rc ]) ++
|
packages = (with nixpkgs.pkgs; [ s6-rc ]) ++
|
||||||
config.systemPackages ++
|
config.systemPackages ++
|
||||||
(builtins.attrValues config.services);
|
(builtins.attrValues config.services)
|
||||||
|
;
|
||||||
};
|
};
|
||||||
squashfs = (nixpkgs.pkgs.callPackage ./make-image.nix {}) finalConfig;
|
squashfs = (import ./make-image.nix) nixpkgs finalConfig;
|
||||||
kernel = nixpkgs.pkgs.callPackage ./kernel {
|
kernel = nixpkgs.pkgs.callPackage ./kernel {
|
||||||
inherit (finalConfig.kernel) config;
|
inherit (finalConfig.kernel) config;
|
||||||
};
|
};
|
||||||
|
@ -1,30 +1,47 @@
|
|||||||
{
|
pkgs: config:
|
||||||
stdenv
|
|
||||||
, busybox
|
|
||||||
, buildPackages
|
|
||||||
, callPackage
|
|
||||||
, execline
|
|
||||||
, lib
|
|
||||||
, runCommand
|
|
||||||
, s6-init-bin
|
|
||||||
, s6-init-files
|
|
||||||
, s6-linux-init
|
|
||||||
, s6-rc
|
|
||||||
, s6-rc-database
|
|
||||||
, stdenvNoCC
|
|
||||||
, writeScript
|
|
||||||
, writeText
|
|
||||||
} : config :
|
|
||||||
let
|
let
|
||||||
s6-rc-db = s6-rc-database.override {
|
inherit (pkgs)
|
||||||
services = builtins.attrValues config.services;
|
callPackage
|
||||||
};
|
closureInfo
|
||||||
|
lib
|
||||||
|
runCommand
|
||||||
|
s6-rc
|
||||||
|
stdenv
|
||||||
|
stdenvNoCC
|
||||||
|
writeScript
|
||||||
|
writeText;
|
||||||
|
|
||||||
|
# we need to generate s6 db, by generating closure of all
|
||||||
|
# config.services and calling s6-rc-compile on them
|
||||||
|
allServices = closureInfo {
|
||||||
|
rootPaths = builtins.attrValues config.services;
|
||||||
|
};
|
||||||
|
s6db = stdenvNoCC.mkDerivation {
|
||||||
|
name = "s6-rc-db";
|
||||||
|
nativeBuildInputs = [pkgs.buildPackages.s6-rc];
|
||||||
|
builder = writeText "find-s6-services" ''
|
||||||
|
source $stdenv/setup
|
||||||
|
mkdir -p $out
|
||||||
|
srcs=""
|
||||||
|
shopt -s nullglob
|
||||||
|
for i in $(cat ${allServices}/store-paths ); do
|
||||||
|
if test -d $i; then
|
||||||
|
for j in $i/* ; do
|
||||||
|
if test -f $j/type ; then
|
||||||
|
srcs="$srcs $i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo s6-rc-compile $out/compiled $srcs
|
||||||
|
s6-rc-compile $out/compiled $srcs
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
s6-pseudofiles = pkgs.s6-init-files;
|
||||||
profile = writeScript ".profile" ''
|
profile = writeScript ".profile" ''
|
||||||
PATH=${lib.makeBinPath ([ s6-init-bin busybox execline s6-linux-init s6-rc])}
|
PATH=${lib.makeBinPath (with pkgs; [ s6-init-bin busybox execline s6-linux-init s6-rc])}
|
||||||
export PATH
|
export PATH
|
||||||
'';
|
'';
|
||||||
|
|
||||||
pseudofiles = writeText "pseudofiles" ''
|
pseudofiles = writeText "pseudofiles" ''
|
||||||
/ d 0755 0 0
|
/ d 0755 0 0
|
||||||
/bin d 0755 0 0
|
/bin d 0755 0 0
|
||||||
@ -43,25 +60,24 @@ let
|
|||||||
/sys d 0555 root root
|
/sys d 0555 root root
|
||||||
/dev/pts d 0755 0 0
|
/dev/pts d 0755 0 0
|
||||||
/etc/init.d d 0755 0 0
|
/etc/init.d d 0755 0 0
|
||||||
/bin/init s 0755 0 0 ${s6-init-bin}/bin/init
|
/bin/init s 0755 0 0 ${pkgs.s6-init-bin}/bin/init
|
||||||
/bin/sh s 0755 0 0 ${busybox}/bin/sh
|
/bin/sh s 0755 0 0 ${pkgs.pkgsStatic.busybox}/bin/sh
|
||||||
/bin/busybox s 0755 0 0 ${busybox}/bin/busybox
|
/bin/busybox s 0755 0 0 ${pkgs.busybox}/bin/busybox
|
||||||
/etc/s6-rc d 0755 0 0
|
/etc/s6-rc d 0755 0 0
|
||||||
/etc/s6-rc/compiled s 0755 0 0 ${s6-rc-db}/compiled
|
/etc/s6-rc/compiled s 0755 0 0 ${s6db}/compiled
|
||||||
/etc/passwd f 0644 0 0 echo "root::0:0:root:/:/bin/sh"
|
/etc/passwd f 0644 0 0 echo "root::0:0:root:/:/bin/sh"
|
||||||
/.profile s 0644 0 0 ${profile}
|
/.profile s 0644 0 0 ${profile}
|
||||||
'';
|
'';
|
||||||
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
|
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
|
||||||
# add pseudofiles to store so that the packages they
|
storeContents = [ pseudofiles pkgs.strace s6-pseudofiles pkgs.pkgsStatic.busybox s6db pkgs.s6-linux-init ] ++ config.packages ;
|
||||||
# depend on are also added
|
# comp = "xz -Xdict-size 100%"
|
||||||
storeContents = [ pseudofiles s6-init-files ] ++ config.packages ;
|
|
||||||
};
|
};
|
||||||
in runCommand "frob-squashfs" {
|
in runCommand "frob-squashfs" {
|
||||||
nativeBuildInputs = with buildPackages; [ squashfsTools qprint ];
|
nativeBuildInputs = with pkgs.buildPackages; [ squashfsTools qprint ];
|
||||||
} ''
|
} ''
|
||||||
cp ${storefs} ./store.img
|
cp ${storefs} ./store.img
|
||||||
chmod +w store.img
|
chmod +w store.img
|
||||||
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
|
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
|
||||||
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -pf ${pseudofiles} -pf ${s6-init-files}
|
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -pf ${pseudofiles} -pf ${s6-pseudofiles}
|
||||||
cp store.img $out
|
cp store.img $out
|
||||||
''
|
''
|
||||||
|
@ -10,8 +10,6 @@ final: prev: {
|
|||||||
|
|
||||||
s6-init-bin = final.callPackage ./pkgs/s6-init-bin {};
|
s6-init-bin = final.callPackage ./pkgs/s6-init-bin {};
|
||||||
|
|
||||||
s6-rc-database = final.callPackage ./pkgs/s6-rc-database {};
|
|
||||||
|
|
||||||
pppoe = prev.rpPPPoE.overrideAttrs (o: {
|
pppoe = prev.rpPPPoE.overrideAttrs (o: {
|
||||||
# use newer rp-pppoe, it builds cleanly
|
# use newer rp-pppoe, it builds cleanly
|
||||||
src = final.fetchFromGitHub {
|
src = final.fetchFromGitHub {
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
# generate s6-rc database, by generating closure of all
|
|
||||||
# config.services and calling s6-rc-compile on them
|
|
||||||
|
|
||||||
{
|
|
||||||
stdenvNoCC
|
|
||||||
, buildPackages
|
|
||||||
, closureInfo
|
|
||||||
, writeText
|
|
||||||
, services ? []
|
|
||||||
}:
|
|
||||||
let closure-info = closureInfo { rootPaths = services; };
|
|
||||||
in stdenvNoCC.mkDerivation {
|
|
||||||
name = "s6-rc-database";
|
|
||||||
nativeBuildInputs = [buildPackages.s6-rc];
|
|
||||||
builder = writeText "find-s6-services" ''
|
|
||||||
source $stdenv/setup
|
|
||||||
mkdir -p $out
|
|
||||||
srcs=""
|
|
||||||
shopt -s nullglob
|
|
||||||
for i in $(cat ${closure-info}/store-paths ); do
|
|
||||||
if test -d $i; then
|
|
||||||
for j in $i/* ; do
|
|
||||||
if test -f $j/type ; then
|
|
||||||
srcs="$srcs $i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
s6-rc-compile $out/compiled $srcs
|
|
||||||
'';
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ trap cleanup EXIT
|
|||||||
trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR
|
trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR
|
||||||
unsquashfs -q -d $dest_path -excludes smoke.img /dev
|
unsquashfs -q -d $dest_path -excludes smoke.img /dev
|
||||||
cd $dest_path;
|
cd $dest_path;
|
||||||
db=nix/store/*-s6-rc-database/compiled/
|
db=nix/store/*-s6-rc-db/compiled/
|
||||||
test -d $db
|
test -d $db
|
||||||
chmod -R +w $db
|
chmod -R +w $db
|
||||||
# check we have closure of config.services (lo.link.service exists only
|
# check we have closure of config.services (lo.link.service exists only
|
||||||
@ -21,4 +21,5 @@ echo OK
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
nix-shell -p s6-rc -p squashfsTools --run "$TESTS" || exit 1
|
nix-shell -p s6-rc -p squashfsTools --run "$TESTS" || exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user