mirror of
https://github.com/justinwoo/easy-dhall-nix.git
synced 2024-12-23 02:09:44 +01:00
Merge pull request #42 from Profpatsch/explicit-nixpkgs-imports
Explicit nixpkgs imports
This commit is contained in:
commit
da01add18b
15 changed files with 59 additions and 22 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -16,6 +16,4 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v12
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-20.09
|
||||
- run: ./test.sh
|
||||
|
|
|
@ -16,14 +16,14 @@ You might choose to simply copy the derivations from this repository, or you can
|
|||
|
||||
```
|
||||
> nix repl
|
||||
nix-repl> pkgs = import <nixpkgs> {}
|
||||
nix-repl> pkgs = import ./nixpkgs.nix {}
|
||||
|
||||
nix-repl> drvs = import (pkgs.fetchFromGitHub {
|
||||
owner = "justinwoo";
|
||||
repo = "easy-dhall-nix";
|
||||
rev = # some REV
|
||||
sha256 = # some SHA
|
||||
}) {}
|
||||
}) { inherit pkgs; }
|
||||
|
||||
nix-repl> drvs.dhall-simple
|
||||
«derivation /nix/store/qz29jbplpmlvsbmq05084dh1fbs8sl0h-dhall-simple.drv»
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
{
|
||||
dhall-simple = import ./dhall-simple.nix {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
|
||||
simpleName = "dhall-bash-simple";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
{ pkgs ? import ./nixpkgs.nix { } }:
|
||||
|
||||
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
|
||||
simpleName = "dhall-docs-simple";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
|
||||
simpleName = "dhall-json-simple";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
|
||||
simpleName = "dhall-lsp-simple";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
|
||||
simpleName = "dhall-nix-simple";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
|
||||
simpleName = "dhall-simple";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
|
||||
simpleName = "dhall-yaml-simple";
|
||||
|
|
31
fetch.py
31
fetch.py
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p python3 curl nix
|
||||
#!nix-shell -I nixpkgs=./nixpkgs.nix -i python3 -p python3 curl nix
|
||||
|
||||
import json
|
||||
import re
|
||||
|
@ -11,6 +11,29 @@ def curl_latest_release():
|
|||
url = "https://api.github.com/repos/dhall-lang/dhall-haskell/releases/latest"
|
||||
return json.loads(sub.check_output(["curl", url]))
|
||||
|
||||
# fetch the latest nixos unstable version
|
||||
def curl_latest_nixos_unstable():
|
||||
url = "https://nixos.org/channels/nixos-unstable/git-revision"
|
||||
return sub.check_output(["curl", "--location", url]).strip().decode()
|
||||
|
||||
def update_nixpkgs(lockfile_path, new_hash):
|
||||
# --unpack produces the hash required by `builtins.fetchTarball`
|
||||
github_archive = "https://github.com/NixOS/nixpkgs/archive/{}.tar.gz".format(new_hash)
|
||||
hash = sub.check_output([
|
||||
"nix-prefetch-url", '--unpack', github_archive
|
||||
]).strip().decode()
|
||||
date = sub.check_output([
|
||||
"date", "--iso-8601=minutes"
|
||||
]).strip().decode()
|
||||
with open(lockfile_path, 'w') as f:
|
||||
json.dump({
|
||||
"comment": "autogenerated by fetch.py",
|
||||
"url": github_archive,
|
||||
"sha256": hash,
|
||||
"date": date
|
||||
}, f, indent=2)
|
||||
|
||||
|
||||
# call nix-prefetch-url on each asset to get their hashes
|
||||
def prefetch_binaries(release):
|
||||
res = []
|
||||
|
@ -39,11 +62,17 @@ def postprocess(fetched):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("updating nixpkgs to latest unstable", file=sys.stderr)
|
||||
nixos_hash = curl_latest_nixos_unstable()
|
||||
update_nixpkgs("./nixpkgs.json", nixos_hash)
|
||||
|
||||
release = curl_latest_release()
|
||||
version = release['tag_name']
|
||||
|
||||
print("updating to release {}".format(version), file=sys.stderr)
|
||||
fetched = prefetch_binaries(release)
|
||||
res = postprocess(fetched)
|
||||
|
||||
print("writing ./release.json", file=sys.stderr)
|
||||
with open("./release.json", mode='w') as f:
|
||||
json.dump(res, f, indent=2)
|
||||
|
|
6
nixpkgs.json
Normal file
6
nixpkgs.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"comment": "autogenerated by fetch.py",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/24eb3f87fc610f18de7076aee7c5a84ac5591e3e.tar.gz",
|
||||
"sha256": "1ca14hhbinnz1ylbqnhwinjdbm6nn859j4gmyamg2kr7jl6611s0",
|
||||
"date": "2020-11-30T23:28+01:00"
|
||||
}
|
12
nixpkgs.nix
12
nixpkgs.nix
|
@ -1,6 +1,6 @@
|
|||
import (
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/nixos/nixpkgs/archive/a7bf8161fa834a602278c15fcbdd955656b3aed8.tar.gz";
|
||||
sha256 = "0lzd35niw0j8qy4mhglvqwv5qwyvdb9mhv8hpmn73ym57r92i4p1";
|
||||
}
|
||||
)
|
||||
import (fetchTarball {
|
||||
inherit (builtins.fromJSON (builtins.readFile ./nixpkgs.json))
|
||||
url
|
||||
sha256
|
||||
;
|
||||
})
|
||||
|
|
2
test.nix
2
test.nix
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nixpkgs.nix {} }:
|
||||
|
||||
let
|
||||
|
||||
|
|
8
test.sh
8
test.sh
|
@ -1,4 +1,8 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
test_script="$(nix-build ./test.nix)"
|
||||
exec "$test_script"
|
||||
tmp="$(mktemp -d)"
|
||||
trap "rm -r $tmp" EXIT
|
||||
nix-build \
|
||||
--out-link "$tmp"/result \
|
||||
./test.nix
|
||||
"$tmp/result"
|
||||
|
|
Loading…
Reference in a new issue