Skip to content

Commit

Permalink
lib/types: change pathInStore to allow leading period
Browse files Browse the repository at this point in the history
As of [nix v2.21.0](https://nix.dev/manual/nix/2.25/release-notes/rl-2.21.html):

> Store paths are allowed to start with `.`

I'm not entirely sure what range of versions of `nix` we try to stay
compatible with over here in `nixpkgs`. That said, I don't think
particular change would cause issues for people using a version of `nix`
that doesn't support leading periods.
  • Loading branch information
jfly committed Jan 12, 2025
1 parent e5b47e1 commit 3766aa0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/tests/modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ checkConfigError 'In attrTag, each tag value must be an option, but tag int was
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix
checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash"' config.pathInStore.ok3 ./types.nix
checkConfigOutput '".*/store/\.links"' config.pathInStore.ok4 ./types.nix
checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ""' config.pathInStore.bad1 ./types.nix
checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store"' config.pathInStore.bad2 ./types.nix
checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/"' config.pathInStore.bad3 ./types.nix
checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/.links"' config.pathInStore.bad4 ./types.nix
checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: "/foo/bar"' config.pathInStore.bad5 ./types.nix
checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: "/foo/bar"' config.pathInStore.bad4 ./types.nix

# Check boolean option.
checkConfigOutput '^false$' config.enable ./declare-enable.nix
Expand Down
4 changes: 2 additions & 2 deletions lib/tests/modules/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ in
pathInStore.ok1 = "${storeDir}/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv";
pathInStore.ok2 = "${storeDir}/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15";
pathInStore.ok3 = "${storeDir}/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash";
pathInStore.ok4 = "${storeDir}/.links";
pathInStore.bad1 = "";
pathInStore.bad2 = "${storeDir}";
pathInStore.bad3 = "${storeDir}/";
pathInStore.bad4 = "${storeDir}/.links"; # technically true, but not reasonable
pathInStore.bad5 = "/foo/bar";
pathInStore.bad4 = "/foo/bar";
};
}
2 changes: 1 addition & 1 deletion lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ rec {
name = "pathInStore";
description = "path in the Nix store";
descriptionClass = "noun";
check = x: isStringLike x && builtins.match "${builtins.storeDir}/[^.].*" (toString x) != null;
check = x: isStringLike x && builtins.match "${builtins.storeDir}/.+" (toString x) != null;
merge = mergeEqualOption;
};

Expand Down

0 comments on commit 3766aa0

Please sign in to comment.