Skip to content

Commit 9f32b79

Browse files
committed
Use nix file to set nixpkgs version
This makes it easier to other nix derivations in the repo to use the same snapshot that's being used for deployments. Fixes #1
1 parent 9071a89 commit 9f32b79

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

manage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ command -v nix-shell >/dev/null 2>&1 || {
4949
fi
5050
}
5151

52-
here=$(dirname "$0")
52+
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
5353
repo_root=$(cd "$here" && git rev-parse --show-toplevel) # Use Git to find repo root.
5454

5555
deployment="$1"
@@ -83,4 +83,4 @@ elif [ -e "$state_file" ] && [ "$command" == "create" ]; then
8383
else
8484
ARGS=$(printf "%q"" " "${@:2}")
8585
$withNixops "nixops $ARGS"
86-
fi
86+
fi

nixpkgs-version.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Check out different Nixpkgs channels here:
2+
# * http://howoldis.herokuapp.com/
3+
# * https://nixos.org/channels/
4+
#
5+
# To upgrade:
6+
# 1. Choose a channel and click on it.
7+
# 2. Get the URL of the `nixexprs.tar.xz` file for the channel.
8+
# 4. Paste the URL below for `url`.
9+
# 5. Get SHA256 hash of URL contents with `nix-prefetch-url --unpack <url>`.
10+
11+
{
12+
url = "https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.03pre101896.4a524cf/nixexprs.tar.xz";
13+
sha256 = "1wrm9k0plpzz0wi94ry1xv1v3aq4vs20v5dzxv4azn4i8vhf7wmg";
14+
}

nixpkgs-version.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/env bash
2-
export nixpkgs_channel="https://nixos.org/channels/nixpkgs-unstable"
3-
export nixpkgs_snapshot="https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.03pre98765.6043569/nixexprs.tar.xz"
4-
export nixops_version="nixops" # Use the packaged nixops
2+
3+
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
4+
5+
nixpkgs_snapshot=$(eval echo "$(nix-instantiate --eval -E "(import \"$here/nixpkgs-version.nix\").url")")
6+
export nixpkgs_snapshot
7+
export nixops_version="nixops"
58

69
# Or you can use a more recent build of nixops:
710
#if [ "$(uname)" == "Darwin" ]; then

nixpkgs.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Import this instead of <nixpkgs> to get the repo-specific version of nixpkgs.
2+
3+
import ((import <nixpkgs> {}).fetchzip (import ./nixpkgs-version.nix))

0 commit comments

Comments
 (0)