Skip to content

Commit 1c7ff62

Browse files
committed
nix: fix path substitution
1 parent 02f517c commit 1c7ff62

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,4 @@ jobs:
3737
# except any version with the key that is the same as the `primary-key`
3838
purge-primary-key: never
3939

40-
- run: |
41-
cd lint
42-
nix run .. -- checkall
40+
- run: nix run . -- checkall

flake.nix

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818

1919
devShells = eachSystem (system: {
2020
default = pkgsFor.${system}.mkShell {
21-
packages = with pkgsFor.${system}; [
22-
nodejs_22
23-
pnpm
24-
self.packages.${system}.default
25-
];
21+
inputsFrom = self.packages.${system}.default;
22+
packages = [self.packages.${system}.default];
2623
name = "hyprland-wiki";
2724
};
2825
});

nix/default.nix

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,33 @@ in
2222
installPhase = ''
2323
runHook preInstall
2424
25+
shopt -s dotglob
26+
2527
mkdir -p $out/bin
2628
27-
cat << EOF > $out/bin/lint
29+
cp -r * $out/
30+
31+
# Replace relative paths in package.json scripts with cwd paths
32+
sed -i "s|\.\.|\$cwd|g" $out/package.json
33+
34+
cat << 'EOF' > $out/bin/lint
2835
#!/usr/bin/env bash
29-
${pnpm}/bin/pnpm run \$1
36+
shopt -s dotglob
37+
38+
export cwd=$(pwd)
39+
40+
args=()
41+
for arg in "$@"; do
42+
if [[ "$arg" == ../* ]] || [[ "$arg" == ./* ]] || [[ "$arg" == */* && "$arg" != /* ]]; then
43+
args+=("$(realpath -m "$cwd/$arg")")
44+
else
45+
args+=("$arg")
46+
fi
47+
done
48+
49+
cd ${placeholder "out"}
50+
51+
exec ${pnpm}/bin/pnpm run "''${args[@]}"
3052
EOF
3153
3254
chmod +x $out/bin/lint
@@ -38,7 +60,7 @@ in
3860
runHook preFixup
3961
4062
wrapProgram $out/bin/lint \
41-
--suffix PATH : ${lib.makeBinPath [nodejs]}
63+
--suffix PATH : ${lib.makeBinPath [nodejs]}:$out/node_modules/.bin
4264
4365
runHook postFixup
4466
'';

0 commit comments

Comments
 (0)