warp-terminal-overlay #10
6 changed files with 112 additions and 10 deletions
|
@ -5,8 +5,7 @@ let
|
|||
in
|
||||
{
|
||||
options.mySystem.system = {
|
||||
packages = mkOption
|
||||
{
|
||||
packages = mkOption {
|
||||
type = with types; listOf package;
|
||||
description = "List of system level package installs";
|
||||
default = [ ];
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
{ inputs
|
||||
, ...
|
||||
}:
|
||||
{ inputs, ... }:
|
||||
let
|
||||
warpTerminal = import ./warp-terminal/warp-terminal.nix {
|
||||
inherit (inputs.nixpkgs) lib;
|
||||
};
|
||||
in
|
||||
{
|
||||
nur = inputs.nur.overlay;
|
||||
warp-terminal = warpTerminal;
|
||||
|
||||
# The unstable nixpkgs set (declared in the flake inputs) will
|
||||
# be accessible through 'pkgs.unstable'
|
||||
# great idea if I wasn't using unstable as my base.
|
||||
|
|
74
nixos/overlays/warp-terminal/update.sh
Executable file
74
nixos/overlays/warp-terminal/update.sh
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p cacert curl jq nix moreutils --pure
|
||||
#shellcheck shell=bash
|
||||
set -eu -o pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
nixpkgs=$(nix-instantiate --eval -E '<nixpkgs>' --impure)
|
||||
|
||||
err() {
|
||||
echo "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
json_get() {
|
||||
jq -r "$1" < "./versions.json"
|
||||
}
|
||||
|
||||
json_set() {
|
||||
jq --arg x "$2" "$1 = \$x" < "./versions.json" | sponge "./versions.json"
|
||||
}
|
||||
|
||||
resolve_url() {
|
||||
local pkg sfx url
|
||||
local -i i max_redirects
|
||||
case "$1" in
|
||||
darwin)
|
||||
pkg=macos
|
||||
sfx=dmg
|
||||
;;
|
||||
linux)
|
||||
pkg=pacman
|
||||
sfx=pkg.tar.zst
|
||||
;;
|
||||
*)
|
||||
err "Unexpected download type: $1"
|
||||
;;
|
||||
esac
|
||||
url="https://app.warp.dev/download?package=${pkg}"
|
||||
((max_redirects = 15))
|
||||
for ((i = 0; i < max_redirects; i++)); do
|
||||
url=$(curl -s -o /dev/null -w '%{redirect_url}' "${url}")
|
||||
[[ ${url} != *.${sfx} ]] || break
|
||||
done
|
||||
((i < max_redirects)) || { err "too many redirects"; }
|
||||
echo "${url}"
|
||||
}
|
||||
|
||||
get_version() {
|
||||
echo "$1" | grep -oP -m 1 '(?<=/v)[\d.\w]+(?=/)'
|
||||
}
|
||||
|
||||
# nix-prefetch-url seems to be uncompressing the archive then taking the hash
|
||||
# so just get the hash from fetchurl
|
||||
sri_get() {
|
||||
local ouput sri
|
||||
output=$(nix-build --expr \
|
||||
"with import $nixpkgs {};
|
||||
fetchurl {
|
||||
url = \"$1\";
|
||||
}" 2>&1 || true)
|
||||
sri=$(echo "$output" | awk '/^\s+got:\s+/{ print $2 }')
|
||||
[[ -z "$sri" ]] && err "$output"
|
||||
echo "$sri"
|
||||
}
|
||||
|
||||
for sys in darwin linux; do
|
||||
url=$(resolve_url ${sys})
|
||||
version=$(get_version "${url}")
|
||||
if [[ ${version} != "$(json_get ".${sys}.version")" ]]; then
|
||||
sri=$(sri_get "${url}")
|
||||
json_set ".${sys}.version" "${version}"
|
||||
json_set ".${sys}.hash" "${sri}"
|
||||
fi
|
||||
done
|
10
nixos/overlays/warp-terminal/versions.json
Normal file
10
nixos/overlays/warp-terminal/versions.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"darwin": {
|
||||
"hash": "sha256-vogQAVbtiw2/U3oJrTj8SUexkEsEfYvmGq50nzy5aYo=",
|
||||
"version": "0.2024.06.25.08.02.stable_01"
|
||||
},
|
||||
"linux": {
|
||||
"hash": "sha256-Fc48bZzFBw9p636Mr8R+W/d1B3kIcOAu/Gd17nbzNfI=",
|
||||
"version": "0.2024.06.25.08.02.stable_01"
|
||||
}
|
||||
}
|
13
nixos/overlays/warp-terminal/warp-terminal.nix
Normal file
13
nixos/overlays/warp-terminal/warp-terminal.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ lib, ...}:
|
||||
let
|
||||
versions = lib.importJSON ./versions.json;
|
||||
in
|
||||
(final: prev: {
|
||||
warp-terminal = prev.warp-terminal.overrideAttrs (oldAttrs: {
|
||||
version = versions.linux.version;
|
||||
src = prev.fetchurl {
|
||||
url = "https://releases.warp.dev/stable/v${versions.linux.version}/warp-terminal-v${versions.linux.version}-1-x86_64.pkg.tar.zst";
|
||||
hash = versions.linux.hash;
|
||||
};
|
||||
});
|
||||
})
|
|
@ -1,10 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
# Support windows partition
|
||||
mySystem = {
|
||||
security.wheelNeedsSudoPassword = false;
|
||||
system.packages = with pkgs; [
|
||||
ntfs3g
|
||||
warp-terminal
|
||||
];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue