Skip to content

Commit

Permalink
Merge pull request #37337 from obsidiansystems/meta-check-18.03
Browse files Browse the repository at this point in the history
lib: Fix #30902 on 18.03
  • Loading branch information
Ericson2314 authored Apr 6, 2018
2 parents 8244fb1 + ac3d9c3 commit 7060c52
Show file tree
Hide file tree
Showing 50 changed files with 236 additions and 160 deletions.
2 changes: 1 addition & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let
filesystem = callLibs ./filesystem.nix;

# back-compat aliases
platforms = systems.doubles;
platforms = systems.forMeta;

inherit (builtins) add addErrorContext attrNames
concatLists deepSeq elem elemAt filter genericClosure genList
Expand Down
19 changes: 19 additions & 0 deletions lib/meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,23 @@ rec {
*/
hiPrioSet = set: mapDerivationAttrset hiPrio set;


/* Check to see if a platform is matched by the given `meta.platforms`
element.
A `meta.platform` pattern is either
1. (legacy) a system string.
2. (modern) a pattern for the platform `parsed` field.
We can inject these into a patten for the whole of a structured platform,
and then match that.
*/
platformMatch = platform: elem: let
pattern =
if builtins.isString elem
then { system = elem; }
else { parsed = elem; };
in lib.matchAttrs pattern platform;
}
1 change: 1 addition & 0 deletions lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

rec {
doubles = import ./doubles.nix { inherit lib; };
forMeta = import ./for-meta.nix { inherit lib; };
parse = import ./parse.nix { inherit lib; };
inspect = import ./inspect.nix { inherit lib; };
platforms = import ./platforms.nix { inherit lib; };
Expand Down
7 changes: 4 additions & 3 deletions lib/systems/doubles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@ let
in rec {
inherit all;

allBut = platforms: lists.filter (x: !(builtins.elem x platforms)) all;
none = [];

arm = filterDoubles predicates.isArm;
aarch64 = filterDoubles predicates.isAarch64;
x86 = filterDoubles predicates.isx86;
i686 = filterDoubles predicates.isi686;
mips = filterDoubles predicates.isMips;
x86_64 = filterDoubles predicates.isx86_64;
mips = filterDoubles predicates.isMips;

cygwin = filterDoubles predicates.isCygwin;
darwin = filterDoubles predicates.isDarwin;
freebsd = filterDoubles predicates.isFreeBSD;
# Should be better, but MinGW is unclear, and HURD is bit-rotted.
gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; });
gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; });
illumos = filterDoubles predicates.isSunOS;
linux = filterDoubles predicates.isLinux;
netbsd = filterDoubles predicates.isNetBSD;
Expand Down
30 changes: 30 additions & 0 deletions lib/systems/for-meta.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ lib }:
let
inherit (lib.systems) parse;
inherit (lib.systems.inspect) patterns;

in rec {
all = [ {} ]; # `{}` matches anything
none = [];

arm = [ patterns.isArm ];
aarch64 = [ patterns.isAarch64 ];
x86 = [ patterns.isx86 ];
i686 = [ patterns.isi686 ];
x86_64 = [ patterns.isx86_64 ];
mips = [ patterns.isMips ];

cygwin = [ patterns.isCygwin ];
darwin = [ patterns.isDarwin ];
freebsd = [ patterns.isFreeBSD ];
# Should be better, but MinGW is unclear, and HURD is bit-rotted.
gnu = [ { kernel = parse.kernels.linux; abi = parse.abis.gnu; } ];
illumos = [ patterns.isSunOS ];
linux = [ patterns.isLinux ];
netbsd = [ patterns.isNetBSD ];
openbsd = [ patterns.isOpenBSD ];
unix = patterns.isUnix; # Actually a list
windows = [ patterns.isWindows ];

inherit (lib.systems.doubles) mesaPlatforms;
}
80 changes: 39 additions & 41 deletions lib/systems/inspect.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,49 @@ with lib.lists;

