Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake support #8

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
description = "Flake for NixPACK";

inputs.spack = { url="github:spack/spack"; flake=false; };
#inputs.spack = { url="github:flatironinstitute/spack/fi-nixpack"; flake=false; };
inputs.nixpkgs.url = "github:NixOS/nixpkgs";

outputs = inputs: let
nixpkgsFor = system: import inputs.nixpkgs {
inherit system;
config = {
replaceStdenv = import ./nixpkgs/stdenv.nix;
allowUnfree = true;
cudaSupport = true;
};
overlays = [(import ./nixpkgs/overlay.nix)];
};

nixosPacks = system: let
pkgs = nixpkgsFor system;
gccWithFortran = pkgs.wrapCC (pkgs.gcc.cc.override {
langFortran = true;
});
in inputs.self.lib.packs {
inherit system;
os = "nixos21";
global.verbose = "true";
spackConfig.config.source_cache="/tmp/spack_cache";
spackPython = "${pkgs.python3}/bin/python3";
spackEnv = {
# pure environment PATH
PATH=/*"/run/current-system/sw/bin:"
+*/inputs.nixpkgs.lib.concatStringsSep ":"
(builtins.map (x: "${x}/bin")
[
pkgs.bash
pkgs.coreutils
pkgs.gnumake
pkgs.gnutar
pkgs.gzip
pkgs.bzip2
pkgs.xz
pkgs.gawk
pkgs.gnused
pkgs.gnugrep
pkgs.glib
pkgs.binutils.bintools # glib: locale
pkgs.patch
pkgs.texinfo
pkgs.diffutils
pkgs.pkgconfig
pkgs.gitMinimal
pkgs.findutils
]);
#PATH="/run/current-system/sw/bin:${pkgs.gnumake}/bin:${pkgs.binutils.bintools}/bin";
LOCALE_ARCHIVE="/run/current-system/sw/lib/locale/locale-archive";
LIBRARY_PATH=/*"/run/current-system/sw/bin:"
+*/inputs.nixpkgs.lib.concatStringsSep ":"
(builtins.map (x: "${x}/lib")
[
(inputs.nixpkgs.lib.getLib pkgs.binutils.bintools) # ucx (configure fails) libbfd not found
]);
};

package = {
compiler = { name="gcc"; extern=gccWithFortran; version=gccWithFortran.version; };
perl = { extern=pkgs.perl; version=pkgs.perl.version; };
openssh = { extern=pkgs.openssh; version=pkgs.openssh.version; };
openssl = { extern=pkgs.symlinkJoin { name="openssl"; paths = [ pkgs.openssl.all ]; }; version=pkgs.openssl.version; };
openmpi = {
version = "4.1";
variants = {
fabrics = {
none = false;
ucx = true;
};
schedulers = {
none = false;
slurm = false;
};
pmi = false;
pmix = false;
static = false;
thread_multiple = true;
legacylaunchers = true;
};
};
};
repoPatch = {
dyninst = spec: old: {
patches = [ ./patch/dyninst-nixos.patch ];
};
openmpi = spec: old: {
build = {
setup = ''
configure_args = pkg.configure_args()
if spec.satisfies("~pmix"):
if '--without-mpix' in configure_args: configure_args.remove('--without-pmix')
pkg.configure_args = lambda: configure_args
'';
};
};
};
};
in {
lib = (import packs/lib.nix) // {
packs = {
...
}@args: import ./packs ({
inherit (inputs) spack nixpkgs;
} // args);
};

packages.x86_64-linux = nixosPacks "x86_64-linux";

defaultPackage.x86_64-linux = inputs.self.packages.x86_64-linux.hello;

};
}
11 changes: 4 additions & 7 deletions nixpkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{ system ? builtins.currentSystem
, target ? builtins.head (builtins.split "-" system)
, src ? {}
, nixpkgs
, overlays ? []
}:

let

