about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJonas Heinrich <onny@project-insanity.org>2022-09-16 13:40:17 +0200
committerGitHub <noreply@github.com>2022-09-16 13:40:17 +0200
commit22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827 (patch)
tree2a9a9b18769365f2beb93085810d0d082803fb15 /nixos
parent594b981f7019ffd5a34b278eabe5f732abb96094 (diff)
parent6ec928d73d0580692e75c54c79a0f5a69c1edcf2 (diff)
downloadnixlib-22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827.tar
nixlib-22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827.tar.gz
nixlib-22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827.tar.bz2
nixlib-22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827.tar.lz
nixlib-22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827.tar.xz
nixlib-22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827.tar.zst
nixlib-22c17bd5f3ec1f2c49f9afee4c7f9d99fcd45827.zip
Merge pull request #186940 from NickCao/stratis-cli
stratis-cli: init at 3.2.0
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/tasks/stratis.nix18
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/stratis/default.nix7
-rw-r--r--nixos/tests/stratis/simple.nix39
5 files changed, 66 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 6fd0bacc5f57..d5ab997bda38 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 000000000000..9a85fe23f248
--- /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" ];
+  };
+}
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 2464ec4d404b..e0121fe6b6b8 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 000000000000..6964852e30a0
--- /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 000000000000..7357d71fc52b
--- /dev/null
+++ b/nixos/tests/stratis/simple.nix
@@ -0,0 +1,39 @@
+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.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")
+      assert "test2" in machine.succeed("cat /mnt/testfs1/test1")
+      assert "test1" in machine.succeed("cat /mnt/testfs2/test1")
+    '';
+  })