Skip to content

Set operations on meta.platforms #52463

Closed

Description

@cyounkins

Is it possible to define meta.platforms using set operations? For example, mongodb should no longer be built on 32-bit platforms. Currently, platforms = platforms.unix. How can I effectively set platforms = platforms.unix - platforms.i686?

Activity

  1. joachifm commented on Dec 18, 2018

    @joachifm
    Contributor

    There are some set operations defined in lib, e.g. lib.subtractLists and lib.intersectLists.

  2. joachifm commented on Dec 18, 2018

    @joachifm
    Contributor

    For your specific case I think you'd do subtractLists platforms.i686 platforms.unix

  3. cyounkins commented on Dec 18, 2018

    @cyounkins
    ContributorAuthor

    Thank you @joachifm , I didn't see that! I guess those should be documented in https://nixos.org/nixpkgs/manual/#sec-functions-library . I don't think I'm qualified to do that though.

    Unfortunately I also cannot seem to get the result I need:

    nix-repl> stdenv = import <nixpkgs> {}
    
    nix-repl> b = stdenv.lib.subtractLists stdenv.lib.platforms.i686 stdenv.lib.platforms.unix
    
    nix-repl> builtins.trace b b
    trace: [ { kernel = { families = { bsd = <CODE>; }; }; } { kernel = { families = { darwin = <CODE>; }; }; } { kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "elf"; }; families = { }; name = "linux"; }; } { kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "elf"; }; families = { }; name = "solaris"; }; } { abi = { _type = "abi"; name = "cygnus"; }; kernel = <CODE>; } ]
    [ { ... } { ... } { ... } { ... } { ... } ]
    
    nix-repl> builtins.trace stdenv.lib.platforms.unix stdenv.lib.platforms.unix
    trace: [ { kernel = { families = { bsd = <CODE>; }; }; } { kernel = { families = { darwin = <CODE>; }; }; } { kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "elf"; }; families = { }; name = "linux"; }; } { kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "elf"; }; families = { }; name = "solaris"; }; } { abi = { _type = "abi"; name = "cygnus"; }; kernel = <CODE>; } ]
    [ { ... } { ... } { ... } { ... } { ... } ]
    
    nix-repl> :p b
    [ { kernel = { families = { bsd = { _type = "exec-format"; name = "bsd"; }; }; }; } { kernel = { families = { darwin = { _type = "exec-format"; name = "darwin"; }; }; }; } { kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "elf"; }; families = { }; name = "linux"; }; } { kernel = { _type = "kernel"; execFormat = «repeated»; families = { }; name = "solaris"; }; } { abi = { _type = "abi"; name = "cygnus"; }; kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "pe"; }; families = { }; name = "windows"; }; } ]
    
    nix-repl> :p stdenv.lib.platforms.unix
    [ { kernel = { families = { bsd = { _type = "exec-format"; name = "bsd"; }; }; }; } { kernel = { families = { darwin = { _type = "exec-format"; name = "darwin"; }; }; }; } { kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "elf"; }; families = { }; name = "linux"; }; } { kernel = { _type = "kernel"; execFormat = «repeated»; families = { }; name = "solaris"; }; } { abi = { _type = "abi"; name = "cygnus"; }; kernel = { _type = "kernel"; execFormat = { _type = "exec-format"; name = "pe"; }; families = { }; name = "windows"; }; } ]
    
    nix-repl> :p stdenv.lib.platforms.i686
    [ { cpu = { _type = "cpu-type"; bits = 32; family = "x86"; name = "i686"; significantByte = { _type = "significant-byte"; name = "littleEndian"; }; }; } ]
    
  4. joachifm commented on Dec 18, 2018

    @joachifm
    Contributor

    Ah, sorry, I didn't consider that platforms no longer is a simple set of strings ... obviously there won't be overlap between unix and i686 because they represent different aspects of a platform. lib.systems.doubles.unix and lib.systems.doubles.i686 are more like what I had in mind, as in

    nix-repl> lib.subtractLists lib.systems.doubles.i686 lib.systems.doubles.unix
    [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "mipsel-linux" "x86_64-cygwin" "x86_64-darwin" "x86_64-freebsd" "x86_64-linux" "x86_64-netbsd" "x86_64-openbsd" "x86_64-solaris" ]
    
  5. cyounkins commented on Dec 20, 2018

    @cyounkins
    ContributorAuthor

    Thank you again @joachifm!

  6. pbogdan commented on Dec 20, 2018

    @pbogdan
    Member

    Just wanted to mention there's (AFAIK undocumented) meta.badPlatforms attribute which may be suitable for this specific use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions