Skip to content

Commit

Permalink
Improve nix with thunk.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Sep 15, 2020
1 parent 91cb3d2 commit c41eb68
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 36 deletions.
29 changes: 11 additions & 18 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
{ pkgs ? import (builtins.fetchTarball { # 2020-02-13 (nixos-19.09)
url = "https://github.com/NixOS/nixpkgs/archive/e02fb6eaf70d4f6db37ce053edf79b731f13c838.tar.gz";
sha256 = "1dbjbak57vl7kcgpm1y1nm4s74gjfzpfgk33xskdxj9hjphi6mws";
}) {}
{ pkgsFun ? import (import ./nix/nixpkgs/thunk.nix)

, fetch ? { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
}

, rustOverlay ? import
"${fetch (builtins.fromJSON (builtins.readFile ./nix/nixpkgs-mozilla/github.json))}/rust-overlay.nix"
pkgs
pkgs
, rustOverlay ? import "${import ./nix/nixpkgs-mozilla/thunk.nix}/rust-overlay.nix"

# Rust manifest hash must be updated when rust-toolchain file changes.
, rustPackages ? rustOverlay.rustChannelOf {
, rustPackages ? pkgs.rustChannelOf {
date = "2020-05-04";
rustToolchain = ./rust-toolchain;
sha256 = "07mp7n4n3cmm37mv152frv7p9q58ahjw5k8gcq48vfczrgm5qgiy";
}

, gitignoreNix ? fetch (builtins.fromJSON (builtins.readFile ./nix/gitignore.nix/github.json))
, pkgs ? pkgsFun {
overlays = [
rustOverlay
];
}

, gitignoreNix ? import ./nix/gitignore.nix/thunk.nix

}:

Expand All @@ -40,5 +33,5 @@ in rustPlatform.buildRustPackage {
verifyCargoDeps = true;

# Cargo hash must be updated when Cargo.lock file changes.
cargoSha256 = "039bvmi7ai5zd3k46jfr1r82sfn84x4hg7c34sxsncwifd8p5yc6";
cargoSha256 = "12kkhbfcl5x2k3n73rfrza7zmjf67s943gbcnvy061l80r6jry2s";
}
8 changes: 1 addition & 7 deletions nix/gitignore.nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
in import (fetch (builtins.fromJSON (builtins.readFile ./github.json)))
import (import ./thunk.nix)
4 changes: 2 additions & 2 deletions nix/gitignore.nix/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"repo": "gitignore.nix",
"branch": "master",
"private": false,
"rev": "2ced4519f865341adcb143c5d668f955a2cb997f",
"sha256": "0fc5bgv9syfcblp23y05kkfnpgh3gssz6vn24frs8dzw39algk2z"
"rev": "c4662e662462e7bf3c2a968483478a665d00e717",
"sha256": "1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx"
}
9 changes: 9 additions & 0 deletions nix/gitignore.nix/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
8 changes: 1 addition & 7 deletions nix/nixpkgs-mozilla/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
in import (fetch (builtins.fromJSON (builtins.readFile ./github.json)))
import (import ./thunk.nix)
4 changes: 2 additions & 2 deletions nix/nixpkgs-mozilla/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"repo": "nixpkgs-mozilla",
"branch": "master",
"private": false,
"rev": "e912ed483e980dfb4666ae0ed17845c4220e5e7c",
"sha256": "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3"
"rev": "efda5b357451dbb0431f983cca679ae3cd9b9829",
"sha256": "11wqrg86g3qva67vnk81ynvqyfj0zxk83cbrf0p9hsvxiwxs8469"
}
9 changes: 9 additions & 0 deletions nix/nixpkgs-mozilla/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions nix/nixpkgs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions nix/nixpkgs/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "nixos",
"repo": "nixpkgs",
"branch": "nixos-20.03",
"private": false,
"rev": "252bfe0107587d40092057f338e9ffcf7bbd90cb",
"sha256": "1ljw98lcc04mlz6pprlgd1plinwl5q8fraakk6bx8igkiqlxaadn"
}
9 changes: 9 additions & 0 deletions nix/nixpkgs/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json

0 comments on commit c41eb68

Please sign in to comment.