Skip to content

Commit

Permalink
Create Nix derivation for bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabani committed Sep 7, 2024
1 parent c2b2b73 commit 98247ba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,8 @@ jobs:

- name: Create darwin bundle
run: |
nix-env -iA macdylibbundler -f ./nix/nixpkgs.nix
# dylibbundler tries to modify the source folder, which fails because it's a nix store path
mkdir -p ./codd.app/Contents/MacOS/
cp static-codd/bin/codd ./codd.app/Contents/MacOS/codd
dylibbundler -od -b -x ./codd.app/Contents/MacOS/codd -d ./codd.app/Contents/libs/ -p @executable_path/../libs/
ls -lh -R codd.app
otool -L ./codd.app/Contents/MacOS/codd
echo Running
./codd.app/Contents/MacOS/codd --help
./codd.app/Contents/MacOS/codd up || echo Failed!
nix build .#coddDarwinAppBundle
unzip -l result/codd.zip
- name: Install codd with nix-env and uninstall it
run: |
Expand Down
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,7 @@
codd-exe =
flakeDefault.packages."x86_64-unknown-linux-musl:codd:exe:codd";
};

coddDarwinAppBundle = import ./nix/codd-darwin-bundle.nix { codd-exe = flakeDefault.packages."codd:exe:codd"; macdylibbundler=pkgs.macdylibbundler; stdenv = pkgs.stdenv; zip = pkgs.zip; };
});
}
22 changes: 22 additions & 0 deletions nix/codd-darwin-bundle.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ codd-exe,
macdylibbundler,
stdenv, zip }:
stdenv.mkDerivation {
name = "codd.app";
buildInputs = [
macdylibbundler
zip ];
src = codd-exe;
installPhase = ''
# dylibbundler tries to modify the source folder, which fails because it's a nix store path
mkdir -p "$out"
mkdir -p codd.app/Contents/MacOS/
cp "$src/bin/codd" "codd.app/Contents/MacOS/codd"
dylibbundler -od -b -x ./codd.app/Contents/MacOS/codd -d ./codd.app/Contents/libs/ -p @executable_path/../libs/
ls -lh -R codd.app
# otool -L ./codd.app/Contents/MacOS/codd
# echo Running
codd.app/Contents/MacOS/codd --help
zip -r "$out/codd.zip" codd.app
'';
}

0 comments on commit 98247ba

Please sign in to comment.