aboutsummaryrefslogtreecommitdiff
path: root/home-manager/tests/modules/files/out-of-store-symlink.nix
blob: af274aaebec6895b0c4ff39b0a7988155242f811 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{ config, lib, ... }:

with lib;

let

  filePath = ./. + "/source with spaces!";

in {
  config = {
    home.file."oos".source = config.lib.file.mkOutOfStoreSymlink filePath;

    nmt.script = ''
      assertLinkExists "home-files/oos"

      storePath="$(readlink $TESTED/home-files/oos)"

      if [[ ! -L $storePath ]]; then
        fail "Expected $storePath to be a symbolic link, but it was not."
      fi

      actual="$(readlink "$storePath")"
      expected="${toString filePath}"
      if [[ $actual != $expected ]]; then
        fail "Symlink home-files/oos should point to $expected via the Nix store, but it actually points to $actual."
      fi
    '';
  };
}