From 096aba38647c5efd82c3751aaddde9b16076c025 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 1 Aug 2022 23:38:22 +0800 Subject: [PATCH 1/9] python3Packages.hs-dbus-signature: init at 0.7 --- .../hs-dbus-signature/default.nix | 28 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 pkgs/development/python-modules/hs-dbus-signature/default.nix diff --git a/pkgs/development/python-modules/hs-dbus-signature/default.nix b/pkgs/development/python-modules/hs-dbus-signature/default.nix new file mode 100644 index 0000000000000..7d071b75c3b12 --- /dev/null +++ b/pkgs/development/python-modules/hs-dbus-signature/default.nix @@ -0,0 +1,28 @@ +{ lib +, buildPythonPackage +, fetchPypi +, pytestCheckHook +, hypothesis +}: + +buildPythonPackage rec { + pname = "hs-dbus-signature"; + version = "0.7"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-NNnTcSX+K8zU+sj1QBd13h7aEXN9VqltJMNWCuhgZ6I="; + }; + + checkInputs = [ + pytestCheckHook + hypothesis + ]; + + meta = with lib; { + description = "A Hypothesis Strategy for Generating Arbitrary DBus Signatures"; + homepage = "https://github.com/stratis-storage/hs-dbus-signature"; + license = licenses.mpl20; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index a1e4469769711..18f5d5fe71308 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4232,6 +4232,8 @@ in { hpccm = callPackage ../development/python-modules/hpccm { }; + hs-dbus-signature = callPackage ../development/python-modules/hs-dbus-signature { }; + hsaudiotag3k = callPackage ../development/python-modules/hsaudiotag3k { }; hsluv = callPackage ../development/python-modules/hsluv { }; From dc168de323e6ea34c49153b0c9b592800206d2af Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 1 Aug 2022 23:39:05 +0800 Subject: [PATCH 2/9] python3Packages.dbus-signature-pyparsing: init at 0.04 --- .../dbus-signature-pyparsing/default.nix | 34 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 pkgs/development/python-modules/dbus-signature-pyparsing/default.nix diff --git a/pkgs/development/python-modules/dbus-signature-pyparsing/default.nix b/pkgs/development/python-modules/dbus-signature-pyparsing/default.nix new file mode 100644 index 0000000000000..659fcc3ed59d8 --- /dev/null +++ b/pkgs/development/python-modules/dbus-signature-pyparsing/default.nix @@ -0,0 +1,34 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pyparsing +, pytestCheckHook +, hypothesis +, hs-dbus-signature +}: + +buildPythonPackage rec { + pname = "dbus-signature-pyparsing"; + version = "0.04"; + + src = fetchFromGitHub { + owner = "stratis-storage"; + repo = pname; + rev = "v${version}"; + hash = "sha256-IXyepfq7pLTRkTolKWsKGrYDoxukVC9JTrxS9xV7s2I="; + }; + + propagatedBuildInputs = [ pyparsing ]; + checkInputs = [ + pytestCheckHook + hypothesis + hs-dbus-signature + ]; + + meta = with lib; { + description = "A Parser for a D-Bus Signature"; + homepage = "https://github.com/stratis-storage/dbus-signature-pyparsing"; + license = licenses.asl20; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 18f5d5fe71308..1b7caca0f253b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2299,6 +2299,8 @@ in { inherit (pkgs) dbus; }; + dbus-signature-pyparsing = callPackage ../development/python-modules/dbus-signature-pyparsing { }; + dbutils = callPackage ../development/python-modules/dbutils { }; db-dtypes = callPackage ../development/python-modules/db-dtypes { }; From de6160d4ff407d948f5604607ee4ac2eb1b84f3a Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 1 Aug 2022 23:39:47 +0800 Subject: [PATCH 3/9] python3Packages.into-dbus-python: init at 0.08 --- .../into-dbus-python/default.nix | 38 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 40 insertions(+) create mode 100644 pkgs/development/python-modules/into-dbus-python/default.nix diff --git a/pkgs/development/python-modules/into-dbus-python/default.nix b/pkgs/development/python-modules/into-dbus-python/default.nix new file mode 100644 index 0000000000000..1d893cd696926 --- /dev/null +++ b/pkgs/development/python-modules/into-dbus-python/default.nix @@ -0,0 +1,38 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, dbus-signature-pyparsing +, dbus-python +, pytestCheckHook +, hypothesis +, hs-dbus-signature +}: + +buildPythonPackage rec { + pname = "into-dbus-python"; + version = "0.08"; + + src = fetchFromGitHub { + owner = "stratis-storage"; + repo = pname; + rev = "v${version}"; + hash = "sha256-Z8e6oAvRMIisMjG4HcS5jSH1znGVc7pGpMITo5fXYVs="; + }; + + propagatedBuildInputs = [ + dbus-signature-pyparsing + dbus-python + ]; + checkInputs = [ + pytestCheckHook + hypothesis + hs-dbus-signature + ]; + + meta = with lib; { + description = "A transformer to dbus-python types"; + homepage = "https://github.com/stratis-storage/into-dbus-python"; + license = licenses.asl20; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 1b7caca0f253b..e56dd1762cf14 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4524,6 +4524,8 @@ in { intervaltree = callPackage ../development/python-modules/intervaltree { }; + into-dbus-python = callPackage ../development/python-modules/into-dbus-python { }; + intreehooks = callPackage ../development/python-modules/intreehooks { }; invocations = callPackage ../development/python-modules/invocations { }; From 91dee8a4562c62e7af4f612c4d1106193a8d01e0 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 1 Aug 2022 23:41:00 +0800 Subject: [PATCH 4/9] python3Packages.dbus-python-client-gen: init at 0.8 --- .../dbus-python-client-gen/default.nix | 34 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 pkgs/development/python-modules/dbus-python-client-gen/default.nix diff --git a/pkgs/development/python-modules/dbus-python-client-gen/default.nix b/pkgs/development/python-modules/dbus-python-client-gen/default.nix new file mode 100644 index 0000000000000..100144c152e4f --- /dev/null +++ b/pkgs/development/python-modules/dbus-python-client-gen/default.nix @@ -0,0 +1,34 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, into-dbus-python +, dbus-python +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "dbus-python-client-gen"; + version = "0.8"; + + src = fetchFromGitHub { + owner = "stratis-storage"; + repo = pname; + rev = "v${version}"; + hash = "sha256-nSzxT65WHBVct5pGHmIAHJXftd0tKZeK/argN+V9xcs="; + }; + + propagatedBuildInputs = [ + into-dbus-python + dbus-python + ]; + checkInputs = [ + pytestCheckHook + ]; + + meta = with lib; { + description = "A Python library for generating dbus-python client code"; + homepage = "https://github.com/stratis-storage/dbus-python-client-gen"; + license = licenses.mpl20; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e56dd1762cf14..dd5c978f7d070 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2299,6 +2299,8 @@ in { inherit (pkgs) dbus; }; + dbus-python-client-gen = callPackage ../development/python-modules/dbus-python-client-gen { }; + dbus-signature-pyparsing = callPackage ../development/python-modules/dbus-signature-pyparsing { }; dbutils = callPackage ../development/python-modules/dbutils { }; From bb307c917dde9f6f80114cd5b43b210ed552b884 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 1 Aug 2022 23:41:31 +0800 Subject: [PATCH 5/9] stratis-cli: init at 3.2.0 --- .../tools/filesystems/stratis-cli/default.nix | 33 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 35 insertions(+) create mode 100644 pkgs/tools/filesystems/stratis-cli/default.nix diff --git a/pkgs/tools/filesystems/stratis-cli/default.nix b/pkgs/tools/filesystems/stratis-cli/default.nix new file mode 100644 index 0000000000000..b0e279d0228c1 --- /dev/null +++ b/pkgs/tools/filesystems/stratis-cli/default.nix @@ -0,0 +1,33 @@ +{ lib +, python3Packages +, fetchFromGitHub +}: + +python3Packages.buildPythonApplication rec { + pname = "stratis-cli"; + version = "3.2.0"; + + src = fetchFromGitHub { + owner = "stratis-storage"; + repo = pname; + rev = "v${version}"; + hash = "sha256-JQXTzvm4l/pl2T4djZ3HEdDQJdFE+I9doe8Iv5q34kw="; + }; + + propagatedBuildInputs = with python3Packages; [ + psutil + python-dateutil + wcwidth + justbytes + dbus-client-gen + dbus-python-client-gen + packaging + ]; + + meta = with lib; { + description = "CLI for the Stratis project"; + homepage = "https://stratis-storage.github.io"; + license = licenses.asl20; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ce4a69104f56e..425b32c7ed825 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5918,6 +5918,8 @@ with pkgs; stratisd = callPackage ../tools/filesystems/stratisd { }; + stratis-cli = callPackage ../tools/filesystems/stratis-cli { }; + strawberry = libsForQt5.callPackage ../applications/audio/strawberry { }; schildichat-desktop = callPackage ../applications/networking/instant-messengers/schildichat/schildichat-desktop.nix { From ca03f2dc0fff2d30387714e43886af5e74425820 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 12 Sep 2022 14:38:10 +0800 Subject: [PATCH 6/9] nixos/stratis: init --- nixos/modules/module-list.nix | 1 + nixos/modules/tasks/stratis.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 nixos/modules/tasks/stratis.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index e6f077dd5d085..a7231b066befd 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1266,6 +1266,7 @@ ./tasks/network-interfaces-scripted.nix ./tasks/scsi-link-power-management.nix ./tasks/snapraid.nix + ./tasks/stratis.nix ./tasks/swraid.nix ./tasks/trackpoint.nix ./tasks/powertop.nix diff --git a/nixos/modules/tasks/stratis.nix b/nixos/modules/tasks/stratis.nix new file mode 100644 index 0000000000000..9a85fe23f248d --- /dev/null +++ b/nixos/modules/tasks/stratis.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.stratis; +in +{ + options.services.stratis = { + enable = lib.mkEnableOption (lib.mdDoc "Stratis Storage - Easy to use local storage management for Linux"); + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ pkgs.stratis-cli ]; + systemd.packages = [ pkgs.stratisd ]; + services.dbus.packages = [ pkgs.stratisd ]; + services.udev.packages = [ pkgs.stratisd ]; + systemd.services.stratisd.wantedBy = [ "sysinit.target" ]; + }; +} From 4abf0ee79352df4f107d7eb0fccced381a9f673b Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 12 Sep 2022 15:18:11 +0800 Subject: [PATCH 7/9] nixos/stratis: add test for simple usecases --- nixos/tests/all-tests.nix | 1 + nixos/tests/stratis/default.nix | 7 +++++++ nixos/tests/stratis/simple.nix | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 nixos/tests/stratis/default.nix create mode 100644 nixos/tests/stratis/simple.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 230ad47f3bfac..0faa17d8b5f83 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -533,6 +533,7 @@ in { sssd-ldap = handleTestOn ["x86_64-linux"] ./sssd-ldap.nix {}; starship = handleTest ./starship.nix {}; step-ca = handleTestOn ["x86_64-linux"] ./step-ca.nix {}; + stratis = handleTest ./stratis {}; strongswan-swanctl = handleTest ./strongswan-swanctl.nix {}; stunnel = handleTest ./stunnel.nix {}; sudo = handleTest ./sudo.nix {}; diff --git a/nixos/tests/stratis/default.nix b/nixos/tests/stratis/default.nix new file mode 100644 index 0000000000000..6964852e30a09 --- /dev/null +++ b/nixos/tests/stratis/default.nix @@ -0,0 +1,7 @@ +{ system ? builtins.currentSystem +, pkgs ? import ../../.. { inherit system; } +}: + +{ + simple = import ./simple.nix { inherit system pkgs; }; +} diff --git a/nixos/tests/stratis/simple.nix b/nixos/tests/stratis/simple.nix new file mode 100644 index 0000000000000..0878cb12d967a --- /dev/null +++ b/nixos/tests/stratis/simple.nix @@ -0,0 +1,37 @@ +import ../make-test-python.nix ({ pkgs, ... }: + { + name = "stratis"; + + meta = with pkgs.lib.maintainers; { + maintainers = [ nickcao ]; + }; + + nodes.machine = { pkgs, ... }: { + services.stratis.enable = true; + virtualisation.emptyDiskImages = [ 1024 1024 1024 1024 ]; + }; + + testScript = '' + machine.wait_for_unit("stratisd") + # test pool creation + machine.succeed("stratis pool create testpool /dev/vdb") + machine.succeed("stratis pool add-data testpool /dev/vdc") + machine.succeed("stratis pool init-cache testpool /dev/vdd") + machine.succeed("stratis pool add-cache testpool /dev/vde") + # test filesystem creation and rename + machine.succeed("stratis filesystem create testpool testfs0") + machine.succeed("stratis filesystem rename testpool testfs0 testfs1") + # test snapshot + machine.succeed("mkdir -p /mnt/testfs1 /mnt/testfs2") + machine.succeed("mount /dev/stratis/testpool/testfs1 /mnt/testfs1") + machine.succeed("echo test0 > /mnt/testfs1/test0") + machine.succeed("echo test1 > /mnt/testfs1/test1") + machine.succeed("stratis filesystem snapshot testpool testfs1 testfs2") + machine.succeed("echo test2 > /mnt/testfs1/test1") + machine.succeed("mount /dev/stratis/testpool/testfs2 /mnt/testfs2") + assert "test0" in machine.succeed("cat /mnt/testfs1/test0") + assert "test0" in machine.succeed("cat /mnt/testfs2/test0") + assert "test2" in machine.succeed("cat /mnt/testfs1/test1") + assert "test1" in machine.succeed("cat /mnt/testfs2/test1") + ''; + }) From 7398c337c9ce56c16bb93756f3e2f763058a9efa Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 12 Sep 2022 15:20:59 +0800 Subject: [PATCH 8/9] nixos/stratis: passthru tests to stratis-cli and stratisd --- pkgs/tools/filesystems/stratis-cli/default.nix | 3 +++ pkgs/tools/filesystems/stratisd/default.nix | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkgs/tools/filesystems/stratis-cli/default.nix b/pkgs/tools/filesystems/stratis-cli/default.nix index b0e279d0228c1..813ecfa22c6de 100644 --- a/pkgs/tools/filesystems/stratis-cli/default.nix +++ b/pkgs/tools/filesystems/stratis-cli/default.nix @@ -1,6 +1,7 @@ { lib , python3Packages , fetchFromGitHub +, nixosTests }: python3Packages.buildPythonApplication rec { @@ -24,6 +25,8 @@ python3Packages.buildPythonApplication rec { packaging ]; + passthru.tests = nixosTests.stratis; + meta = with lib; { description = "CLI for the Stratis project"; homepage = "https://stratis-storage.github.io"; diff --git a/pkgs/tools/filesystems/stratisd/default.nix b/pkgs/tools/filesystems/stratisd/default.nix index 1302c10ea8c1c..b37c46c4e2d8a 100644 --- a/pkgs/tools/filesystems/stratisd/default.nix +++ b/pkgs/tools/filesystems/stratisd/default.nix @@ -18,6 +18,7 @@ , tpm2-tools , coreutils , clevisSupport ? false +, nixosTests }: stdenv.mkDerivation rec { @@ -95,6 +96,8 @@ stdenv.mkDerivation rec { rm -r "$out/lib/systemd/system-generators" ''; + passthru.tests = nixosTests.stratis; + meta = with lib; { description = "Easy to use local storage management for Linux"; homepage = "https://stratis-storage.github.io"; From 6ec928d73d0580692e75c54c79a0f5a69c1edcf2 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 12 Sep 2022 23:49:52 +0800 Subject: [PATCH 9/9] nixos/stratis: wait for devices to appear in tests --- nixos/tests/stratis/simple.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/tests/stratis/simple.nix b/nixos/tests/stratis/simple.nix index 0878cb12d967a..7357d71fc52ba 100644 --- a/nixos/tests/stratis/simple.nix +++ b/nixos/tests/stratis/simple.nix @@ -23,11 +23,13 @@ import ../make-test-python.nix ({ pkgs, ... }: machine.succeed("stratis filesystem rename testpool testfs0 testfs1") # test snapshot machine.succeed("mkdir -p /mnt/testfs1 /mnt/testfs2") + machine.wait_for_file("/dev/stratis/testpool/testfs1") machine.succeed("mount /dev/stratis/testpool/testfs1 /mnt/testfs1") machine.succeed("echo test0 > /mnt/testfs1/test0") machine.succeed("echo test1 > /mnt/testfs1/test1") machine.succeed("stratis filesystem snapshot testpool testfs1 testfs2") machine.succeed("echo test2 > /mnt/testfs1/test1") + machine.wait_for_file("/dev/stratis/testpool/testfs2") machine.succeed("mount /dev/stratis/testpool/testfs2 /mnt/testfs2") assert "test0" in machine.succeed("cat /mnt/testfs1/test0") assert "test0" in machine.succeed("cat /mnt/testfs2/test0")