Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: quoting of PRJ_PATH/fragment for installables #358

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions src/local/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions src/std/fwlib/blockTypes/installables.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
root,
super,
nixpkgs,
}:
/*
Use the Installables Blocktype for targets that you want to
Expand All @@ -18,6 +19,7 @@ Available actions:
let
inherit (root) mkCommand actions;
inherit (super) addSelectorFunctor;
l = nixpkgs.lib // builtins;
in
name: {
__functor = addSelectorFunctor;
Expand All @@ -29,33 +31,41 @@ in
fragmentRelPath,
target,
inputs,
}: [
}: let
escapedFragment = l.escapeShellArg fragment;
in [
(actions.build currentSystem target)
# profile commands require a flake ref
(mkCommand currentSystem "install" "install this target" [] ''
# ${target}
nix profile install $PRJ_ROOT#${fragment}
set -x
nix profile install "$PRJ_ROOT#"${escapedFragment}
'' {})
(mkCommand currentSystem "upgrade" "upgrade this target" [] ''
# ${target}
nix profile upgrade $PRJ_ROOT#${fragment}
set -x
nix profile upgrade "$PRJ_ROOT#"${escapedFragment}
'' {})
(mkCommand currentSystem "remove" "remove this target" [] ''
# ${target}
nix profile remove $PRJ_ROOT#${fragment}
set -x
nix profile remove "$PRJ_ROOT#"${escapedFragment}
'' {})
# TODO: use target. `nix bundle` requires a flake ref, but we may be able to use nix-bundle instead as a workaround
(mkCommand currentSystem "bundle" "bundle this target" [] ''
# ${target}
nix bundle --bundler github:Ninlives/relocatable.nix --refresh $PRJ_ROOT#${fragment}
set -x
nix bundle --bundler github:Ninlives/relocatable.nix --refresh "$PRJ_ROOT#"${escapedFragment}
'' {})
(mkCommand currentSystem "bundleImage" "bundle this target to image" [] ''
# ${target}
nix bundle --bundler github:NixOS/bundlers#toDockerImage --refresh $PRJ_ROOT#${fragment}
set -x
nix bundle --bundler github:NixOS/bundlers#toDockerImage --refresh "$PRJ_ROOT#"${escapedFragment}
'' {})
(mkCommand currentSystem "bundleAppImage" "bundle this target to AppImage" [] ''
# ${target}
nix bundle --bundler github:ralismark/nix-appimage --refresh $PRJ_ROOT#${fragment}
set -x
nix bundle --bundler github:ralismark/nix-appimage --refresh "$PRJ_ROOT#"${escapedFragment}
'' {})
];
}
4 changes: 2 additions & 2 deletions src/std/templates/rust/nix/repo/shells.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
deps = [];
text = ''
# ensure CARGO_HOME is populated
mkdir -p $PRJ_DATA_DIR/cargo
ln -snf -t $PRJ_DATA_DIR/cargo $(ls -d ${cell.rust.toolchain}/*)
mkdir -p "$PRJ_DATA_DIR/cargo"
ln -snf -t "$PRJ_DATA_DIR/cargo" $(ls -d ${cell.rust.toolchain}/*)
'';
};

Expand Down
29 changes: 8 additions & 21 deletions src/tests/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.