Skip to content

Commit

Permalink
nix: Recreate from org
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Jan 8, 2019
1 parent e4e03a9 commit 83ff579
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 40 deletions.
28 changes: 9 additions & 19 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::finalNix][finalNix]]
# Nix skeleton for compiler, cmake, boost.
# Dependencies (boost and the rest) are built with selected compiler (for ABI compatibility).
# Examples:
# nix-shell --argstr compiler gcc5 --run 'mkdir build && cd build && cmake .. && cmake --build .'
# nix-shell --argstr compiler gcc6 --run 'mkdir build && cd build && cmake .. && cmake --build .'
# nix-shell --argstr compiler clang_38 --run 'mkdir build && cd build && cmake .. && cmake --build .'
{ nixpkgs ? import <nixpkgs> {}, compiler ? "clang" }:
let
stdenv = nixpkgs.overrideCC nixpkgs.stdenv nixpkgs.${compiler};
in rec {
myProject = stdenv.mkDerivation {
name = "supaaYoda";
version = "dev-0.1";
nativeBuildInputs = [ nixpkgs.boost nixpkgs.lua nixpkgs.cmake nixpkgs.luarocks nixpkgs.blas nixpkgs.conan nixpkgs.libyaml ];
buildInputs = [ ];
};
}
# finalNix ends here
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Project%20Root][Project Root:1]]
# Define
let
# Import
buildpkgs = import ./nix {};
in
# Pass to
buildpkgs.yodaStruct
# Project Root:1 ends here
14 changes: 7 additions & 7 deletions nix/catch.nix → nix/catch2.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Putting%20Things%20Together][Putting Things Together:3]]
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Catch2][Catch2:1]]
{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
name = "catch-${version}";
version = "2.1.2";
version = "2.5.0";

src = fetchurl {
url = "https://github.com/catchorg/Catch2/releases/download/v2.1.2/catch.hpp";
sha256 = "e8b8f3109716891aa99b1a8e29cd0d627419bdc4a8d2eeef0d8370aaf8d5e483";
url = "https://github.com/catchorg/Catch2/releases/download/v2.5.0/catch.hpp";
sha256 = "a87d5c0417aaf1c3d16565244a1b643e1999d5838d842823731bc18560268f94";
};

# It is just the file. No unpacking needed. Seems like we need to create
# This is a header only library. No unpacking needed. Seems like we need to create
# _some_ folder, otherwise we get errors.
unpackCmd = "mkdir dummy_dir";
unpackCmd = "mkdir fake_dir";

installPhase = ''
mkdir -p $out/include/catch
Expand All @@ -24,4 +24,4 @@ stdenv.mkDerivation rec {
homepage = http://catch-lib.net;
};
}
# Putting Things Together:3 ends here
# Catch2:1 ends here
25 changes: 25 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Project%20Source][Project Source:1]]
# Usage Example
# nix-shell --argstr compiler gcc5 --run bash
# nix-shell --argstr compiler clang --run bash
# something ? default value ---- Variable declration
# pattern : body ---- Function prototype
{ nixpkgs ? import ./nixpkgs
, compiler ? "clang"
}:
# Define
let overlay = self: buildpkgs: with buildpkgs; {
# All the other nix files
fetchJSON = import ./fetchJSON.nix { inherit (buildpkgs) fetchFromGitHub; };
# Package for testing
catch2 = callPackage ./catch2.nix {};
conan = callPackage ./pkgs/conan/conan.nix { };
# Program expression
yodaStruct = callPackage ./yodaStruct.nix {};
}; in
# Ensure reproducibility
nixpkgs {
config = {};
overlays = [overlay];
}
# Project Source:1 ends here
12 changes: 12 additions & 0 deletions nix/fetchJSON.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Helper%20Functions][Helper Functions:1]]
{ fetchFromGitHub }:

# fetches the source described in the <package>.src.json

# path to the .src.json
path:
let
data = builtins.fromJSON (builtins.readFile path);
in
fetchFromGitHub { inherit (data) owner repo rev sha256; }
# Helper Functions:1 ends here
14 changes: 0 additions & 14 deletions nix/luafilesystem.nix

This file was deleted.

