init(builder): debian-binary builder

This initializes first efforts to generate a debian builder.
This commit is contained in:
a-kenji 2022-07-26 20:33:22 +02:00 committed by DavHau
parent 74e91fbaee
commit d05e8b5dba
3 changed files with 88 additions and 3 deletions

View File

@ -36,6 +36,6 @@
source = drvSanitized;
};
in
extracted;
b.trace drvSanitized.outputHashAlgo extracted;
};
}

View File

@ -0,0 +1,85 @@
{...}: {
type = "pure";
build = {
lib,
pkgs,
stdenv,
# dream2nix inputs
externals,
...
}: {
### FUNCTIONS
# AttrSet -> Bool) -> AttrSet -> [x]
getCyclicDependencies, # name: version: -> [ {name=; version=; } ]
getDependencies, # name: version: -> [ {name=; version=; } ]
getSource, # name: version: -> store-path
# to get information about the original source spec
getSourceSpec, # name: version: -> {type="git"; url=""; hash="";}
### ATTRIBUTES
subsystemAttrs, # attrset
defaultPackageName, # string
defaultPackageVersion, # string
# all exported (top-level) package names and versions
# attrset of pname -> version,
packages,
# all existing package names and versions
# attrset of pname -> versions,
# where versions is a list of version strings
packageVersions,
# function which applies overrides to a package
# It must be applied by the builder to each individual derivation
# Example:
# produceDerivation name (mkDerivation {...})
produceDerivation,
...
} @ args: let
l = lib // builtins;
allDependencySources' =
l.flatten
(l.mapAttrsToList
(name: versions:
if l.elem name [defaultPackageName]
then []
else l.map (ver: getSource name ver) versions)
packageVersions);
allDependencySources =
l.map
(src: l.trace (l.toJSON src) l.trace (l.toJSON src.original) src.original)
allDependencySources';
package = produceDerivation defaultPackageName (stdenv.mkDerivation {
name = defaultPackageName;
src = ":";
dontUnpack = true;
buildInputs = [pkgs.unzip];
nativeBuildInputs = [pkgs.autoPatchelfHook];
doCheck = false;
dontStrip = true;
buildPhase = ''
runHook preBuild
mkdir $out/bin
mkdir $out/share
mkdir $out/lib
mkdir $out/etc
for file in ${toString allDependencySources};do
mkdir $TMP/unpack
unzip -d $TMP/unpack file
cd $TMP/unpack
tar -xf $TMP/unpack/data.tar.xz
cp $TMP/unpack/usr/bin/* $out/bin
cp $TMP/unpack/usr/sbin/* $out/bin
cp -r $TMP/unpack/usr/share/* $out/share
cp -r $TMP/unpack/etc/* $out/etc
runHook postBuild
'';
});
in {
packages.${defaultPackageName}.${defaultPackageVersion} = package;
};
}

View File

@ -12,7 +12,7 @@ def main():
dream_lock = dict(
sources={},
_generic={
"subsystem": "debian-binary",
"subsystem": "debian",
"defaultPackage": os.environ.get("NAME"),
"packages": {
os.environ.get("NAME"): os.environ.get("VERSION"),
@ -40,7 +40,7 @@ def main():
dream_lock["sources"][name] = {
version: dict(
type="http",
url="uri",
url=uri.replace("http:", "https:").replace("'", ""),
sha256=sha256,
)
}