rec {
patterns = rec {
i686 = { cpu = cpuTypes.i686; };
x86_64 = { cpu = cpuTypes.x86_64; };
PowerPC = { cpu = cpuTypes.powerpc; };
x86 = { cpu = { family = "x86"; }; };
Arm = { cpu = { family = "arm"; }; };
Aarch64 = { cpu = { family = "aarch64"; }; };
Mips = { cpu = { family = "mips"; }; };
RiscV = { cpu = { family = "riscv"; }; };
Wasm = { cpu = { family = "wasm"; }; };

"32bit" = { cpu = { bits = 32; }; };
"64bit" = { cpu = { bits = 64; }; };
BigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; };
LittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };

BSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
Unix = [ BSD Darwin Linux SunOS Hurd Cygwin ];

Darwin = { kernel = kernels.darwin; };
Linux = { kernel = kernels.linux; };
SunOS = { kernel = kernels.solaris; };
FreeBSD = { kernel = kernels.freebsd; };
Hurd = { kernel = kernels.hurd; };
NetBSD = { kernel = kernels.netbsd; };
OpenBSD = { kernel = kernels.openbsd; };
Windows = { kernel = kernels.windows; };
Cygwin = { kernel = kernels.windows; abi = abis.cygnus; };
MinGW = { kernel = kernels.windows; abi = abis.gnu; };

Android = [ { abi = abis.android; } { abi = abis.androideabi; } ];
Musl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ];

Kexecable = map (family: { kernel = kernels.linux; cpu.family = family; })
[ "x86" "arm" "aarch64" "mips" ];
Efi = map (family: { cpu.family = family; })
[ "x86" "arm" "aarch64" ];
Seccomputable = map (family: { kernel = kernels.linux; cpu.family = family; })
[ "x86" "arm" "aarch64" "mips" ];
isi686 = { cpu = cpuTypes.i686; };
isx86_64 = { cpu = cpuTypes.x86_64; };
isPowerPC = { cpu = cpuTypes.powerpc; };
isx86 = { cpu = { family = "x86"; }; };
isArm = { cpu = { family = "arm"; }; };
isAarch64 = { cpu = { family = "aarch64"; }; };
isMips = { cpu = { family = "mips"; }; };
isRiscV = { cpu = { family = "riscv"; }; };
isWasm = { cpu = { family = "wasm"; }; };

is32bit = { cpu = { bits = 32; }; };
is64bit = { cpu = { bits = 64; }; };
isBigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; };
isLittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };

isBSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
isUnix = [ isBSD isDarwin isLinux isSunOS isHurd isCygwin ];

isDarwin = { kernel = kernels.darwin; };
isLinux = { kernel = kernels.linux; };
isSunOS = { kernel = kernels.solaris; };
isFreeBSD = { kernel = kernels.freebsd; };
isHurd = { kernel = kernels.hurd; };
isNetBSD = { kernel = kernels.netbsd; };
isOpenBSD = { kernel = kernels.openbsd; };
isWindows = { kernel = kernels.windows; };
isCygwin = { kernel = kernels.windows; abi = abis.cygnus; };
isMinGW = { kernel = kernels.windows; abi = abis.gnu; };

isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ];

isKexecable = map (family: { kernel = kernels.linux; cpu.family = family; })
[ "x86" "arm" "aarch64" "mips" ];
isEfi = map (family: { cpu.family = family; })
[ "x86" "arm" "aarch64" ];
isSeccomputable = map (family: { kernel = kernels.linux; cpu.family = family; })
[ "x86" "arm" "aarch64" "mips" ];
};

matchAnyAttrs = patterns:
if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
else matchAttrs patterns;

predicates = mapAttrs'
(name: value: nameValuePair ("is" + name) (matchAnyAttrs value))
patterns;
predicates = mapAttrs (_: matchAnyAttrs) patterns;
}
53 changes: 26 additions & 27 deletions nixos/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ let
inherit system;
} // args);

