From 2a93f24a58da6c70c8e803a6e8eb1397a24c8e71 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 5 Jan 2024 00:07:01 +0000 Subject: [PATCH] add turris "schnapps" tool in its current state this is useful for turris omnia only, but will allow us to do installs and rollback to turris os if needed. --- modules/schnapps/default.nix | 19 +++++++++++++++++++ pkgs/default.nix | 7 +++++++ pkgs/schnapps/default.nix | 27 +++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 modules/schnapps/default.nix create mode 100644 pkgs/schnapps/default.nix diff --git a/modules/schnapps/default.nix b/modules/schnapps/default.nix new file mode 100644 index 0000000..5bf0aa8 --- /dev/null +++ b/modules/schnapps/default.nix @@ -0,0 +1,19 @@ +{ config, pkgs, lib, ... } : +{ + config = { + programs.busybox = { + options = { + # schnapps is a shell script that needs + # [ command + # find -maxdepth -mindepth + # head -c + # echo -n + ASH_TEST = "y"; + FEATURE_FIND_MAXDEPTH = "y"; + FEATURE_FANCY_HEAD = "y"; + FEATURE_FANCY_ECHO = "y"; + }; + }; + defaultProfile.packages = [ pkgs.schnapps ] ; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 2ad956b..823d560 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -92,6 +92,13 @@ in { run-liminix-vm = callPackage ./run-liminix-vm {}; s6-init-bin = callPackage ./s6-init-bin {}; s6-rc-database = callPackage ./s6-rc-database {}; + + # schnapps is written by Turris and provides a high-level interface + # to btrfs snapshots. It may be useful on the Turris Omnia to + # install Liminix while retaining the ability to rollback to the + # vendor OS, or even to derisk Liminix updates on that device + schnapps = callPackage ./schnapps {}; + serviceFns = callPackage ./service-fns {}; swconfig = callPackage ./swconfig {}; systemconfig = callPackage ./systemconfig {}; diff --git a/pkgs/schnapps/default.nix b/pkgs/schnapps/default.nix new file mode 100644 index 0000000..b5ac8be --- /dev/null +++ b/pkgs/schnapps/default.nix @@ -0,0 +1,27 @@ +{ + stdenv +, fetchFromGitLab +, makeWrapper +, btrfs-progs +, lib +}: +let search_path = lib.makeBinPath [btrfs-progs]; +in stdenv.mkDerivation { + pname = "schnapps"; + version = "2.13.0"; + + src =fetchFromGitLab { + domain = "gitlab.nic.cz"; + owner = "turris"; + repo = "schnapps"; + rev = "53ac92c765d670be4b98dba2c948859a9ac7607f"; + hash = "sha256-yVgXK+V2wrcOPLB6X6qm3hyBcWcyzNhfJjFF7YRk5Lc="; + }; + + nativeBuildInputs = [ makeWrapper ]; + buildPhase = ":"; + installPhase = '' + install -D schnapps.sh $out/bin/schnapps + wrapProgram $out/bin/schnapps --prefix PATH : "${search_path}" + ''; +}