Move lib out of repo top level and into overlay
This commit is contained in:
parent
38f48c8d07
commit
66117e07b5
49
default.nix
49
default.nix
|
@ -47,53 +47,6 @@ let
|
||||||
crossSystem = system;
|
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 =
|
nixosSystem =
|
||||||
# A derivative of the function for generating Linux NixOS systems.
|
# A derivative of the function for generating Linux NixOS systems.
|
||||||
# This one is not so well tested…
|
# This one is not so well tested…
|
||||||
|
@ -208,7 +161,7 @@ in rec {
|
||||||
let tests = import ./tests;
|
let tests = import ./tests;
|
||||||
in with (lib.forAllCrossSystems ({ system, localSystem, crossSystem }:
|
in with (lib.forAllCrossSystems ({ system, localSystem, crossSystem }:
|
||||||
tests {
|
tests {
|
||||||
inherit lib system localSystem crossSystem;
|
inherit system localSystem crossSystem;
|
||||||
hostPkgs = legacyPackages.${localSystem};
|
hostPkgs = legacyPackages.${localSystem};
|
||||||
testPkgs = legacyPackages.${crossSystem};
|
testPkgs = legacyPackages.${crossSystem};
|
||||||
modulesPath = "${nixpkgs}/nixos/modules";
|
modulesPath = "${nixpkgs}/nixos/modules";
|
||||||
|
|
47
flake.nix
47
flake.nix
|
@ -72,53 +72,6 @@
|
||||||
nixpkgs.lib.extend (final: prev: {
|
nixpkgs.lib.extend (final: prev: {
|
||||||
inherit forAllSystems forAllLocalSystems forAllCrossSystems;
|
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 =
|
nixosSystem =
|
||||||
# A derivative of the function for generating Linux NixOS systems.
|
# A derivative of the function for generating Linux NixOS systems.
|
||||||
# This one is not so well tested…
|
# This one is not so well tested…
|
||||||
|
|
50
lib/overlay.nix
Normal file
50
lib/overlay.nix
Normal 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;
|
||||||
|
}
|
|
@ -107,6 +107,8 @@ in nullPkgs // {
|
||||||
else
|
else
|
||||||
prev.grub2;
|
prev.grub2;
|
||||||
|
|
||||||
|
lib = prev.lib.extend (import ../lib/overlay.nix);
|
||||||
|
|
||||||
libcCrossChooser = name:
|
libcCrossChooser = name:
|
||||||
if stdenv.targetPlatform.isGenode then
|
if stdenv.targetPlatform.isGenode then
|
||||||
final.genodeLibcCross
|
final.genodeLibcCross
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
{ lib, system, localSystem, crossSystem, hostPkgs, testPkgs, modulesPath }:
|
{ system, localSystem, crossSystem, hostPkgs, testPkgs, modulesPath }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
lib = testPkgs.lib;
|
||||||
|
|
||||||
testingPython =
|
testingPython =
|
||||||
# Mostly lifted from Nixpkgs.
|
# Mostly lifted from Nixpkgs.
|
||||||
import ./lib/testing-python.nix;
|
import ./lib/testing-python.nix;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user