nixpkgs = fetchGit ({
url = "https://github.com/NixOS/nixpkgs";
ref = "master";
} // src);
# gcc arch is x64-64
target_ = builtins.replaceStrings ["x86_64"] ["x86-64"] target;

args = {
localSystem = {
inherit system;
gcc = { arch = target; };
gcc = { arch = target_; };
};
config = {
replaceStdenv = import ./stdenv.nix;
Expand Down
90 changes: 90 additions & 0 deletions nixpkgs/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,32 @@ self: pkgs:
with pkgs;

{
gnutls = gnutls.overrideAttrs (old: {
doCheck = false; # failure test-getaddrinfo
});
libgpg-error = libgpg-error.overrideAttrs (old: {
doCheck = false; # failure FAIL: t-argparse 1.42
});
p11-kit = p11-kit.overrideAttrs (old: {
doCheck = false; # failure ERROR: test-path - missing test plan
});

nss_sss = callPackage sssd/nss-client.nix { };

libuv = libuv.overrideAttrs (old: {
doCheck = false; # failure
});

libffi = libffi.overrideAttrs (old: {
doCheck = false; # failure
});

coreutils = (coreutils.override {
autoreconfHook = null; # workaround nixpkgs #144747
}).overrideAttrs (old: {
preBuild = "touch Makefile.in"; # avoid automake
doCheck = false; # df/total-verify broken on ceph
# failure test-getaddrinfo
});

nix = (nix.override {
Expand All @@ -22,10 +37,84 @@ with pkgs;
doInstallCheck = false;
});

# `fetchurl' downloads a file from the network.
fetchurl = if stdenv.buildPlatform != stdenv.hostPlatform
then buildPackages.fetchurl # No need to do special overrides twice,
else makeOverridable (import (pkgs.path + "/pkgs/build-support/fetchurl")) {
inherit lib stdenvNoCC buildPackages;
inherit cacert;
curl = buildPackages.curlMinimal.override (old: rec {
# break dependency cycles
fetchurl = stdenv.fetchurlBoot;
zlib = buildPackages.zlib.override { fetchurl = stdenv.fetchurlBoot; };
pkg-config = buildPackages.pkg-config.override (old: {
pkg-config = old.pkg-config.override {
fetchurl = stdenv.fetchurlBoot;
};
});
perl = buildPackages.perl.override { fetchurl = stdenv.fetchurlBoot; inherit zlib; };
openssl = buildPackages.openssl.override {
fetchurl = stdenv.fetchurlBoot;
buildPackages = {
coreutils = (buildPackages.coreutils.override rec {
fetchurl = stdenv.fetchurlBoot;
inherit perl;
xz = buildPackages.xz.override { fetchurl = stdenv.fetchurlBoot; };
gmp = null;
aclSupport = false;
attrSupport = false;
autoreconfHook = null; # workaround nixpkgs #144747
texinfo = null;
}).overrideAttrs (_: {
preBuild = "touch Makefile.in"; # avoid automake
});
inherit perl;
};
inherit perl;
};
libssh2 = buildPackages.libssh2.override {
fetchurl = stdenv.fetchurlBoot;
inherit zlib openssl;
};
# On darwin, libkrb5 needs bootstrap_cmds which would require
# converting many packages to fetchurl_boot to avoid evaluation cycles.
# So turn gssSupport off there, and on Windows.
# On other platforms, keep the previous value.
gssSupport =
if stdenv.isDarwin || stdenv.hostPlatform.isWindows
then false
else old.gssSupport or true; # `? true` is the default
libkrb5 = buildPackages.libkrb5.override {
fetchurl = stdenv.fetchurlBoot;
inherit pkg-config perl openssl;
keyutils = buildPackages.keyutils.override { fetchurl = stdenv.fetchurlBoot; };
};
nghttp2 = buildPackages.nghttp2.override {
fetchurl = stdenv.fetchurlBoot;
inherit pkg-config;
enableApp = false; # curl just needs libnghttp2
enableTests = false; # avoids bringing `cunit` and `tzdata` into scope
};
});
}; git = git.overrideAttrs (old: {
doCheck = false; # failure
doInstallCheck = false; # failure
});

gtk3 = gtk3.override {
trackerSupport = false;
};

autogen = autogen.overrideAttrs (old: {
postInstall = old.postInstall + ''
# remove $TMPDIR/** from RPATHs
for f in "$bin"/bin/*; do
local nrp="$(patchelf --print-rpath "$f" | sed -E 's@(:|^)'$TMPDIR'[^:]*:@\1@g')"
patchelf --set-rpath "$nrp" "$f"
done
'';
});

openssl_1_0_2 = openssl_1_0_2.overrideAttrs (old: {
postPatch = old.postPatch + ''
sed -i 's:define\s\+X509_CERT_FILE\s\+.*$:define X509_CERT_FILE "/etc/pki/tls/certs/ca-bundle.crt":' crypto/cryptlib.h
Expand Down Expand Up @@ -57,3 +146,4 @@ with pkgs;
"-DEMBREE_ISA_SSE42=OFF"];
});
}

19 changes: 12 additions & 7 deletions packs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ prefsUpdate = let
os = scalar;
label = a: b: "${a}.${b}";
spackSrc = scalar;
spack = scalar;
spackConfig = lib.recursiveUpdate;
spackPython = scalar;
spackEnv = a: b: a // b;
nixpkgsSrc = scalar;
nixpkgs = scalar;
verbose = scalar;
repoPatch = a: b: a // b;
global = lib.prefsUpdate;
Expand All @@ -72,18 +74,24 @@ prefsUpdate = let

spackTarget = builtins.replaceStrings ["-"] ["_"];

packsWithPrefs =
packsWithPrefs =
{ system ? builtins.currentSystem
, os ? "unknown"
, label ? "packs"
, spackSrc ? {}
, spack ? if builtins.isString spackSrc then spackSrc else
builtins.fetchGit ({ name = "spack"; url = "git://github.com/spack/spack"; } // spackSrc)
, spackConfig ? {}
, spackPython ? "/usr/bin/python3"
, spackEnv ? {
PATH = "/bin:/usr/bin";
}
, nixpkgsSrc ? null
, nixpkgsOverlays ? []
, nixpkgs ? fetchGit ({
url = "git://github.com/NixOS/nixpkgs";
ref = "master";
} // nixpkgsSrc)
, repos ? [ ../spack/repo ]
, repoPatch ? {}
, global ? {}
Expand All @@ -99,12 +107,9 @@ lib.fix (packs: with packs; {
withPrefs = p: packsWithPrefs (prefsUpdate packPrefs
({ label = "withPrefs"; } // p));

spack = if builtins.isString spackSrc then spackSrc else
builtins.fetchGit ({ name = "spack"; url = "https://github.com/spack/spack"; } // spackSrc);

makeSpackConfig = import ../spack/config.nix packs;

inherit spackPython spackEnv;
inherit spack spackPython spackEnv;
spackConfig = makeSpackConfig (lib.recursiveUpdate defaultSpackConfig packPrefs.spackConfig);

spackNixLib = derivation (spackEnv // {
Expand Down Expand Up @@ -401,11 +406,11 @@ lib.fix (packs: with packs; {
/* a runnable (if only partly functional) spack binary */
spackBin = import ../spack/bin.nix packs;

nixpkgs = lib.when (nixpkgsSrc != null)
nixpkgs = lib.when (nixpkgs != null)
(import ../nixpkgs {
inherit system;
target = global.target or target;
src = nixpkgsSrc;
inherit nixpkgs;
overlays = nixpkgsOverlays;
});
});
Expand Down
20 changes: 20 additions & 0 deletions patch/dyninst-nixos.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/scripts/dynsysname b/scripts/dynsysname
index 6906fb224..ce385e046 100755
--- a/scripts/dynsysname
+++ b/scripts/dynsysname
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash

P=$1

diff --git a/scripts/sysname b/scripts/sysname
index 16f540483..dccd3e677 100755
--- a/scripts/sysname
+++ b/scripts/sysname
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# $Id: sysname,v 1.6 2005/08/09 16:13:16 gquinn Exp $
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.