This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pin haskell.nix and iohk-nix using niv
- Loading branch information
1 parent
93bfeb8
commit d0cc2e6
Showing
5 changed files
with
230 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"gitignore": { | ||
"branch": "master", | ||
"description": "Nix function for filtering local git sources", | ||
"homepage": "", | ||
"owner": "hercules-ci", | ||
"repo": "gitignore", | ||
"rev": "f9e996052b5af4032fe6150bba4a6fe4f7b9d698", | ||
"sha256": "0jrh5ghisaqdd0vldbywags20m2cxpkbbk5jjjmwaw0gr8nhsafv", | ||
"type": "tarball", | ||
"url": "https://github.com/hercules-ci/gitignore/archive/f9e996052b5af4032fe6150bba4a6fe4f7b9d698.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": "3ae2303b14bdebd00437b0e995af2d0eb21abafe", | ||
"sha256": "0dk6541kwfyc5sp5h1vfk6zl4ghln4i2zqkaijbjwv8bnixnm6wl", | ||
"type": "tarball", | ||
"url": "https://github.com/input-output-hk/haskell.nix/archive/3ae2303b14bdebd00437b0e995af2d0eb21abafe.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" | ||
}, | ||
"iohk-nix": { | ||
"branch": "master", | ||
"description": "nix scripts shared across projects", | ||
"homepage": null, | ||
"owner": "input-output-hk", | ||
"repo": "iohk-nix", | ||
"rev": "f854c957a65295639d2062867552b65c7dc227a6", | ||
"sha256": "1jl07ng2nx6lgj9rrqzl242r263505llzzxb592fn81h0dq6jx1r", | ||
"type": "tarball", | ||
"url": "https://github.com/input-output-hk/iohk-nix/archive/f854c957a65295639d2062867552b65c7dc227a6.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" | ||
}, | ||
"niv": { | ||
"branch": "iohk", | ||
"description": "Easy dependency management for Nix projects", | ||
"homepage": "https://github.com/nmattia/niv", | ||
"owner": "input-output-hk", | ||
"repo": "niv", | ||
"rev": "c25268460b72cea5b7294354ab019997530a6f3d", | ||
"sha256": "1fgq1nkycm54f431h6wflh6rr7xsq3q2fq9drbgra2fnrsyn65ll", | ||
"type": "tarball", | ||
"url": "https://github.com/input-output-hk/niv/archive/c25268460b72cea5b7294354ab019997530a6f3d.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" | ||
}, | ||
"nixpkgs": { | ||
"branch": "iohk-19.03", | ||
"description": "Nix Packages collection", | ||
"homepage": null, | ||
"owner": "input-output-hk", | ||
"repo": "nixpkgs", | ||
"rev": "5bd4c4ea6804b54683ef2b802d970ae473e1b658", | ||
"sha256": "12gah6y1lkkgvvdgswyzsqyvxvsvljn61vpy606sy37yfgkc1a63", | ||
"type": "tarball", | ||
"url": "https://github.com/input-output-hk/nixpkgs/archive/5bd4c4ea6804b54683ef2b802d970ae473e1b658.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# This file has been generated by Niv. | ||
|
||
# A record, from name to path, of the third-party packages | ||
with rec | ||
{ | ||
pkgs = | ||
if hasNixpkgsPath | ||
then | ||
if hasThisAsNixpkgsPath | ||
then import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {} | ||
else import <nixpkgs> {} | ||
else | ||
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}; | ||
|
||
sources_nixpkgs = | ||
if builtins.hasAttr "nixpkgs" sources | ||
then sources.nixpkgs | ||
else abort | ||
'' | ||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or | ||
add a package called "nixpkgs" to your sources.json. | ||
''; | ||
|
||
sources_gitignore = | ||
if builtins.hasAttr "gitignore" sources | ||
then sources.gitignore | ||
else abort | ||
'' | ||
Please add "gitignore" to your sources.json: | ||
niv add hercules-ci/gitignore | ||
''; | ||
|
||
inherit (import (builtins_fetchTarball { inherit (sources_gitignore) url sha256; }) { | ||
inherit (pkgs) lib; | ||
}) gitignoreSource; | ||
|
||
# fetchTarball version that is compatible between all the versions of Nix | ||
builtins_fetchTarball = | ||
{ url, sha256 ? null }@attrs: | ||
let | ||
inherit (builtins) lessThan nixVersion fetchTarball; | ||
in | ||
if sha256 == null || lessThan nixVersion "1.12" then | ||
fetchTarball { inherit url; } | ||
else | ||
fetchTarball attrs; | ||
|
||
# fetchurl version that is compatible between all the versions of Nix | ||
builtins_fetchurl = | ||
{ url, sha256 ? null }@attrs: | ||
let | ||
inherit (builtins) lessThan nixVersion fetchurl; | ||
in | ||
if sha256 == null || lessThan nixVersion "1.12" then | ||
fetchurl { inherit url; } | ||
else | ||
fetchurl attrs; | ||
|
||
# A wrapper around pkgs.fetchzip that has inspectable arguments, | ||
# annoyingly this means we have to specify them | ||
fetchzip = { url, sha256 ? null }@attrs: if sha256 == null | ||
then builtins.fetchTarball { inherit url; } | ||
else pkgs.fetchzip attrs; | ||
|
||
# A wrapper around pkgs.fetchurl that has inspectable arguments, | ||
# annoyingly this means we have to specify them | ||
fetchurl = { url, sha256 }@attrs: pkgs.fetchurl attrs; | ||
|
||
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success; | ||
hasThisAsNixpkgsPath = | ||
(builtins.tryEval <nixpkgs>).success && <nixpkgs> == ./.; | ||
|
||
sources = builtins.fromJSON (builtins.readFile ./sources.json); | ||
|
||
mapAttrs = builtins.mapAttrs or | ||
(f: set: with builtins; | ||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))); | ||
|
||
# borrowed from nixpkgs | ||
functionArgs = f: f.__functionArgs or (builtins.functionArgs f); | ||
callFunctionWith = autoArgs: f: args: | ||
let auto = builtins.intersectAttrs (functionArgs f) autoArgs; | ||
in f (auto // args); | ||
|
||
getFetcher = spec: | ||
let fetcherName = | ||
if builtins.hasAttr "type" spec | ||
then builtins.getAttr "type" spec | ||
else "builtin-tarball"; | ||
in builtins.getAttr fetcherName { | ||
"tarball" = fetchzip; | ||
"builtin-tarball" = builtins_fetchTarball; | ||
"file" = fetchurl; | ||
"builtin-url" = builtins_fetchurl; | ||
}; | ||
}; | ||
# NOTE: spec must _not_ have an "outPath" attribute | ||
mapAttrs (name: spec: | ||
if builtins.hasAttr "outPath" spec | ||
then abort | ||
"The values in sources.json should not have an 'outPath' attribute" | ||
else | ||
let | ||
host = if (name == "nixpkgs") then "custom_nixpkgs" else name; | ||
tryFromPath = builtins.tryEval (builtins.findFile builtins.nixPath host); | ||
defaultSpec = (if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec | ||
then spec // | ||
{ outPath = callFunctionWith spec (getFetcher spec) { }; } | ||
else spec) // (if tryFromPath.success | ||
then let path = tryFromPath.value; | ||
in { | ||
outPath = builtins.trace "using search host <${host}>" ( | ||
if pkgs.lib.hasPrefix "/nix/store" (builtins.toString path) | ||
then path else gitignoreSource path); | ||
} | ||
else {}); | ||
in if builtins.hasAttr "rev" spec && builtins.hasAttr "url" spec then | ||
defaultSpec // | ||
{ revOverride = rev: if (rev == null) then defaultSpec else | ||
let | ||
spec' = removeAttrs (spec // { | ||
rev = rev; | ||
url = builtins.replaceStrings [defaultSpec.rev] [rev] defaultSpec.url; | ||
}) [ "sha256" ]; | ||
in | ||
spec' // | ||
{ outPath = callFunctionWith spec' (getFetcher spec') { }; }; | ||
} | ||
else defaultSpec | ||
) sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
#!/usr/bin/env nix-shell | ||
#!nix-shell -i bash -p nix-prefetch-git | ||
|
||
set -euo pipefail | ||
|
||
NIX_DIR=$(dirname "$0") | ||
|
||
nix-prefetch-git https://github.com/input-output-hk/iohk-nix refs/heads/haskell-nix-cardano-sl \ | ||
> "$NIX_DIR/iohk-nix-src.json" | ||
#!nix-shell -A devops ../shell.nix -i bash | ||
niv update iohk-nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ localLib ? import ./lib.nix | ||
}: | ||
let | ||
pkgs = localLib.iohkNix.pkgs; | ||
default = import ./default.nix {}; | ||
devops = pkgs.stdenv.mkDerivation { | ||
name = "devops-shell"; | ||
buildInputs = [ | ||
localLib.niv | ||
]; | ||
shellHook = '' | ||
echo "DevOps Tools" \ | ||
| ${pkgs.figlet}/bin/figlet -f banner -c \ | ||
| ${pkgs.lolcat}/bin/lolcat | ||
echo "NOTE: you may need to export GITHUB_TOKEN if you hit rate limits with niv" | ||
echo "Commands: | ||
* niv update <package> - update package | ||
" | ||
''; | ||
}; | ||
in { inherit devops; } |