Skip to content

Commit 5126d9d

Browse files
committed
packet: add system expression
1 parent e49e9a9 commit 5126d9d

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

packet/default.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let
2+
fetcher = { owner, repo, rev, sha256, ... }: builtins.fetchTarball {
3+
inherit sha256;
4+
url = "https://github.com/${owner}/${repo}/tarball/${rev}";
5+
};
6+
nixpkgs = fetcher (builtins.fromJSON (builtins.readFile ./versions.json)).nixpkgs;
7+
nixos = import "${nixpkgs}/nixos" {
8+
configuration = import ./configuration.nix;
9+
};
10+
in
11+
nixos.system

packet/updater

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#! /usr/bin/env nix-shell
2+
#! nix-shell -i bash
3+
#! nix-shell -p curl jq nix
4+
5+
set -eufo pipefail
6+
7+
FILE=$1
8+
PROJECT=$2
9+
10+
OWNER=$(jq -r '.[$project].owner' --arg project "$PROJECT" < "$FILE")
11+
REPO=$(jq -r '.[$project].repo' --arg project "$PROJECT" < "$FILE")
12+
DEFAULT_BRANCH=$(jq -r '.[$project].branch // "master"' --arg project "$PROJECT" < "$FILE")
13+
14+
BRANCH=${3:-$DEFAULT_BRANCH}
15+
16+
REV=$(curl "https://api.github.com/repos/$OWNER/$REPO/branches/$BRANCH" | jq -r '.commit.sha')
17+
SHA256=$(nix-prefetch-url --unpack "https://github.com/$OWNER/$REPO/tarball/$REV")
18+
TJQ=$(jq '.[$project] = {owner: $owner, repo: $repo, branch: $branch, rev: $rev, sha256: $sha256}' \
19+
--arg project "$PROJECT" \
20+
--arg owner "$OWNER" \
21+
--arg repo "$REPO" \
22+
--arg branch "$BRANCH" \
23+
--arg rev "$REV" \
24+
--arg sha256 "$SHA256" \
25+
< "$FILE")
26+
[[ $? == 0 ]] && echo "${TJQ}" >| "$FILE"

packet/versions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"nixpkgs": {
3+
"owner": "NixOS",
4+
"repo": "nixpkgs-channels",
5+
"branch": "nixos-19.03",
6+
"rev": "77295b0bd26555c39a1ba9c1da72dbdb651fd280",
7+
"sha256": "18v866h12xk6l1s37nk1vns869pvzphmnnlhrnm2b1zklg2hd1nq"
8+
}
9+
}

0 commit comments

Comments
 (0)