Skip to content

Commit

Permalink
basic flake.nix support with lib.packs
Browse files Browse the repository at this point in the history
impure and sandbox options should be passed as:

$ nix build .#pkgs.zlib -L --impure --option sandbox false
  • Loading branch information
dguibert committed Jan 21, 2022
1 parent 646d0e6 commit b55c44d
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 4 deletions.
44 changes: 44 additions & 0 deletions flake.lock

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

120 changes: 120 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
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:dguibert/nixpkgs/pu-nixpack";

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;

};
}
26 changes: 22 additions & 4 deletions nixpkgs/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,37 @@ self: pkgs:
with pkgs;

{
coreutils = coreutils.overrideAttrs (old: {
doCheck = false; # failure test-getaddrinfo
});
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
});

coreutils = coreutils.overrideAttrs (old: {
doCheck = false; # df/total-verify broken on ceph
});

nix = (nix.override {
withAWS = false;
}).overrideAttrs (old: {
patches = [../patch/nix-ignore-fsea.patch];
doInstallCheck = false;
});

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

gtk3 = gtk3.override {
trackerSupport = false;
};
Expand All @@ -33,6 +47,10 @@ with pkgs;
'';
});

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

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
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.

0 comments on commit b55c44d

Please sign in to comment.