# Note: only supportedSystems are considered.
callTestOnTheseSystems = systems: fn: args:
forTheseSystems
(intersectLists supportedSystems systems)
callTestOnMatchingSystems = systems: fn: args:
forMatchingSystems
systems
(system: hydraJob (importTest fn args system));
callTest = callTestOnTheseSystems supportedSystems;
callTest = callTestOnMatchingSystems supportedSystems;

callSubTests = callSubTestsOnTheseSystems supportedSystems;
callSubTestsOnTheseSystems = systems: fn: args: let
callSubTests = callSubTestsOnMatchingSystems supportedSystems;
callSubTestsOnMatchingSystems = systems: fn: args: let
discover = attrs: let
subTests = filterAttrs (const (hasAttr "test")) attrs;
in mapAttrs (const (t: hydraJob t.test)) subTests;
Expand Down Expand Up @@ -138,7 +137,7 @@ in rec {
# Build the initial ramdisk so Hydra can keep track of its size over time.
initialRamdisk = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.initialRamdisk);

netboot = forTheseSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeNetboot {
netboot = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeNetboot {
inherit system;
modules = [
./modules/installer/netboot/netboot-minimal.nix
Expand All @@ -152,15 +151,15 @@ in rec {
inherit system;
});

iso_graphical = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
iso_graphical = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
module = ./modules/installer/cd-dvd/installation-cd-graphical-kde.nix;
type = "graphical";
inherit system;
});

# A variant with a more recent (but possibly less stable) kernel
# that might support more hardware.
iso_minimal_new_kernel = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
type = "minimal-new-kernel";
inherit system;
Expand All @@ -172,7 +171,7 @@ in rec {
});

