Skip to content

Commit

Permalink
fix: quoting of PRJ_PATH/fragment for installables
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Kolloch authored and blaggacao committed Nov 3, 2023
1 parent 845fd29 commit 403fd2a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 51 deletions.
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.

0 comments on commit 403fd2a

Please sign in to comment.