4 changes: 4 additions & 0 deletions nix/nixBuilder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source $stdenv/setup
mkdir pureBuild && cd pureBuild
cmake -DCMAKE_BUILD_TYPE=Release
make
12 changes: 12 additions & 0 deletions nix/nixpkgs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Entry][Entry:1]]
# Define
let
spec = builtins.fromJSON (builtins.readFile ./default.src.json);
fetchTarball = import ./fetchTarball-compat.nix;
src = fetchTarball {
url = "https://github.com/${spec.owner}/${spec.repo}/archive/${spec.rev}.tar.gz";
sha256 = spec.sha256;
};
in
import src
# Entry:1 ends here
7 changes: 7 additions & 0 deletions nix/nixpkgs/default.src.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"owner": "NixOS",
"repo": "nixpkgs-channels",
"branch": "nixos-18.09",
"rev": "ae002fe44e96b868c62581e8066d559ca2179e01",
"sha256": "1bawyz3ksw2sihv6vsgbvhdm4kn63xrrj5bavg6mz5mxml9rji89"
}
11 changes: 11 additions & 0 deletions nix/nixpkgs/fetchTarball-compat.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Using%20the%20JSON][Using the JSON:2]]
# fetchTarball version that is compatible between all the versions of Nix
{ url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball { inherit url; }
else
fetchTarball attrs
# Using the JSON:2 ends here
73 changes: 73 additions & 0 deletions nix/pkgs/conan/conan.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Conan][Conan:3]]
{ lib, python3, fetchpatch, git }:

let newPython = python3.override {
packageOverrides = self: super: {
distro = super.distro.overridePythonAttrs (oldAttrs: rec {
version = "1.2.0";
src = oldAttrs.src.override {
inherit version;
sha256 = "1vn1db2akw98ybnpns92qi11v94hydwp130s8753k6ikby95883j";
};
});
node-semver = super.node-semver.overridePythonAttrs (oldAttrs: rec {
version = "0.2.0";
src = oldAttrs.src.override {
inherit version;
sha256 = "1080pdxrvnkr8i7b7bk0dfx6cwrkkzzfaranl7207q6rdybzqay3";
};
});
future = super.future.overridePythonAttrs (oldAttrs: rec {
version = "0.16.0";
src = oldAttrs.src.override {
inherit version;
sha256 = "1nzy1k4m9966sikp0qka7lirh8sqrsyainyf8rk97db7nwdfv773";
};
});
tqdm = super.tqdm.overridePythonAttrs (oldAttrs: rec {
version = "4.28.1";
src = oldAttrs.src.override {
inherit version;
sha256 = "1fyybgbmlr8ms32j7h76hz5g9xc6nf0644mwhc40a0s5k14makav";
};
});
};
};

in newPython.pkgs.buildPythonApplication rec {
version = "1.9.1";
pname = "conan";

src = newPython.pkgs.fetchPypi {
inherit pname version;
sha256 = "0mn69ps84w8kq76zba2gnlqlp855a6ksbl1l6pd1gkjlp9ry0hnf";
};
checkInputs = [
git
] ++ (with newPython.pkgs; [
nose
parameterized
mock
webtest
codecov
]);

propagatedBuildInputs = with newPython.pkgs; [
requests fasteners pyyaml pyjwt colorama patch
bottle pluginbase six distro pylint node-semver
future pygments mccabe deprecation tqdm
];

checkPhase = ''
export HOME="$TMP/conan-home"
mkdir -p "$HOME"
'';

meta = with lib; {
homepage = https://conan.io;
description = "Decentralized and portable C/C++ package manager";
license = licenses.mit;
platforms = platforms.linux;
};
}
# Conan:3 ends here
7 changes: 7 additions & 0 deletions nix/pkgs/conan/conan.src.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"owner": "conan-io",
"repo": "conan",
"branch": "release/1.9.1",
"rev": "bcb6080d98e7d4e5ed6fafdeb9f3e254c03123e4",
"sha256": "1bm1c43aswz69rvxp6z61gn310x9k77ixih64kprhdwwzqn1ja4c"
}
23 changes: 23 additions & 0 deletions nix/yodaStruct.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# [[file:~/Git/Github/C++/Forks/structureFactor/literateNix.org::*Expression][Expression:1]]
# Using patterns, and white space negligence
{ clangStdenv
, lua
, conan
, luaPackages
, lib
, boost
, cmake }:
clangStdenv.mkDerivation {
name = "yodaStruct";
src = lib.cleanSource ../.;
nativeBuildInputs = [
cmake
lua
conan
];
buildInputs = [
boost
luaPackages.luafilesystem
];
}
# Expression:1 ends here

0 comments on commit 83ff579

Please sign in to comment.