# A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
ova = forTheseSystems [ "x86_64-linux" ] (system:
ova = forMatchingSystems [ "x86_64-linux" ] (system:

with import nixpkgs { inherit system; };

Expand Down Expand Up @@ -248,9 +247,9 @@ in rec {
tests.boot-stage1 = callTest tests/boot-stage1.nix {};
tests.borgbackup = callTest tests/borgbackup.nix {};
tests.buildbot = callTest tests/buildbot.nix {};
tests.cadvisor = callTestOnTheseSystems ["x86_64-linux"] tests/cadvisor.nix {};
tests.ceph = callTestOnTheseSystems ["x86_64-linux"] tests/ceph.nix {};
tests.chromium = (callSubTestsOnTheseSystems ["x86_64-linux"] tests/chromium.nix {}).stable or {};
tests.cadvisor = callTestOnMatchingSystems ["x86_64-linux"] tests/cadvisor.nix {};
tests.ceph = callTestOnMatchingSystems ["x86_64-linux"] tests/ceph.nix {};
tests.chromium = (callSubTestsOnMatchingSystems ["x86_64-linux"] tests/chromium.nix {}).stable or {};
tests.cjdns = callTest tests/cjdns.nix {};
tests.cloud-init = callTest tests/cloud-init.nix {};
tests.containers-ipv4 = callTest tests/containers-ipv4.nix {};
Expand All @@ -264,21 +263,21 @@ in rec {
tests.containers-hosts = callTest tests/containers-hosts.nix {};
tests.containers-macvlans = callTest tests/containers-macvlans.nix {};
tests.couchdb = callTest tests/couchdb.nix {};
tests.docker = callTestOnTheseSystems ["x86_64-linux"] tests/docker.nix {};
tests.docker-tools = callTestOnTheseSystems ["x86_64-linux"] tests/docker-tools.nix {};
tests.docker-edge = callTestOnTheseSystems ["x86_64-linux"] tests/docker-edge.nix {};
tests.docker = callTestOnMatchingSystems ["x86_64-linux"] tests/docker.nix {};
tests.docker-tools = callTestOnMatchingSystems ["x86_64-linux"] tests/docker-tools.nix {};
tests.docker-edge = callTestOnMatchingSystems ["x86_64-linux"] tests/docker-edge.nix {};
tests.dovecot = callTest tests/dovecot.nix {};
tests.dnscrypt-proxy = callTestOnTheseSystems ["x86_64-linux"] tests/dnscrypt-proxy.nix {};
tests.dnscrypt-proxy = callTestOnMatchingSystems ["x86_64-linux"] tests/dnscrypt-proxy.nix {};
tests.ecryptfs = callTest tests/ecryptfs.nix {};
tests.etcd = callTestOnTheseSystems ["x86_64-linux"] tests/etcd.nix {};
tests.ec2-nixops = (callSubTestsOnTheseSystems ["x86_64-linux"] tests/ec2.nix {}).boot-ec2-nixops or {};
tests.ec2-config = (callSubTestsOnTheseSystems ["x86_64-linux"] tests/ec2.nix {}).boot-ec2-config or {};
tests.elk = callSubTestsOnTheseSystems ["x86_64-linux"] tests/elk.nix {};
tests.etcd = callTestOnMatchingSystems ["x86_64-linux"] tests/etcd.nix {};
tests.ec2-nixops = (callSubTestsOnMatchingSystems ["x86_64-linux"] tests/ec2.nix {}).boot-ec2-nixops or {};
tests.ec2-config = (callSubTestsOnMatchingSystems ["x86_64-linux"] tests/ec2.nix {}).boot-ec2-config or {};
tests.elk = callSubTestsOnMatchingSystems ["x86_64-linux"] tests/elk.nix {};
tests.env = callTest tests/env.nix {};
tests.ferm = callTest tests/ferm.nix {};
tests.firefox = callTest tests/firefox.nix {};
tests.firewall = callTest tests/firewall.nix {};
tests.fleet = callTestOnTheseSystems ["x86_64-linux"] tests/fleet.nix {};
tests.fleet = callTestOnMatchingSystems ["x86_64-linux"] tests/fleet.nix {};
tests.fwupd = callTest tests/fwupd.nix {};
#tests.gitlab = callTest tests/gitlab.nix {};
tests.gitolite = callTest tests/gitolite.nix {};
Expand Down Expand Up @@ -311,7 +310,7 @@ in rec {
tests.kernel-copperhead = callTest tests/kernel-copperhead.nix {};
tests.kernel-latest = callTest tests/kernel-latest.nix {};
tests.kernel-lts = callTest tests/kernel-lts.nix {};
tests.kubernetes = callSubTestsOnTheseSystems ["x86_64-linux"] tests/kubernetes/default.nix {};
tests.kubernetes = callSubTestsOnMatchingSystems ["x86_64-linux"] tests/kubernetes/default.nix {};
tests.latestKernel.login = callTest tests/login.nix { latestKernel = true; };
tests.ldap = callTest tests/ldap.nix {};
#tests.lightdm = callTest tests/lightdm.nix {};
Expand Down Expand Up @@ -341,14 +340,14 @@ in rec {
tests.nginx = callTest tests/nginx.nix { };
tests.nghttpx = callTest tests/nghttpx.nix { };
tests.nix-ssh-serve = callTest tests/nix-ssh-serve.nix { };
tests.novacomd = callTestOnTheseSystems ["x86_64-linux"] tests/novacomd.nix { };
tests.novacomd = callTestOnMatchingSystems ["x86_64-linux"] tests/novacomd.nix { };
tests.leaps = callTest tests/leaps.nix { };
tests.nsd = callTest tests/nsd.nix {};
tests.openssh = callTest tests/openssh.nix {};
tests.openldap = callTest tests/openldap.nix {};
tests.owncloud = callTest tests/owncloud.nix {};
tests.pam-oath-login = callTest tests/pam-oath-login.nix {};
#tests.panamax = callTestOnTheseSystems ["x86_64-linux"] tests/panamax.nix {};
#tests.panamax = callTestOnMatchingSystems ["x86_64-linux"] tests/panamax.nix {};
tests.peerflix = callTest tests/peerflix.nix {};
tests.php-pcre = callTest tests/php-pcre.nix {};
tests.postgresql = callSubTests tests/postgresql.nix {};
Expand Down Expand Up @@ -382,7 +381,7 @@ in rec {
tests.tomcat = callTest tests/tomcat.nix {};
tests.udisks2 = callTest tests/udisks2.nix {};
tests.vault = callTest tests/vault.nix {};
tests.virtualbox = callSubTestsOnTheseSystems ["x86_64-linux"] tests/virtualbox.nix {};
tests.virtualbox = callSubTestsOnMatchingSystems ["x86_64-linux"] tests/virtualbox.nix {};
tests.wordpress = callTest tests/wordpress.nix {};
tests.xfce = callTest tests/xfce.nix {};
tests.xmonad = callTest tests/xmonad.nix {};
Expand Down
4 changes: 3 additions & 1 deletion pkgs/applications/graphics/ahoviewer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ stdenv.mkDerivation rec {
description = "A GTK2 image viewer, manga reader, and booru browser";
maintainers = with maintainers; [ skrzyp xzfc ];
license = licenses.mit;
platforms = platforms.allBut [ "darwin" "cygwin" ];
# Unintentionally not working on Darwin:
# https://github.com/ahodesuka/ahoviewer/issues/62
platforms = platforms.linux;
};
}

Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/misc/robo3t/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
mkdir -p $out/share/icons
cp ${icon} $out/share/icons/robomongo.png
patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2 $BASEDIR/bin/robo3t
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 $BASEDIR/bin/robo3t
mkdir $out/bin
Expand All @@ -70,7 +70,7 @@ stdenv.mkDerivation rec {
meta = {
homepage = https://robomongo.org/;
description = "Query GUI for mongodb";
platforms = stdenv.lib.intersectLists stdenv.lib.platforms.linux stdenv.lib.platforms.x86_64;
platforms = [ "x86_64-linux" ];
license = stdenv.lib.licenses.gpl3;
maintainers = [ stdenv.lib.maintainers.eperuffo ];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
fetchgit, fetchhg, fetchbzr, fetchsvn }:

let
isx86_64 = stdenv.lib.any (n: n == stdenv.system) stdenv.lib.platforms.x86_64;
gui = true; # Might be implemented with nixpkgs config.
in
buildGoPackage rec {
Expand All @@ -22,11 +21,11 @@ buildGoPackage rec {

nativeBuildInputs = [ pkgconfig ];
buildInputs = [ trousers gtk3 gtkspell3 ]
++ stdenv.lib.optional isx86_64 dclxvi
++ stdenv.lib.optional stdenv.hostPlatform.isx86_64 dclxvi
++ stdenv.lib.optionals gui [ wrapGAppsHook ];
buildFlags = stdenv.lib.optionalString (!gui) "-tags nogui";
excludedPackages = "\\(appengine\\|bn256cgo\\)";
postPatch = stdenv.lib.optionalString isx86_64 ''
postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isx86_64 ''
grep -r 'bn256' | awk -F: '{print $1}' | xargs sed -i \
-e "s,golang.org/x/crypto/bn256,github.com/agl/pond/bn256cgo,g" \
-e "s,bn256\.,bn256cgo.,g"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/window-managers/i3/lock-color.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ stdenv.mkDerivation rec {

# Needs the SSE2 instruction set. See upstream issue
# https://github.com/chrjguill/i3lock-color/issues/44
platforms = platforms.i686 ++ platforms.x86_64;
platforms = platforms.x86;
};
}
2 changes: 1 addition & 1 deletion pkgs/data/icons/numix-icon-theme-square/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
description = "Numix icon theme (square version)";
homepage = https://numixproject.org;
license = licenses.gpl3;
platforms = with platforms; allBut darwin;
platforms = platforms.linux; # Maybe other non-darwin Unix
maintainers = with maintainers; [ romildo ];
};
}
Loading

0 comments on commit 7060c52

Please sign in to comment.