nixfmt-rfc-style

There is nothing in this commit except for the changes made by
nix-shell -p nixfmt-rfc-style --run "nixfmt ."

If this has mucked up your open branches then sorry about that. You
can probably nixfmt them to match before merging
This commit is contained in:
Daniel Barlow
2025-02-10 21:55:08 +00:00
parent 13cc5a8992
commit 7e2b0068e6
211 changed files with 6049 additions and 4355 deletions

View File

@@ -1,9 +1,11 @@
{ buildPackages
, callPackage
, pseudofile
, runCommand
, writeText
} : filesystem :
{
buildPackages,
callPackage,
pseudofile,
runCommand,
writeText,
}:
filesystem:
let
pseudofiles = pseudofile.write "files.pf" filesystem;
@@ -14,12 +16,18 @@ let
# the pseudofile will give us all the needed packages
storeContents = [ pseudofiles ];
};
in runCommand "frob-squashfs" {
nativeBuildInputs = with buildPackages; [ squashfsTools qprint ];
} ''
in
runCommand "frob-squashfs"
{
nativeBuildInputs = with buildPackages; [
squashfsTools
qprint
];
}
''
cp ${storefs} ./store.img
chmod +w store.img
mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${pseudofiles}
cp store.img $out
''
''

View File

@@ -1,9 +1,9 @@
{
ifwait
, serviceFns
ifwait,
serviceFns,
}:
{
ifup = name : ifname : ''
ifup = name: ifname: ''
. ${serviceFns}
${ifwait}/bin/ifwait -v ${ifname} present
ip link set up dev ${ifname}

View File

@@ -1,100 +1,135 @@
{
stdenvNoCC
, s6
, lib
, writeScript
, serviceFns
stdenvNoCC,
s6,
lib,
writeScript,
serviceFns,
}:
let
prefix = "/run/services/outputs";
output = service: name: "${prefix}/${service.name}/${name}";
serviceScript = commands : ''
serviceScript = commands: ''
#!/bin/sh
exec 2>&1
. ${serviceFns}
${commands}
'';
cleanupScript = name : cmds : ''
cleanupScript = name: cmds: ''
#!/bin/sh
${if cmds != null then cmds else ""}
if test -d ${prefix}/${name} ; then rm -rf ${prefix}/${name} ; fi
'';
service = {
name
, serviceType
, run ? null
, up ? null
, down ? null
, finish ? null
, notification-fd ? null
, producer-for ? null
, consumer-for ? null
, pipeline-name ? null
, timeout-up ? 30000 # milliseconds
, timeout-down ? 0
, dependencies ? []
, contents ? []
, buildInputs ? []
, restart-on-upgrade ? false
, controller ? null
}:
service =
{
name,
serviceType,
run ? null,
up ? null,
down ? null,
finish ? null,
notification-fd ? null,
producer-for ? null,
consumer-for ? null,
pipeline-name ? null,
timeout-up ? 30000, # milliseconds
timeout-down ? 0,
dependencies ? [ ],
contents ? [ ],
buildInputs ? [ ],
restart-on-upgrade ? false,
controller ? null,
}:
stdenvNoCC.mkDerivation {
# we use stdenvNoCC to avoid generating derivations with names
# like foo.service-mips-linux-musl
inherit name serviceType up down run finish notification-fd
producer-for consumer-for pipeline-name timeout-up timeout-down
restart-on-upgrade;
buildInputs = buildInputs ++ dependencies ++ contents ++ lib.optional (controller != null) controller;
inherit
name
serviceType
up
down
run
finish
notification-fd
producer-for
consumer-for
pipeline-name
timeout-up
timeout-down
restart-on-upgrade
;
buildInputs =
buildInputs ++ dependencies ++ contents ++ lib.optional (controller != null) controller;
inherit controller dependencies contents;
builder = ./builder.sh;
};
longrun = {
name
, run
, finish ? null
, notification-fd ? null
, buildInputs ? []
, producer-for ? null
, ...
} @ args:
let logger = service {
serviceType = "longrun";
name = "${name}-log";
run = serviceScript "${s6}/bin/s6-log -d 10 -- p${name} 1";
notification-fd = 10;
consumer-for = name;
pipeline-name = "${name}-pipeline";
};
in service (args // {
buildInputs = buildInputs ++ lib.optional (producer-for == null) logger;
serviceType = "longrun";
run = serviceScript run;
finish = cleanupScript name finish;
producer-for = if producer-for != null then producer-for else "${name}-log";
});
longrun =
{
name,
run,
finish ? null,
notification-fd ? null,
buildInputs ? [ ],
producer-for ? null,
...
}@args:
let
logger = service {
serviceType = "longrun";
name = "${name}-log";
run = serviceScript "${s6}/bin/s6-log -d 10 -- p${name} 1";
notification-fd = 10;
consumer-for = name;
pipeline-name = "${name}-pipeline";
};
in
service (
args
// {
buildInputs = buildInputs ++ lib.optional (producer-for == null) logger;
serviceType = "longrun";
run = serviceScript run;
finish = cleanupScript name finish;
producer-for = if producer-for != null then producer-for else "${name}-log";
}
);
oneshot = {
name
, up
, down ? ""
, ...
} @ args : service (args // {
serviceType = "oneshot";
up = writeScript "${name}-up" (serviceScript up);
down = writeScript
"${name}-down"
"${serviceScript down}\n${cleanupScript name null}";
});
bundle = { contents ? []
, dependencies ? []
, ...
} @ args: service (args // {
serviceType = "bundle";
inherit contents dependencies;
});
oneshot =
{
name,
up,
down ? "",
...
}@args:
service (
args
// {
serviceType = "oneshot";
up = writeScript "${name}-up" (serviceScript up);
down = writeScript "${name}-down" "${serviceScript down}\n${cleanupScript name null}";
}
);
bundle =
{
contents ? [ ],
dependencies ? [ ],
...
}@args:
service (
args
// {
serviceType = "bundle";
inherit contents dependencies;
}
);
target = bundle;
in {
inherit target bundle oneshot output;
in
{
inherit
target
bundle
oneshot
output
;
longrun = lib.makeOverridable longrun;
}