Skip to content
Permalink
Browse files

packet: add system expression

  • Loading branch information...
vaibhavsagar committed Aug 20, 2019
1 parent e49e9a9 commit 5126d9dba971d6480aeec43c4263c5a7f7b1f1b5
Showing with 46 additions and 0 deletions.
  1. +11 −0 packet/default.nix
  2. +26 −0 packet/updater
  3. +9 −0 packet/versions.json
@@ -0,0 +1,11 @@
let
fetcher = { owner, repo, rev, sha256, ... }: builtins.fetchTarball {
inherit sha256;
url = "https://github.com/${owner}/${repo}/tarball/${rev}";
};
nixpkgs = fetcher (builtins.fromJSON (builtins.readFile ./versions.json)).nixpkgs;
nixos = import "${nixpkgs}/nixos" {
configuration = import ./configuration.nix;
};
in
nixos.system
@@ -0,0 +1,26 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash
#! nix-shell -p curl jq nix

set -eufo pipefail

FILE=$1
PROJECT=$2

OWNER=$(jq -r '.[$project].owner' --arg project "$PROJECT" < "$FILE")
REPO=$(jq -r '.[$project].repo' --arg project "$PROJECT" < "$FILE")
DEFAULT_BRANCH=$(jq -r '.[$project].branch // "master"' --arg project "$PROJECT" < "$FILE")

BRANCH=${3:-$DEFAULT_BRANCH}

REV=$(curl "https://api.github.com/repos/$OWNER/$REPO/branches/$BRANCH" | jq -r '.commit.sha')
SHA256=$(nix-prefetch-url --unpack "https://github.com/$OWNER/$REPO/tarball/$REV")
TJQ=$(jq '.[$project] = {owner: $owner, repo: $repo, branch: $branch, rev: $rev, sha256: $sha256}' \
--arg project "$PROJECT" \
--arg owner "$OWNER" \
--arg repo "$REPO" \
--arg branch "$BRANCH" \
--arg rev "$REV" \
--arg sha256 "$SHA256" \
< "$FILE")
[[ $? == 0 ]] && echo "${TJQ}" >| "$FILE"
@@ -0,0 +1,9 @@
{
"nixpkgs": {
"owner": "NixOS",
"repo": "nixpkgs-channels",
"branch": "nixos-19.03",
"rev": "77295b0bd26555c39a1ba9c1da72dbdb651fd280",
"sha256": "18v866h12xk6l1s37nk1vns869pvzphmnnlhrnm2b1zklg2hd1nq"
}
}

0 comments on commit 5126d9d

Please sign in to comment.
You can’t perform that action at this time.