From c37ae887fdcc8718d8418b8982620b0cf8870851 Mon Sep 17 00:00:00 2001 From: Alex David Date: Fri, 15 Aug 2025 07:51:01 -0700 Subject: [PATCH] Allow consuming jail.nix without flakes --- default.nix | 1 + tests/test-cases.nix | 5 +++++ website/static-docs/index.md | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..f63452f --- /dev/null +++ b/default.nix @@ -0,0 +1 @@ +_: import ./lib diff --git a/tests/test-cases.nix b/tests/test-cases.nix index db227b9..479fe82 100644 --- a/tests/test-cases.nix +++ b/tests/test-cases.nix @@ -7,6 +7,11 @@ in { (jail "hello" pkgs.hello []) "Hello, world!"; + "can be imported using callPackage" = let + jail-nix-without-flake = pkgs.callPackage ../. {}; + jail-without-flake = jail-nix-without-flake.init pkgs; + in assertStdout (jail-without-flake "hello" pkgs.hello []) "Hello, world!"; + "it allows overriding base permissions shared across all jails" = let jail' = jail-nix.lib.extend { inherit pkgs; diff --git a/website/static-docs/index.md b/website/static-docs/index.md index 01f4af8..de1deb1 100644 --- a/website/static-docs/index.md +++ b/website/static-docs/index.md @@ -2,8 +2,9 @@ ## Installation -It is currently recommended to install jail.nix as a flake input to your -configuration: +### Flakes + +To install jail.nix using flakes, add jail.nix to your flake inputs: ```nix # flake.nix @@ -16,6 +17,21 @@ configuration: } ``` +### callPackage + +To install jail.nix using a different dependency manager like +[niv](https://github.com/nmattia/niv), you can use `pkgs.callPackage`: + +```nix +let + sources = import ./nix/sources.nix; + pkgs = import sources.nixpkgs {}; + jail-nix = pkgs.callPackage sources."jail.nix" {}; + jail = jail-nix.init pkgs; +in + # ... +``` + --- ## Initializing