diff --git a/nixos/modules/nixos/system/systempackages.nix b/nixos/modules/nixos/system/systempackages.nix index bfa6f37..ba05893 100644 --- a/nixos/modules/nixos/system/systempackages.nix +++ b/nixos/modules/nixos/system/systempackages.nix @@ -5,12 +5,11 @@ let in { options.mySystem.system = { - packages = mkOption - { - type = with types; listOf package; - description = "List of system level package installs"; - default = [ ]; - }; + packages = mkOption { + type = with types; listOf package; + description = "List of system level package installs"; + default = [ ]; + }; }; # System packages deployed globally. # This is NixOS so lets keep this liiight? diff --git a/nixos/overlays/default.nix b/nixos/overlays/default.nix index 8d4634d..88e52b1 100644 --- a/nixos/overlays/default.nix +++ b/nixos/overlays/default.nix @@ -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. diff --git a/nixos/overlays/warp-terminal/update.sh b/nixos/overlays/warp-terminal/update.sh new file mode 100755 index 0000000..f9bcec2 --- /dev/null +++ b/nixos/overlays/warp-terminal/update.sh @@ -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 '' --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 \ No newline at end of file diff --git a/nixos/overlays/warp-terminal/versions.json b/nixos/overlays/warp-terminal/versions.json new file mode 100644 index 0000000..1890475 --- /dev/null +++ b/nixos/overlays/warp-terminal/versions.json @@ -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" + } +} diff --git a/nixos/overlays/warp-terminal/warp-terminal.nix b/nixos/overlays/warp-terminal/warp-terminal.nix new file mode 100644 index 0000000..e9b4665 --- /dev/null +++ b/nixos/overlays/warp-terminal/warp-terminal.nix @@ -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; + }; + }); +}) \ No newline at end of file diff --git a/nixos/profiles/hw-legion-15arh05h.nix b/nixos/profiles/hw-legion-15arh05h.nix index 5281387..b28df24 100644 --- a/nixos/profiles/hw-legion-15arh05h.nix +++ b/nixos/profiles/hw-legion-15arh05h.nix @@ -1,10 +1,11 @@ -{ config, lib, pkgs, ... }: +{ lib, pkgs, ... }: { # Support windows partition mySystem = { security.wheelNeedsSudoPassword = false; system.packages = with pkgs; [ ntfs3g + warp-terminal ]; };