Add 'shell.nix' for local development

As part of this I created a new files `./nixpkgs` that obtains a
specific version of the nixpkgs repo. This code was previously spread
between `release.nix` and `fetchNixpkgs.nix`. I also removed the Nix
1.11 code to simplify things. If we need Nix 1.11 support we can add it
again.
This commit is contained in:
Thomas Scholtes 2018-07-16 19:57:10 +02:00
parent 6e56cd699c
commit dbbd53ba50
No known key found for this signature in database
GPG Key ID: C5BC340BAB556015
4 changed files with 25 additions and 62 deletions

View File

@ -1,50 +0,0 @@
{ rev # The Git revision of nixpkgs to fetch
, sha256 # The SHA256 of the downloaded data
, outputSha256 ? null # The SHA256 fixed-output hash
, system ? builtins.currentSystem # This is overridable if necessary
}:
if (0 <= builtins.compareVersions builtins.nixVersion "1.12")
# In Nix 1.12, we can just give a `sha256` to `builtins.fetchTarball`.
then (
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
sha256 = outputSha256;
})
# This hack should at least work for Nix 1.11
else (
(rec {
tarball = import <nix/fetchurl.nix> {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;
};
builtin-paths = import <nix/config.nix>;
script = builtins.toFile "nixpkgs-unpacker" ''
"$coreutils/mkdir" "$out"
cd "$out"
"$gzip" --decompress < "$tarball" | "$tar" -x --strip-components=1
'';
nixpkgs = builtins.derivation ({
name = "nixpkgs-${builtins.substring 0 6 rev}";
builder = builtins.storePath builtin-paths.shell;
args = [ script ];
inherit tarball system;
tar = builtins.storePath builtin-paths.tar;
gzip = builtins.storePath builtin-paths.gzip;
coreutils = builtins.storePath builtin-paths.coreutils;
} // (if null == outputSha256 then { } else {
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = outputSha256;
}));
}).nixpkgs)

10
nixpkgs.nix Normal file
View File

@ -0,0 +1,10 @@
let
rev = "c5f9cd4cde81bcef2c8882d359d9d30313bebeb3";
outputSha256 = "1nilhz6rhfg3ckp8yfmgy6v3q6spbyxfg0yn8rc2ydyn7119h4fn";
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
sha256 = outputSha256;
};
in
import nixpkgs {}

View File

@ -1,15 +1,5 @@
let
fetchNixpkgs = import ./fetchNixpkgs.nix;
nixpkgs = fetchNixpkgs {
rev = "c5f9cd4cde81bcef2c8882d359d9d30313bebeb3";
sha256 = "12w6g50hgk5nmijgs3rv7kq5mdybnkyv3cr2zm0q3ka9ax180dk6";
outputSha256 = "1nilhz6rhfg3ckp8yfmgy6v3q6spbyxfg0yn8rc2ydyn7119h4fn";
};
pkgs = import nixpkgs {};
pkgs = import ./nixpkgs.nix;
dhall-kubernetes-smoketests =
pkgs.runCommand
@ -42,4 +32,3 @@ in
];
};
}

14
shell.nix Normal file
View File

@ -0,0 +1,14 @@
let
pkgs = import ./nixpkgs.nix;
in
pkgs.stdenv.mkDerivation {
name = "dhall-kubernetes-shell";
buildInputs = [
pkgs.git
pkgs.dhall
pkgs.dhall-json
pkgs.python3
pkgs.python3Packages.requests
pkgs.glibcLocales
];
}