Create python-games
This commit is contained in:
78
flake.lock
generated
Normal file
78
flake.lock
generated
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1780161478,
|
||||
"narHash": "sha256-rDecpW3DELGlKJzQ8mNpiYMZM/GiWJBJtDb8C5RMZ4E=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4559cbbadcd2ee31608d9c4638b4875554e7dc71",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "release-26.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"python-games": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1422347668,
|
||||
"narHash": "sha256-jcSlpFAwnYzCB8f30sqyxteeKYvsZbk/ZBj5o49b+H0=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "956e7604905940db7132644f7b2660874fd6e102",
|
||||
"revCount": 8,
|
||||
"type": "git",
|
||||
"url": "https://github.com/KenT2/python-games.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/KenT2/python-games.git"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"python-games": "python-games"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
76
flake.nix
Normal file
76
flake.nix
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/release-26.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
python-games = {
|
||||
url = "git+https://github.com/KenT2/python-games.git";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, flake-utils, python-games, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
|
||||
python = pkgs.python313;
|
||||
|
||||
python-with-deps = python.withPackages (python-pkgs: with python-pkgs; [
|
||||
pygame
|
||||
]);
|
||||
in
|
||||
{
|
||||
packages.default = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "python-games";
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
src = python-games;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin -p $out/share/python_games -p $out/share/applications
|
||||
|
||||
# Copy launcher to bin directory
|
||||
cp launcher.sh $out/bin/python-games
|
||||
|
||||
# Copy everything else to share directory
|
||||
cp -r . $out/share/python_games
|
||||
rm $out/share/python_games/launcher.sh
|
||||
|
||||
# Substitute paths in the launcher script
|
||||
substituteInPlace $out/bin/python-games \
|
||||
--replace-fail "cd /home/\$USER/python_games" "cd $out/share/python_games"
|
||||
|
||||
# Use xdg-open instead of sensible-browser for opening the website
|
||||
substituteInPlace $out/bin/python-games \
|
||||
--replace-fail "sensible-browser" "${pkgs.xdg-utils}/bin/xdg-open"
|
||||
|
||||
chmod +x $out/bin/python-games
|
||||
|
||||
# Wrap the program to allow using packages
|
||||
wrapProgram $out/bin/python-games \
|
||||
--prefix PATH : "${pkgs.zenity}/bin" \
|
||||
--prefix PATH : "${python-with-deps}/bin"
|
||||
|
||||
# Write desktop entry
|
||||
cat <<EOF > $out/share/applications/python-games.desktop
|
||||
[Desktop Entry]
|
||||
Name=Python Games
|
||||
Comment=Examples of games written in Python
|
||||
Exec=$out/bin/python-games
|
||||
Icon=python
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Application;Game;
|
||||
StartupNotify=true
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user