Move lib out of repo top level and into overlay

This commit is contained in:
Ehmry - 2023-10-03 12:05:21 +01:00
parent 38f48c8d07
commit 66117e07b5
5 changed files with 56 additions and 96 deletions

View File

@ -47,53 +47,6 @@ let
crossSystem = system;
}));
getMainProgram = pkg:
with builtins;
if hasAttr "mainProgram" pkg.meta then
pkg.meta.mainProgram
else
trace "${pkg.name} is missing meta.mainProgram" pkg.pname;
getEris = filename: pkg:
with builtins;
let
manifest = fromJSON (unsafeDiscardStringContext
(readFile "${pkg}/nix-support/eris-manifest.json"));
entry = manifest.${filename};
in {
inherit (entry) cap;
closure = map (ce:
if ce.cap == entry.cap then
ce // {
# hack to build a string with context to propagate a
# dependency on the rest of the closure
path = "${pkg}${
substring (stringLength pkg) (stringLength ce.path) ce.path
}";
}
else
ce) entry.closure;
};
getErisMainProgram = pkg:
final.getEris (final.getMainProgram pkg) (prev.getOutput "bin" pkg);
getErisLib = filename: pkg:
final.getEris filename (prev.getOutput "lib" pkg);
uuidFrom = seed:
let digest = builtins.hashString "sha256" seed;
in (lib.lists.foldl ({ str, off }:
n:
let chunk = builtins.substring off n digest;
in {
str = if off == 0 then chunk else "${str}-${chunk}";
off = off + n;
}) {
str = "";
off = 0;
} [ 8 4 4 4 12 ]).str;
nixosSystem =
# A derivative of the function for generating Linux NixOS systems.
# This one is not so well tested…
@ -208,7 +161,7 @@ in rec {
let tests = import ./tests;
in with (lib.forAllCrossSystems ({ system, localSystem, crossSystem }:
tests {
inherit lib system localSystem crossSystem;
inherit system localSystem crossSystem;
hostPkgs = legacyPackages.${localSystem};
testPkgs = legacyPackages.${crossSystem};
modulesPath = "${nixpkgs}/nixos/modules";

View File

@ -72,53 +72,6 @@
nixpkgs.lib.extend (final: prev: {
inherit forAllSystems forAllLocalSystems forAllCrossSystems;
getMainProgram = pkg:
with builtins;
if hasAttr "mainProgram" pkg.meta then
pkg.meta.mainProgram
else
trace "${pkg.name} is missing meta.mainProgram" pkg.pname;
getEris = filename: pkg:
with builtins;
let
manifest = fromJSON (unsafeDiscardStringContext
(readFile "${pkg}/nix-support/eris-manifest.json"));
entry = manifest.${filename};
in {
inherit (entry) cap;
closure = map (ce:
if ce.cap == entry.cap then
ce // {
# hack to build a string with context to propagate a
# dependency on the rest of the closure
path = "${pkg}${
substring (stringLength pkg) (stringLength ce.path)
ce.path
}";
}
else
ce) entry.closure;
};
getErisMainProgram = pkg:
final.getEris (final.getMainProgram pkg) (prev.getOutput "bin" pkg);
getErisLib = filename: pkg:
final.getEris filename (prev.getOutput "lib" pkg);
uuidFrom = seed:
let digest = builtins.hashString "sha256" seed;
in (lib.lists.foldl ({ str, off }:
n:
let chunk = builtins.substring off n digest;
in {
str = if off == 0 then chunk else "${str}-${chunk}";
off = off + n;
}) {
str = "";
off = 0;
} [ 8 4 4 4 12 ]).str;
nixosSystem =
# A derivative of the function for generating Linux NixOS systems.
# This one is not so well tested…

50
lib/overlay.nix Normal file
View File

@ -0,0 +1,50 @@
final: prev:
let lib = prev;
in {
getMainProgram = pkg:
with builtins;
if hasAttr "mainProgram" pkg.meta then
pkg.meta.mainProgram
else
trace "${pkg.name} is missing meta.mainProgram" pkg.pname;
getEris = filename: pkg:
with builtins;
let
manifest = fromJSON (unsafeDiscardStringContext
(readFile "${pkg}/nix-support/eris-manifest.json"));
entry = manifest.${filename};
in {
inherit (entry) cap;
closure = map (ce:
if ce.cap == entry.cap then
ce // {
# hack to build a string with context to propagate a
# dependency on the rest of the closure
path = "${pkg}${
substring (stringLength pkg) (stringLength ce.path) ce.path
}";
}
else
ce) entry.closure;
};
getErisMainProgram = pkg:
final.getEris (final.getMainProgram pkg) (prev.getOutput "bin" pkg);
getErisLib = filename: pkg: final.getEris filename (prev.getOutput "lib" pkg);
uuidFrom = seed:
let digest = builtins.hashString "sha256" seed;
in (lib.lists.foldl ({ str, off }:
n:
let chunk = builtins.substring off n digest;
in {
str = if off == 0 then chunk else "${str}-${chunk}";
off = off + n;
}) {
str = "";
off = 0;
} [ 8 4 4 4 12 ]).str;
}

View File

@ -107,6 +107,8 @@ in nullPkgs // {
else
prev.grub2;
lib = prev.lib.extend (import ../lib/overlay.nix);
libcCrossChooser = name:
if stdenv.targetPlatform.isGenode then
final.genodeLibcCross

View File

@ -1,6 +1,8 @@
{ lib, system, localSystem, crossSystem, hostPkgs, testPkgs, modulesPath }:
{ system, localSystem, crossSystem, hostPkgs, testPkgs, modulesPath }:
let
lib = testPkgs.lib;
testingPython =
# Mostly lifted from Nixpkgs.
import ./lib/testing-python.nix;