mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-08-16 22:20:34 +03:00
build: remove haskell related nix code and haskell.nix dependency
* Upgrades the nixpkgs pin to 21.11. * Removes nix code, sources, and attributes related to haskell.nix and the code under pkg/hs. * Continuous integration no longer builds (or packages/releases) urbit-king (haskell). * To continue to developing any haskell code under pkg/hs it's left as a user exercise uto install and configure GHC/Stack. As a consequence running nix-shell should be considerably more performant and requires downloading or building less dependencies.
This commit is contained in:
parent
1ffdad8719
commit
16379db9b0
24
.github/workflows/build.yml
vendored
24
.github/workflows/build.yml
vendored
@ -39,7 +39,6 @@ on:
|
||||
- 'pkg/docker-image/**'
|
||||
- 'pkg/ent/**'
|
||||
- 'pkg/ge-additions/**'
|
||||
- 'pkg/hs/**'
|
||||
- 'pkg/libaes_siv/**'
|
||||
- 'pkg/urbit/**'
|
||||
- 'bin/**'
|
||||
@ -50,7 +49,6 @@ on:
|
||||
- 'pkg/docker-image/**'
|
||||
- 'pkg/ent/**'
|
||||
- 'pkg/ge-additions/**'
|
||||
- 'pkg/hs/**'
|
||||
- 'pkg/libaes_siv/**'
|
||||
- 'pkg/urbit/**'
|
||||
- 'bin/**'
|
||||
@ -95,28 +93,6 @@ jobs:
|
||||
- if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: nix-build -A docker-image
|
||||
|
||||
haskell:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-latest }
|
||||
- { os: macos-latest }
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v13
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: ares
|
||||
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||
|
||||
- run: nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true
|
||||
- run: nix-build -A hs-checks
|
||||
- run: nix-build shell.nix
|
||||
|
||||
mingw:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
|
29
default.nix
29
default.nix
@ -14,10 +14,6 @@
|
||||
$ nix-build -A urbit --argstr crossSystem x86_64-unknown-linux-musl \
|
||||
--arg enableStatic true
|
||||
|
||||
Static urbit-king binary:
|
||||
|
||||
$ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true
|
||||
|
||||
Static release tarball:
|
||||
|
||||
$ nix-build -A tarball --arg enableStatic true
|
||||
@ -28,15 +24,6 @@
|
||||
$ nix-build -A brass.build
|
||||
$ nix-build -A solid.build
|
||||
|
||||
Run the king-haskell checks (.tests are _build_ the test code, .checks _runs_):
|
||||
|
||||
$ nix-build -A hs.urbit-king.checks.urbit-king-tests
|
||||
|
||||
Build a specific Haskell package from ./pkg/hs:
|
||||
|
||||
$ nix-build -A hs.urbit-noun.components.library
|
||||
$ nix-build -A hs.urbit-atom.components.benchmarks.urbit-atom-bench
|
||||
$ nix-build -A hs.urbit-atom.components.tests.urbit-atom-tests
|
||||
*/
|
||||
|
||||
# The build system where packages will be _built_.
|
||||
@ -52,7 +39,7 @@
|
||||
# Overlays to apply to the last package set in cross compilation.
|
||||
, crossOverlays ? [ ]
|
||||
# Whether to use pkgs.pkgsStatic.* to obtain statically linked package
|
||||
# dependencies - ie. when building fully-static libraries or executables.
|
||||
# dependencies - ie. when building fully-static libraries or executables.
|
||||
, enableStatic ? false }:
|
||||
|
||||
let
|
||||
@ -76,7 +63,7 @@ let
|
||||
|
||||
# Enrich the global package set with our local functions and packages.
|
||||
# Cross vs static build dependencies can be selectively overridden for
|
||||
# inputs like python and haskell-nix
|
||||
# inputs like python etc.
|
||||
callPackage =
|
||||
pkgsNative.lib.callPackageWith (pkgsStatic // libLocal // pkgsLocal);
|
||||
|
||||
@ -113,11 +100,6 @@ let
|
||||
urcrypt = callPackage ./nix/pkgs/urcrypt { inherit enableStatic; };
|
||||
|
||||
docker-image = callPackage ./nix/pkgs/docker-image { };
|
||||
|
||||
hs = callPackage ./nix/pkgs/hs {
|
||||
inherit enableStatic;
|
||||
inherit (pkgsCross) haskell-nix;
|
||||
};
|
||||
};
|
||||
|
||||
# Additional top-level packages and attributes exposed for convenience.
|
||||
@ -125,11 +107,6 @@ let
|
||||
# Expose packages with local customisations (like patches) for dev access.
|
||||
inherit (pkgsCross) libsigsegv;
|
||||
|
||||
# Collect haskell check (aka "run the tests") attributes so we can run every
|
||||
# test for our local haskell packages, similar to the urbit-tests attribute.
|
||||
hs-checks = (pkgsNative.recurseIntoAttrs
|
||||
(libLocal.collectHaskellComponents pkgsLocal.hs)).checks;
|
||||
|
||||
urbit-debug = urbit.override { enableDebug = true; };
|
||||
urbit-tests = libLocal.testFakeShip {
|
||||
inherit herb;
|
||||
@ -145,14 +122,12 @@ let
|
||||
# Create a .tgz of the primary binaries.
|
||||
tarball = let
|
||||
name = "urbit-v${urbit.version}-${urbit.system}";
|
||||
urbit-king = hs.urbit-king.components.exes.urbit-king;
|
||||
in libLocal.makeReleaseTarball {
|
||||
inherit name;
|
||||
|
||||
contents = {
|
||||
"${name}/urbit" = "${urbit}/bin/urbit";
|
||||
"${name}/urbit-worker" = "${urbit}/bin/urbit-worker";
|
||||
"${name}/urbit-king" = "${urbit-king}/bin/urbit-king";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -13,42 +13,19 @@
|
||||
|
||||
let
|
||||
|
||||
sourcesFinal = import ./sources.nix { inherit pkgs; } // sources;
|
||||
finalSources = import ./sources.nix { } // sources;
|
||||
|
||||
haskellNix = import sourcesFinal."haskell.nix" {
|
||||
sourcesOverride = {
|
||||
hackage = sourcesFinal."hackage.nix";
|
||||
stackage = sourcesFinal."stackage.nix";
|
||||
};
|
||||
};
|
||||
pkgs = import finalSources.nixpkgs {
|
||||
inherit system config crossSystem crossOverlays;
|
||||
|
||||
configFinal = haskellNix.config // config;
|
||||
|
||||
overlaysFinal = haskellNix.overlays ++ [
|
||||
(_final: prev: {
|
||||
# Add top-level .sources attribute for other overlays to access sources.
|
||||
sources = sourcesFinal;
|
||||
|
||||
# Additional non-convential package/exe mappings for shellFor.tools.
|
||||
haskell-nix = prev.haskell-nix // {
|
||||
toolPackageName = prev.haskell-nix.toolPackageName // {
|
||||
shellcheck = "ShellCheck";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
# General unguarded (native) overrides for nixpkgs.
|
||||
(import ./overlays/native.nix)
|
||||
|
||||
# Specific overrides guarded by the host platform.
|
||||
(import ./overlays/musl.nix)
|
||||
] ++ overlays;
|
||||
|
||||
pkgs = import sourcesFinal.nixpkgs {
|
||||
inherit system crossSystem crossOverlays;
|
||||
|
||||
config = configFinal;
|
||||
overlays = overlaysFinal;
|
||||
overlays = [
|
||||
# Make prev.sources available to subsequent overlays.
|
||||
(_final: _prev: { sources = finalSources; })
|
||||
# General unguarded (native) overrides for nixpkgs.
|
||||
(import ./overlays/native.nix)
|
||||
# Specific overrides guarded by the host platform.
|
||||
(import ./overlays/musl.nix)
|
||||
];
|
||||
};
|
||||
|
||||
in pkgs // {
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Functions that are expected run on the native (non-cross) system.
|
||||
|
||||
{ lib, recurseIntoAttrs, haskell-nix, callPackage }:
|
||||
{ callPackage }:
|
||||
|
||||
rec {
|
||||
bootFakeShip = callPackage ./boot-fake-ship.nix { };
|
||||
@ -10,28 +10,4 @@ rec {
|
||||
fetchGitHubLFS = callPackage ./fetch-github-lfs.nix { };
|
||||
|
||||
makeReleaseTarball = callPackage ./make-release-tarball.nix { };
|
||||
|
||||
collectHaskellComponents = project:
|
||||
let
|
||||
|
||||
# These functions pull out from the Haskell project either all the
|
||||
# components of a particular type, or all the checks.
|
||||
|
||||
pkgs = haskell-nix.haskellLib.selectProjectPackages project;
|
||||
|
||||
collectChecks = _:
|
||||
recurseIntoAttrs (builtins.mapAttrs (_: p: p.checks) pkgs);
|
||||
|
||||
collectComponents = type:
|
||||
haskell-nix.haskellLib.collectComponents' type pkgs;
|
||||
|
||||
# Recompute the Haskell package set sliced by component type
|
||||
in builtins.mapAttrs (type: f: f type) {
|
||||
# These names must match the subcomponent: components.<name>.<...>
|
||||
"library" = collectComponents;
|
||||
"tests" = collectComponents;
|
||||
"benchmarks" = collectComponents;
|
||||
"exes" = collectComponents;
|
||||
"checks" = collectChecks;
|
||||
};
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ let
|
||||
"''${curl[@]}" -s --output "$out" "$href"
|
||||
'';
|
||||
|
||||
impureEnvVars = stdenvNoCC.lib.fetchers.proxyImpureEnvVars;
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
||||
|
||||
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
|
||||
|
@ -23,7 +23,7 @@ in {
|
||||
];
|
||||
});
|
||||
|
||||
curlMinimal = prev.curl.override {
|
||||
curlUrbit = prev.curlMinimal.override {
|
||||
http2Support = false;
|
||||
scpSupport = false;
|
||||
gssSupport = false;
|
||||
|
@ -16,7 +16,7 @@ let
|
||||
in {
|
||||
gmp = enableStatic prev.gmp;
|
||||
|
||||
curlMinimal = enableStatic prev.curlMinimal;
|
||||
curlUrbit = enableStatic prev.curlUrbit;
|
||||
|
||||
libuv = enableStatic prev.libuv;
|
||||
|
||||
|
@ -18,7 +18,7 @@ stdenvNoCC.mkDerivation {
|
||||
phases = [ "installPhase" "fixupPhase" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/bin
|
||||
cp $src $out/bin/herb
|
||||
chmod +x $out/bin/herb
|
||||
'';
|
||||
|
@ -1,90 +0,0 @@
|
||||
{ lib, stdenv, darwin, haskell-nix, lmdb, gmp, zlib, libffi, brass
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic }:
|
||||
|
||||
haskell-nix.stackProject {
|
||||
compiler-nix-name = "ghc884";
|
||||
index-state = "2020-09-24T00:00:00Z";
|
||||
|
||||
# This is incredibly difficult to get right, almost everything goes wrong.
|
||||
# See: https://github.com/input-output-hk/haskell.nix/issues/496
|
||||
src = haskell-nix.haskellLib.cleanSourceWith {
|
||||
# Otherwise this depends on the name in the parent directory, which
|
||||
# reduces caching, and is particularly bad on Hercules.
|
||||
# See: https://github.com/hercules-ci/support/issues/40
|
||||
name = "urbit-hs";
|
||||
src = ../../../pkg/hs;
|
||||
};
|
||||
|
||||
modules = [{
|
||||
# This corresponds to the set of packages (boot libs) that ship with GHC.
|
||||
# We declare them yere to ensure any dependency gets them from GHC itself
|
||||
# rather than trying to re-install them into the package database.
|
||||
nonReinstallablePkgs = [
|
||||
"Cabal"
|
||||
"Win32"
|
||||
"array"
|
||||
"base"
|
||||
"binary"
|
||||
"bytestring"
|
||||
"containers"
|
||||
"deepseq"
|
||||
"directory"
|
||||
"filepath"
|
||||
"ghc"
|
||||
"ghc-boot"
|
||||
"ghc-boot-th"
|
||||
"ghc-compact"
|
||||
"ghc-heap"
|
||||
"ghc-prim"
|
||||
"ghci"
|
||||
"ghcjs-prim"
|
||||
"ghcjs-th"
|
||||
"haskeline"
|
||||
"hpc"
|
||||
"integer-gmp"
|
||||
"integer-simple"
|
||||
"mtl"
|
||||
"parsec"
|
||||
"pretty"
|
||||
"process"
|
||||
"rts"
|
||||
"stm"
|
||||
"template-haskell"
|
||||
"terminfo"
|
||||
"text"
|
||||
"time"
|
||||
"transformers"
|
||||
"unix"
|
||||
"xhtml"
|
||||
];
|
||||
|
||||
# Override various project-local flags and build configuration.
|
||||
packages = {
|
||||
urbit-king.components.exes.urbit-king = {
|
||||
enableStatic = enableStatic;
|
||||
enableShared = !enableStatic;
|
||||
|
||||
configureFlags = lib.optionals enableStatic [
|
||||
"--ghc-option=-optl=-L${lmdb}/lib"
|
||||
"--ghc-option=-optl=-L${gmp}/lib"
|
||||
"--ghc-option=-optl=-L${libffi}/lib"
|
||||
"--ghc-option=-optl=-L${zlib}/lib"
|
||||
] ++ lib.optionals (enableStatic && stdenv.isDarwin)
|
||||
[ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ];
|
||||
|
||||
postInstall = lib.optionalString (enableStatic && stdenv.isDarwin) ''
|
||||
find "$out/bin" -type f -exec \
|
||||
install_name_tool -change \
|
||||
${stdenv.cc.libc}/lib/libSystem.B.dylib \
|
||||
/usr/lib/libSystem.B.dylib {} \;
|
||||
'';
|
||||
};
|
||||
|
||||
urbit-king.components.tests.urbit-king-tests.testFlags =
|
||||
[ "--brass-pill=${brass.lfs}" ];
|
||||
|
||||
lmdb.components.library.libs = lib.mkForce [ lmdb ];
|
||||
};
|
||||
}];
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ lib, stdenv, coreutils, pkgconfig # build/env
|
||||
, cacert, ca-bundle, ivory # codegen
|
||||
, curlMinimal, ent, gmp, h2o, libsigsegv, libuv, lmdb # libs
|
||||
, curlUrbit, ent, gmp, h2o, libsigsegv, libuv, lmdb # libs
|
||||
, murmur3, openssl, softfloat3, urcrypt, zlib #
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic # opts
|
||||
, enableDebug ? false
|
||||
@ -25,7 +25,7 @@ in stdenv.mkDerivation {
|
||||
buildInputs = [
|
||||
cacert
|
||||
ca-bundle
|
||||
curlMinimal
|
||||
curlUrbit
|
||||
ent
|
||||
gmp
|
||||
h2o
|
||||
|
120
nix/sources.json
120
nix/sources.json
@ -3,17 +3,17 @@
|
||||
"branch": "master",
|
||||
"description": "H2O - the optimized HTTP/1, HTTP/2, HTTP/3 server",
|
||||
"homepage": "https://h2o.examp1e.net",
|
||||
"pmnsh": {
|
||||
"include": "include",
|
||||
"prepare": "cmake .",
|
||||
"make": "libh2o",
|
||||
"compat": {
|
||||
"mingw": {
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=. ."
|
||||
}
|
||||
}
|
||||
},
|
||||
"owner": "h2o",
|
||||
"pmnsh": {
|
||||
"compat": {
|
||||
"mingw": {
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=. ."
|
||||
}
|
||||
},
|
||||
"include": "include",
|
||||
"make": "libh2o",
|
||||
"prepare": "cmake ."
|
||||
},
|
||||
"repo": "h2o",
|
||||
"rev": "v2.2.6",
|
||||
"sha256": "0qni676wqvxx0sl0pw9j0ph7zf2krrzqc1zwj73mgpdnsr8rsib7",
|
||||
@ -21,47 +21,23 @@
|
||||
"url": "https://github.com/h2o/h2o/archive/v2.2.6.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"hackage.nix": {
|
||||
"branch": "master",
|
||||
"description": "Automatically generated Nix expressions for Hackage",
|
||||
"homepage": "",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "hackage.nix",
|
||||
"rev": "ed4d2759c9e6ca8133a4170f99fabdd76f30f51a",
|
||||
"sha256": "1n5fk8zsxnbca96zk4ikh74iz3lzh35m302q65zk1rx3nmy4027d",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/hackage.nix/archive/ed4d2759c9e6ca8133a4170f99fabdd76f30f51a.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"haskell.nix": {
|
||||
"branch": "master",
|
||||
"description": "Alternative Haskell Infrastructure for Nixpkgs",
|
||||
"homepage": "https://input-output-hk.github.io/haskell.nix",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "haskell.nix",
|
||||
"rev": "bbb34dcdf7b90d478002f91713531f418ddf1b53",
|
||||
"sha256": "1qq397j8vnlp5npk8r675fzjfimg74fcvrkxcdgx7vj48315bh2w",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/bbb34dcdf7b90d478002f91713531f418ddf1b53.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"libaes_siv": {
|
||||
"branch": "master",
|
||||
"description": null,
|
||||
"homepage": null,
|
||||
"owner": "dfoxfranke",
|
||||
"pmnsh": {
|
||||
"compat": {
|
||||
"m1brew": {
|
||||
"prepare": "cmake .",
|
||||
"make": "install CFLAGS=$(pkg-config --cflags openssl)"
|
||||
"make": "install CFLAGS=$(pkg-config --cflags openssl)",
|
||||
"prepare": "cmake ."
|
||||
},
|
||||
"mingw": {
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DDISABLE_DOCS:BOOL=ON .",
|
||||
"make": "aes_siv_static"
|
||||
"make": "aes_siv_static",
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DDISABLE_DOCS:BOOL=ON ."
|
||||
}
|
||||
}
|
||||
},
|
||||
"owner":"dfoxfranke",
|
||||
"repo": "libaes_siv",
|
||||
"rev": "9681279cfaa6e6399bb7ca3afbbc27fc2e19df4b",
|
||||
"sha256": "1g4wy0m5wpqx7z6nillppkh5zki9fkx9rdw149qcxh7mc5vlszzi",
|
||||
@ -73,10 +49,10 @@
|
||||
"branch": "master",
|
||||
"description": null,
|
||||
"homepage": null,
|
||||
"owner": "urbit",
|
||||
"pmnsh": {
|
||||
"make": "static"
|
||||
},
|
||||
"owner": "urbit",
|
||||
"repo": "murmur3",
|
||||
"rev": "71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca",
|
||||
"sha256": "0k7jq2nb4ad9ajkr6wc4w2yy2f2hkwm3nkbj2pklqgwsg6flxzwg",
|
||||
@ -99,21 +75,39 @@
|
||||
"nixpkgs": {
|
||||
"branch": "master",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": null,
|
||||
"owner": "nixos",
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "166ab9d237409c4b74b1f8ca31476ead35e8fe53",
|
||||
"sha256": "13i43kvbkdl3dh8b986j6mxbn355mqjhcxrd8cni8zfx1z0wrscr",
|
||||
"rev": "21.11",
|
||||
"sha256": "162dywda2dvfj1248afxc45kcrg83appjd0nmdb541hl7rnncf02",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nixpkgs/archive/166ab9d237409c4b74b1f8ca31476ead35e8fe53.tar.gz",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/21.11.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"secp256k1": {
|
||||
"branch": "master",
|
||||
"description": "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.",
|
||||
"homepage": null,
|
||||
"owner": "bitcoin-core",
|
||||
"pmnsh": {
|
||||
"include": "include",
|
||||
"lib": ".libs",
|
||||
"make": "libsecp256k1.la",
|
||||
"prepare": "./autogen.sh && ./configure --disable-shared --enable-module-recovery CFLAGS=-DSECP256K1_API="
|
||||
},
|
||||
"repo": "secp256k1",
|
||||
"rev": "26de4dfeb1f1436dae1fcf17f57bdaa43540f940",
|
||||
"sha256": "03i3nv8d3ci7q9y98q11rrp3rvwdqc0hc0ss0pr6xckybvizsmbb",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/bitcoin-core/secp256k1/archive/26de4dfeb1f1436dae1fcf17f57bdaa43540f940.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"softfloat3": {
|
||||
"branch": "master",
|
||||
"description": null,
|
||||
"homepage": null,
|
||||
"owner": "urbit",
|
||||
"pmnsh": {
|
||||
"include": "source/include",
|
||||
"compat": {
|
||||
"m1brew": {
|
||||
"lib": "build/template-FAST_INT64",
|
||||
@ -123,44 +117,14 @@
|
||||
"lib": "build/Win64-MinGW-w64",
|
||||
"make": "-C build/Win64-MinGW-w64 libsoftfloat3.a"
|
||||
}
|
||||
}
|
||||
},
|
||||
"include": "source/include"
|
||||
},
|
||||
"owner": "urbit",
|
||||
"repo": "berkeley-softfloat-3",
|
||||
"rev": "ec4c7e31b32e07aad80e52f65ff46ac6d6aad986",
|
||||
"sha256": "1lz4bazbf7lns1xh8aam19c814a4n4czq5xsq5rmi9sgqw910339",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/urbit/berkeley-softfloat-3/archive/ec4c7e31b32e07aad80e52f65ff46ac6d6aad986.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"secp256k1": {
|
||||
"branch": "master",
|
||||
"description": "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.",
|
||||
"homepage": null,
|
||||
"pmnsh": {
|
||||
"include": "include",
|
||||
"lib": ".libs",
|
||||
"prepare": "./autogen.sh && ./configure --disable-shared --enable-module-recovery CFLAGS=-DSECP256K1_API=",
|
||||
"make": "libsecp256k1.la"
|
||||
},
|
||||
"owner": "bitcoin-core",
|
||||
"repo": "secp256k1",
|
||||
"rev": "26de4dfeb1f1436dae1fcf17f57bdaa43540f940",
|
||||
"sha256": "03i3nv8d3ci7q9y98q11rrp3rvwdqc0hc0ss0pr6xckybvizsmbb",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/bitcoin-core/secp256k1/archive/26de4dfeb1f1436dae1fcf17f57bdaa43540f940.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"stackage.nix": {
|
||||
"branch": "master",
|
||||
"description": "Automatically generated Nix expressions of Stackage snapshots",
|
||||
"homepage": "",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "stackage.nix",
|
||||
"rev": "08312f475f4f5f3b6578e7a78dc501de6fea8792",
|
||||
"sha256": "15j1l6616kfv7351jxwgb9kj6y8227fcm87nxwabmbn1q6a8q2kf",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/stackage.nix/archive/08312f475f4f5f3b6578e7a78dc501de6fea8792.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
210
nix/sources.nix
210
nix/sources.nix
@ -6,149 +6,169 @@ let
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
||||
fetch_file = pkgs: name: spec:
|
||||
let
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
||||
|
||||
fetch_tarball = pkgs: name: spec:
|
||||
let
|
||||
ok = str: !builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
|
||||
# sanitize the name, though nix will still fail if name starts with period
|
||||
name' = stringAsChars (x: if !ok x then "-" else x) "${name}-src";
|
||||
in if spec.builtin or true then
|
||||
builtins_fetchTarball {
|
||||
name = name';
|
||||
inherit (spec) url sha256;
|
||||
}
|
||||
else
|
||||
pkgs.fetchzip {
|
||||
name = name';
|
||||
inherit (spec) url sha256;
|
||||
};
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = spec:
|
||||
builtins.fetchGit {
|
||||
url = spec.repo;
|
||||
inherit (spec) rev ref;
|
||||
};
|
||||
fetch_git = name: spec:
|
||||
let
|
||||
ref =
|
||||
if spec ? ref then spec.ref else
|
||||
if spec ? branch then "refs/heads/${spec.branch}" else
|
||||
if spec ? tag then "refs/tags/${spec.tag}" else
|
||||
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
||||
in
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
||||
|
||||
fetch_local = spec: spec.path;
|
||||
|
||||
fetch_builtin-tarball = name:
|
||||
throw ''
|
||||
[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||
fetch_builtin-tarball = name: throw
|
||||
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||
|
||||
fetch_builtin-url = name:
|
||||
throw ''
|
||||
[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||
fetch_builtin-url = name: throw
|
||||
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
||||
sanitizeName = name:
|
||||
(
|
||||
concatMapStrings (s: if builtins.isList s then "-" else s)
|
||||
(
|
||||
builtins.split "[^[:alnum:]+._?=-]+"
|
||||
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
||||
)
|
||||
);
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources:
|
||||
mkPkgs = sources: system:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; })
|
||||
{ };
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in if builtins.hasAttr "nixpkgs" sources then
|
||||
sourcesNixpkgs
|
||||
else if hasNixpkgsPath && !hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> { }
|
||||
else
|
||||
abort ''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> {}
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if !builtins.hasAttr "type" spec then
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then
|
||||
fetch_file pkgs spec
|
||||
else if spec.type == "tarball" then
|
||||
fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then
|
||||
fetch_git spec
|
||||
else if spec.type == "local" then
|
||||
fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then
|
||||
fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then
|
||||
fetch_builtin-url name
|
||||
else if spec.type == "file" then fetch_file pkgs name spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then fetch_git name spec
|
||||
else if spec.type == "local" then fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||
else
|
||||
abort
|
||||
"ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
||||
# the path directly as opposed to the fetched source.
|
||||
replace = name: drv:
|
||||
let
|
||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||
in
|
||||
if ersatz == "" then drv else
|
||||
# this turns the string into an actual Nix path (for both absolute and
|
||||
# relative paths)
|
||||
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (f: set:
|
||||
with builtins;
|
||||
listToAttrs (map (attr: {
|
||||
name = attr;
|
||||
value = f attr set.${attr};
|
||||
}) (attrNames set)));
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||
range = first: last:
|
||||
if first > last then
|
||||
[ ]
|
||||
else
|
||||
builtins.genList (n: first + n) (last - first + 1);
|
||||
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
||||
stringToCharacters = s:
|
||||
map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||
concatMapStrings = f: list: concatStrings (map f list);
|
||||
concatStrings = builtins.concatStringsSep "";
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
||||
optionalAttrs = cond: as: if cond then as else {};
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, name, sha256 }@attrs:
|
||||
let inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit name url; }
|
||||
else
|
||||
fetchTarball attrs;
|
||||
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, sha256 }@attrs:
|
||||
let inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in if lessThan nixVersion "1.12" then
|
||||
fetchurl { inherit url; }
|
||||
else
|
||||
fetchurl attrs;
|
||||
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs (name: spec:
|
||||
if builtins.hasAttr "outPath" spec then
|
||||
abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = fetch config.pkgs name spec; }) config.sources;
|
||||
mapAttrs (
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
||||
) config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig = { sourcesFile ? ./sources.json
|
||||
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, pkgs ? mkPkgs sources }: rec {
|
||||
mkConfig =
|
||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, system ? builtins.currentSystem
|
||||
, pkgs ? mkPkgs sources system
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
in mkSources (mkConfig { }) // {
|
||||
__functor = _: settings: mkSources (mkConfig settings);
|
||||
}
|
||||
|
||||
in
|
||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
||||
|
@ -1 +0,0 @@
|
||||
import ../../shell.nix
|
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Usage: fmt-haskell
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cd "${0%/*}/.."
|
||||
|
||||
echo "Formatting Haskell"
|
||||
|
||||
# FIXME: Avoid inplace (-i) modifications for now.
|
||||
find pkg/hs -type f -name '*.hs' \
|
||||
-exec ormolu --mode check \
|
||||
-o '-XBangPatterns' \
|
||||
-o '-XMagicHash' \
|
||||
-o '-XTypeApplications' \
|
||||
-o '-XPatternSynonyms' \
|
||||
{} \+
|
@ -9,4 +9,4 @@ cd "${0%/*}/.."
|
||||
echo "Formatting Nix"
|
||||
|
||||
find . -type f -name '*.nix' \
|
||||
-exec nixfmt {} \+
|
||||
-exec nixpkgs-fmt {} \+
|
||||
|
37
shell.nix
37
shell.nix
@ -1,5 +1,5 @@
|
||||
# A repository wide shell.nix containing all tools, formatters, and inputs
|
||||
# required to build any of the C or Haskell packages.
|
||||
# required to build any of the C packages.
|
||||
#
|
||||
# Entering a nix-shell using this derivation will allow you to cd anywhere
|
||||
# in the ./pkg directory and run the appropriate build tooling.
|
||||
@ -14,48 +14,25 @@ let
|
||||
|
||||
pkgsLocal = import ./default.nix { };
|
||||
|
||||
# The non-Haskell packages which build inputs (dependencies) will be
|
||||
# propagated into the shell. This combines nixpkgs' mkShell behaviour
|
||||
# with Haskell.nix's shellFor.
|
||||
# The packages from which build inputs (dependencies) will be propagated into
|
||||
# the shell.
|
||||
#
|
||||
# For example, adding urbit here results in gmp, h2o, zlib, etc. being
|
||||
# made available, so you can just run make.
|
||||
#
|
||||
#
|
||||
# Typically the inputs listed here also have a shell.nix in their respective
|
||||
# source directory you can use, to avoid the Haskell/GHC dependencies.
|
||||
# source directory you can use directly.
|
||||
inputsFrom = with pkgsLocal; [ ent herb urbit urcrypt ];
|
||||
|
||||
# Collect the named attribute from all dependencies listed in inputsFrom.
|
||||
mergeFrom = name: pkgs.lib.concatLists (pkgs.lib.catAttrs name inputsFrom);
|
||||
|
||||
in pkgsLocal.hs.shellFor {
|
||||
# Haskell packages from the stackProject which will have their
|
||||
# dependencies available in the shell.
|
||||
packages = ps:
|
||||
with ps; [
|
||||
racquire
|
||||
terminal-progress-bar
|
||||
urbit-atom
|
||||
urbit-azimuth
|
||||
urbit-eventlog-lmdb
|
||||
urbit-king
|
||||
urbit-noun
|
||||
urbit-noun-core
|
||||
urbit-termsize
|
||||
];
|
||||
|
||||
# Haskell tools to make available on the shell's PATH.
|
||||
tools = {
|
||||
shellcheck = "0.7.1";
|
||||
ormolu = "0.1.3.0";
|
||||
};
|
||||
|
||||
in pkgs.mkShell {
|
||||
# Nixpkgs tools to make available on the shell's PATH.
|
||||
buildInputs = [
|
||||
pkgs.cacert
|
||||
pkgs.nixfmt
|
||||
pkgs.nixpkgs-fmt
|
||||
pkgs.shfmt
|
||||
pkgs.stack
|
||||
(import pkgs.sources.niv { }).niv
|
||||
] ++ mergeFrom "buildInputs";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user