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

feat: make template with hello world (#1) #2

Merged
merged 1 commit into from
Oct 20, 2024
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
26 changes: 2 additions & 24 deletions .github/workflows/auto_nigthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,10 @@ jobs:
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "Tag name will be: $TAG_NAME"

- name: Generate tar.gz from src
id: generate_tar
- name: Build test package.nix
id: build_test_package
run: |
PKG_NAME="$(basename "${{ github.repository }}" | sed 's/pkg-//g')"
FILE_NAME="src-${PKG_NAME}.tar.gz"
echo "PKG_NAME=$PKG_NAME" >> $GITHUB_ENV
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
tar -czvf ${FILE_NAME} src/
FILE_HASH=$(sha256sum ${FILE_NAME} | cut -d ' ' -f 1)
echo "FILE_HASH=$FILE_HASH" >> $GITHUB_ENV

- name: Generate package.nix
id: generate_package
run: |
URL=$(echo \
"https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/${{ env.FILE_NAME }}" \
| sed 's/\//\\\//g'
)
SRC="src = fetchurl {\n url = \"${URL}\";\n sha256 = \"${{ env.FILE_HASH }}\";\n }"
sed -i "s/src = .\/src/src = .\/${{ env.FILE_NAME }}/g" ./package.nix
git add ./${{ env.FILE_NAME }}
nix build
git reset ./${{ env.FILE_NAME }}
sed -i "s/src = .\/${{ env.FILE_NAME }}/${SRC}/g" ./package.nix
sed -i "s/version = \".*\";/version = \"${{ env.TAG_NAME }}\";/g" ./package.nix
sed -i "1s/.*/{\n fetchurl,/" ./package.nix

- name: Create Release
uses: softprops/action-gh-release@v2
Expand Down
28 changes: 4 additions & 24 deletions .github/workflows/auto_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,15 @@ jobs:
id: date
run: |
TAG_NAME="release-$(date +'%Y.%m.%d-%H.%M.%S')"
PKG_NAME="$(basename "${{ github.repository }}" | sed 's/pkg-//g')"
echo "PKG_NAME=$PKG_NAME" >> $GITHUB_ENV
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "Tag name will be: $TAG_NAME"

- name: Generate tar.gz from src
id: generate_tar
run: |
PKG_NAME="$(basename "${{ github.repository }}" | sed 's/pkg-//g')"
FILE_NAME="src-${PKG_NAME}.tar.gz"
echo "PKG_NAME=$PKG_NAME" >> $GITHUB_ENV
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
tar -czvf ${FILE_NAME} src/
FILE_HASH=$(sha256sum ${FILE_NAME} | cut -d ' ' -f 1)
echo "FILE_HASH=$FILE_HASH" >> $GITHUB_ENV

- name: Generate package.nix
id: generate_package
- name: Build test package.nix
id: build_test_package
run: |
URL=$(echo \
"https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/${{ env.FILE_NAME }}" \
| sed 's/\//\\\//g'
)
SRC="src = fetchurl {\n url = \"${URL}\";\n sha256 = \"${{ env.FILE_HASH }}\";\n }"
sed -i "s/src = .\/src/src = .\/${{ env.FILE_NAME }}/g" ./package.nix
git add ./${{ env.FILE_NAME }}
nix build
git reset ./${{ env.FILE_NAME }}
sed -i "s/src = .\/${{ env.FILE_NAME }}/${SRC}/g" ./package.nix
sed -i "s/version = \".*\";/version = \"${{ env.TAG_NAME }}\";/g" ./package.nix
sed -i "1s/.*/{\n fetchurl,/" ./package.nix

- name: Create Release
uses: softprops/action-gh-release@v2
Expand Down
26 changes: 2 additions & 24 deletions .github/workflows/auto_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,10 @@ jobs:
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "Tag name will be: $TAG_NAME"

- name: Generate tar.gz from src
id: generate_tar
- name: Build test package.nix
id: build_test_package
run: |
PKG_NAME="$(basename "${{ github.repository }}" | sed 's/pkg-//g')"
FILE_NAME="src-${PKG_NAME}.tar.gz"
echo "PKG_NAME=$PKG_NAME" >> $GITHUB_ENV
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
tar -czvf ${FILE_NAME} src/
FILE_HASH=$(sha256sum ${FILE_NAME} | cut -d ' ' -f 1)
echo "FILE_HASH=$FILE_HASH" >> $GITHUB_ENV

- name: Generate package.nix
id: generate_package
run: |
URL=$(echo \
"https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/${{ env.FILE_NAME }}" \
| sed 's/\//\\\//g'
)
SRC="src = fetchurl {\n url = \"${URL}\";\n sha256 = \"${{ env.FILE_HASH }}\";\n }"
sed -i "s/src = .\/src/src = .\/${{ env.FILE_NAME }}/g" ./package.nix
git add ./${{ env.FILE_NAME }}
nix build
git reset ./${{ env.FILE_NAME }}
sed -i "s/src = .\/${{ env.FILE_NAME }}/${SRC}/g" ./package.nix
sed -i "s/version = \".*\";/version = \"${{ env.TAG_NAME }}\";/g" ./package.nix
sed -i "1s/.*/{\n fetchurl,/" ./package.nix

- name: Create Release
uses: softprops/action-gh-release@v2
Expand Down
90 changes: 36 additions & 54 deletions package.nix
Original file line number Diff line number Diff line change
@@ -1,70 +1,52 @@
{
stdenv,
lib,
makeWrapper,
bash,
python3Packages,
fetchFromGitHub,
fetchPypi,
}:
############
# Packages #
#########################################################################
let
iconPath = "icon.png";
name = "Exemple Application";
comment = "Exemple Application";
in
# --------------------------------------------------------------------- #
stdenv.mkDerivation (finalAttrs: {
pname = "exemple";
version = "24.05-15-06-2024";
comment = "Python3 Hello World";
pname = "pip-hello-world";
version = "0.1";
in python3Packages.buildPythonApplication rec {
## ----------------------------------------------------------------- ##
src = ./src;
inherit pname version;
format = "pyproject"; # for not setup.py
dontUseCmakeConfigure = true; # for not setup.py
doCheck = false;
## ----------------------------------------------------------------- ##
nativeBuildInputs = [ makeWrapper ];
src = fetchPypi {
inherit pname version;
hash = "sha256-framXG712U7EWdZAP5Xz7dzEGkomaF7aoF7kX6sq5GU=";
};
## ----------------------------------------------------------------- ##
prePatch = ''
patchShebangs . ;

substituteInPlace exemple \
--replace-fail "exemple-2" "${placeholder "out"}/bin/exemple-2"
'';
# src = fetchFromGitHub {
# owner = "pedrocunial";
# repo = "pip-helloworld";
# rev = version; # 7385eb989647509325d4f8f60e839ee699f5802a
# sha256 = "";
# };
## ----------------------------------------------------------------- ##
installPhase = ''
runHook preInstall

mkdir -p $out/bin/ $out/Applications/
cp -r ./ $out/Applications/${finalAttrs.pname}/

install -Dm 755 ${finalAttrs.pname} $out/bin/${finalAttrs.pname}
install -Dm 755 exemple-2 $out/bin/exemple-2

echo -e "[Desktop Entry]\n" \
"Type=Application\n" \
"Name=${name}\n" \
"Comment=${comment}\n" \
"Icon=$out/Applications/${finalAttrs.pname}/${iconPath}\n" \
"Exec=$out/bin/${finalAttrs.pname}\n" \
"Terminal=false" > ./${finalAttrs.pname}.desktop

install -D ${finalAttrs.pname}.desktop \
$out/share/applications/${finalAttrs.pname}.desktop

runHook postInstall
'';
# nativeBuildInputs = [
# ];
#
# buildInputs = [
# ];
## ----------------------------------------------------------------- ##
postFixup = ''
wrapProgram $out/bin/exemple-2 \
--prefix PATH : ${lib.makeBinPath [
bash
]}
'';
propagatedBuildInputs = with python3Packages; [
setuptools
];
## ----------------------------------------------------------------- ##
meta = {
meta = with lib; {
description = comment;
homepage = "https://github.com/RevoluNix/pkgs-template/";
maintainers = with lib.maintainers; [ pikatsuto ];
licenses = lib.licenses.lgpl2;
platforms = lib.platforms.linux;
mainProgram = finalAttrs.pname;
homepage = "https://github.com/RevoluNix/pkg-python311Package.template/";
license = licenses.lgpl2;
platforms = platforms.linux;
maintainers = with maintainers; [ pikatsuto ];
mainProgram = pname;
};
#######################################################################
})
}
3 changes: 0 additions & 3 deletions src/exemple

This file was deleted.

3 changes: 0 additions & 3 deletions src/exemple-2

This file was deleted.

Binary file removed src/icon.png
Binary file not shown.